Commit e9a130ed authored by Romain Courteaud's avatar Romain Courteaud

[replicateStorage] Replicate all documents/attachments before raising.

Accumulate all operations done in a ReplicateReport object.

This ReplicateReport is returned by the repair method in any case (success or failure).

If an error occured while replicating a document, do not stop the full process and log the issue in the report.
Which means repair now always tries to replicate all documents even if one fails.

Each operation has a code to ease parsing it if needed.

By default, the report only contains error code (< 100).
It is possible to change the log level by using the 'report_level' storage parameter.

If the 'debug' parameter is set to true, codes will also be displayed in the console.log.
parent 8ab4f278
...@@ -29,7 +29,218 @@ ...@@ -29,7 +29,218 @@
CONFLICT_THROW = 0, CONFLICT_THROW = 0,
CONFLICT_KEEP_LOCAL = 1, CONFLICT_KEEP_LOCAL = 1,
CONFLICT_KEEP_REMOTE = 2, CONFLICT_KEEP_REMOTE = 2,
CONFLICT_CONTINUE = 3; CONFLICT_CONTINUE = 3,
// 0 - 99 error
LOG_UNEXPECTED_ERROR = 0,
LOG_UNRESOLVED_CONFLICT = 74,
LOG_UNEXPECTED_LOCAL_ATTACHMENT = 49,
LOG_UNEXPECTED_REMOTE_ATTACHMENT = 47,
LOG_UNRESOLVED_ATTACHMENT_CONFLICT = 75,
// 100 - 199 solving conflict
LOG_FORCE_PUT_REMOTE = 116,
LOG_FORCE_DELETE_REMOTE = 136,
LOG_FORCE_PUT_REMOTE_ATTACHMENT = 117,
LOG_FORCE_DELETE_REMOTE_ATTACHMENT = 137,
LOG_FORCE_PUT_LOCAL = 118,
LOG_FORCE_DELETE_LOCAL = 138,
LOG_FORCE_PUT_LOCAL_ATTACHMENT = 119,
LOG_FORCE_DELETE_LOCAL_ATTACHMENT = 139,
// 200 - 299 pushing change
LOG_PUT_REMOTE = 216,
LOG_POST_REMOTE = 226,
LOG_DELETE_REMOTE = 236,
LOG_PUT_REMOTE_ATTACHMENT = 217,
LOG_DELETE_REMOTE_ATTACHMENT = 237,
LOG_PUT_LOCAL = 218,
LOG_POST_LOCAL = 228,
LOG_DELETE_LOCAL = 238,
LOG_PUT_LOCAL_ATTACHMENT = 219,
LOG_DELETE_LOCAL_ATTACHMENT = 239,
LOG_FALSE_CONFLICT = 284,
LOG_FALSE_CONFLICT_ATTACHMENT = 285,
// 300 - 399 nothing to do
LOG_SKIP_LOCAL_CREATION = 348,
LOG_SKIP_LOCAL_MODIFICATION = 358,
LOG_SKIP_LOCAL_DELETION = 368,
LOG_SKIP_REMOTE_CREATION = 346,
LOG_SKIP_REMOTE_MODIFICATION = 356,
LOG_SKIP_REMOTE_DELETION = 366,
LOG_SKIP_LOCAL_ATTACHMENT_CREATION = 349,
LOG_SKIP_LOCAL_ATTACHMENT_MODIFICATION = 359,
LOG_SKIP_LOCAL_ATTACHMENT_DELETION = 369,
LOG_SKIP_REMOTE_ATTACHMENT_CREATION = 347,
LOG_SKIP_REMOTE_ATTACHMENT_MODIFICATION = 357,
LOG_SKIP_REMOTE_ATTACHMENT_DELETION = 367,
LOG_SKIP_CONFLICT = 374,
LOG_SKIP_CONFLICT_ATTACHMENT = 375,
LOG_NO_CHANGE = 384,
LOG_NO_CHANGE_ATTACHMENT = 385;
function ReplicateReport(log_level, log_console) {
this._list = [];
this.name = 'ReplicateReport';
this.message = this.name;
this.has_error = false;
this._log_level = log_level;
this._log_console = log_console;
}
ReplicateReport.prototype = {
constructor: ReplicateReport,
LOG_UNEXPECTED_ERROR: LOG_UNEXPECTED_ERROR,
LOG_UNRESOLVED_CONFLICT: LOG_UNRESOLVED_CONFLICT,
LOG_UNEXPECTED_LOCAL_ATTACHMENT: LOG_UNEXPECTED_LOCAL_ATTACHMENT,
LOG_UNEXPECTED_REMOTE_ATTACHMENT: LOG_UNEXPECTED_REMOTE_ATTACHMENT,
LOG_UNRESOLVED_ATTACHMENT_CONFLICT: LOG_UNRESOLVED_ATTACHMENT_CONFLICT,
LOG_FORCE_PUT_REMOTE: LOG_FORCE_PUT_REMOTE,
LOG_FORCE_DELETE_REMOTE: LOG_FORCE_DELETE_REMOTE,
LOG_FORCE_PUT_LOCAL: LOG_FORCE_PUT_LOCAL,
LOG_FORCE_DELETE_LOCAL: LOG_FORCE_DELETE_LOCAL,
LOG_FORCE_PUT_REMOTE_ATTACHMENT: LOG_FORCE_PUT_REMOTE_ATTACHMENT,
LOG_FORCE_DELETE_REMOTE_ATTACHMENT: LOG_FORCE_DELETE_REMOTE_ATTACHMENT,
LOG_FORCE_PUT_LOCAL_ATTACHMENT: LOG_FORCE_PUT_LOCAL_ATTACHMENT,
LOG_FORCE_DELETE_LOCAL_ATTACHMENT: LOG_FORCE_DELETE_LOCAL_ATTACHMENT,
LOG_PUT_REMOTE: LOG_PUT_REMOTE,
LOG_POST_REMOTE: LOG_POST_REMOTE,
LOG_DELETE_REMOTE: LOG_DELETE_REMOTE,
LOG_PUT_REMOTE_ATTACHMENT: LOG_PUT_REMOTE_ATTACHMENT,
LOG_DELETE_REMOTE_ATTACHMENT: LOG_DELETE_REMOTE_ATTACHMENT,
LOG_PUT_LOCAL: LOG_PUT_LOCAL,
LOG_DELETE_LOCAL: LOG_DELETE_LOCAL,
LOG_PUT_LOCAL_ATTACHMENT: LOG_PUT_LOCAL_ATTACHMENT,
LOG_DELETE_LOCAL_ATTACHMENT: LOG_DELETE_LOCAL_ATTACHMENT,
LOG_FALSE_CONFLICT: LOG_FALSE_CONFLICT,
LOG_FALSE_CONFLICT_ATTACHMENT: LOG_FALSE_CONFLICT_ATTACHMENT,
LOG_SKIP_LOCAL_CREATION: LOG_SKIP_LOCAL_CREATION,
LOG_SKIP_LOCAL_MODIFICATION: LOG_SKIP_LOCAL_MODIFICATION,
LOG_SKIP_LOCAL_DELETION: LOG_SKIP_LOCAL_DELETION,
LOG_SKIP_REMOTE_CREATION: LOG_SKIP_REMOTE_CREATION,
LOG_SKIP_REMOTE_MODIFICATION: LOG_SKIP_REMOTE_MODIFICATION,
LOG_SKIP_REMOTE_DELETION: LOG_SKIP_REMOTE_DELETION,
LOG_SKIP_LOCAL_ATTACHMENT_CREATION: LOG_SKIP_LOCAL_ATTACHMENT_CREATION,
LOG_SKIP_LOCAL_ATTACHMENT_MODIFICATION:
LOG_SKIP_LOCAL_ATTACHMENT_MODIFICATION,
LOG_SKIP_LOCAL_ATTACHMENT_DELETION: LOG_SKIP_LOCAL_ATTACHMENT_DELETION,
LOG_SKIP_REMOTE_ATTACHMENT_CREATION: LOG_SKIP_REMOTE_ATTACHMENT_CREATION,
LOG_SKIP_REMOTE_ATTACHMENT_MODIFICATION:
LOG_SKIP_REMOTE_ATTACHMENT_MODIFICATION,
LOG_SKIP_REMOTE_ATTACHMENT_DELETION: LOG_SKIP_REMOTE_ATTACHMENT_DELETION,
LOG_SKIP_CONFLICT: LOG_SKIP_CONFLICT,
LOG_SKIP_CONFLICT_ATTACHMENT: LOG_SKIP_CONFLICT_ATTACHMENT,
LOG_NO_CHANGE: LOG_NO_CHANGE,
LOG_NO_CHANGE_ATTACHMENT: LOG_NO_CHANGE_ATTACHMENT,
logConsole: function (code, a, b, c) {
if (!this._log_console) {
return;
}
var txt = code,
parsed_code = code,
log;
// Check severity level
if (parsed_code >= 300) {
txt += ' SKIP ';
log = console.info;
} else if (parsed_code >= 200) {
txt += ' SOLVE ';
log = console.log;
} else if (parsed_code >= 100) {
txt += ' FORCE ';
log = console.warn;
} else {
txt += ' ERROR ';
log = console.error;
}
// Check operation
parsed_code = code % 100;
if (parsed_code >= 80) {
txt += 'idem ';
} else if (parsed_code >= 70) {
txt += 'conflict ';
} else if (parsed_code >= 60) {
txt += 'deleted ';
} else if (parsed_code >= 50) {
txt += 'modified ';
} else if (parsed_code >= 40) {
txt += 'created ';
} else if (parsed_code >= 30) {
txt += 'delete ';
} else if (parsed_code >= 20) {
txt += 'post ';
} else if (parsed_code >= 10) {
txt += 'put ';
}
// Check document
parsed_code = code % 10;
if (parsed_code >= 8) {
txt += 'local ';
} else if (parsed_code >= 6) {
txt += 'remote ';
}
if (parsed_code !== 0) {
txt += (parsed_code % 2 === 0) ? 'document' : 'attachment';
}
txt += ' ' + a;
if (b !== undefined) {
txt += ' ' + b;
if (c !== undefined) {
txt += ' ' + c;
}
}
log(txt);
},
log: function (id, type, extra) {
if (type === undefined) {
if (extra === undefined) {
extra = 'Unknown type: ' + type;
}
type = LOG_UNEXPECTED_ERROR;
}
if (type < this._log_level) {
if (extra === undefined) {
this.logConsole(type, id);
this._list.push([type, id]);
} else {
this.logConsole(type, id, extra);
this._list.push([type, id, extra]);
}
if (type < 100) {
this.has_error = true;
}
}
},
logAttachment: function (id, name, type, extra) {
if (type === undefined) {
if (extra === undefined) {
extra = 'Unknown type: ' + type;
}
type = LOG_UNEXPECTED_ERROR;
}
if (type < this._log_level) {
if (extra === undefined) {
this.logConsole(type, id, name);
this._list.push([type, id, name]);
} else {
this.logConsole(type, id, name, extra);
this._list.push([type, id, name, extra]);
}
if (type < 100) {
this.has_error = true;
}
}
},
toString: function () {
return this._list.toString();
}
};
function SkipError(message) { function SkipError(message) {
if ((message !== undefined) && (typeof message !== "string")) { if ((message !== undefined) && (typeof message !== "string")) {
...@@ -58,6 +269,8 @@ ...@@ -58,6 +269,8 @@
function ReplicateStorage(spec) { function ReplicateStorage(spec) {
this._query_options = spec.query || {}; this._query_options = spec.query || {};
this._log_level = spec.report_level || 100;
this._log_console = spec.debug || false;
if (spec.signature_hash_key !== undefined) { if (spec.signature_hash_key !== undefined) {
this._query_options.select_list = [spec.signature_hash_key]; this._query_options.select_list = [spec.signature_hash_key];
} }
...@@ -277,7 +490,16 @@ ...@@ -277,7 +490,16 @@
function propagateAttachmentDeletion(context, function propagateAttachmentDeletion(context,
destination, destination,
id, name) { id, name,
conflict, from_local, report) {
if (conflict) {
report.logAttachment(id, name, from_local ?
LOG_FORCE_DELETE_REMOTE_ATTACHMENT :
LOG_FORCE_DELETE_LOCAL_ATTACHMENT);
} else {
report.logAttachment(id, name, from_local ? LOG_DELETE_REMOTE_ATTACHMENT :
LOG_DELETE_LOCAL_ATTACHMENT);
}
return destination.removeAttachment(id, name) return destination.removeAttachment(id, name)
.push(function () { .push(function () {
return context._signature_sub_storage.removeAttachment(id, name); return context._signature_sub_storage.removeAttachment(id, name);
...@@ -286,7 +508,16 @@ ...@@ -286,7 +508,16 @@
function propagateAttachmentModification(context, function propagateAttachmentModification(context,
destination, destination,
blob, hash, id, name) { blob, hash, id, name,
from_local, is_conflict, report) {
if (is_conflict) {
report.logAttachment(id, name, from_local ?
LOG_FORCE_PUT_REMOTE_ATTACHMENT :
LOG_FORCE_PUT_LOCAL_ATTACHMENT);
} else {
report.logAttachment(id, name, from_local ? LOG_PUT_REMOTE_ATTACHMENT :
LOG_PUT_LOCAL_ATTACHMENT);
}
return destination.putAttachment(id, name, blob) return destination.putAttachment(id, name, blob)
.push(function () { .push(function () {
return context._signature_sub_storage.putAttachment(id, name, return context._signature_sub_storage.putAttachment(id, name,
...@@ -301,7 +532,7 @@ ...@@ -301,7 +532,7 @@
status_hash, local_hash, blob, status_hash, local_hash, blob,
source, destination, id, name, source, destination, id, name,
conflict_force, conflict_revert, conflict_force, conflict_revert,
conflict_ignore) { conflict_ignore, from_local, report) {
// No need to check twice // No need to check twice
skip_attachment_dict[name] = null; skip_attachment_dict[name] = null;
var remote_blob; var remote_blob;
...@@ -325,6 +556,7 @@ ...@@ -325,6 +556,7 @@
.push(function (remote_hash) { .push(function (remote_hash) {
if (local_hash === remote_hash) { if (local_hash === remote_hash) {
// Same modifications on both side // Same modifications on both side
report.logAttachment(id, name, LOG_FALSE_CONFLICT_ATTACHMENT);
if (local_hash === null) { if (local_hash === null) {
// Deleted on both side, drop signature // Deleted on both side, drop signature
return context._signature_sub_storage.removeAttachment(id, name); return context._signature_sub_storage.removeAttachment(id, name);
...@@ -342,15 +574,21 @@ ...@@ -342,15 +574,21 @@
// Deleted locally // Deleted locally
return propagateAttachmentDeletion(context, return propagateAttachmentDeletion(context,
destination, destination,
id, name); id, name,
(remote_hash !== status_hash),
from_local, report);
} }
return propagateAttachmentModification(context, return propagateAttachmentModification(context,
destination, blob, destination, blob,
local_hash, id, name); local_hash, id, name,
from_local,
(remote_hash !== status_hash),
report);
} }
// Conflict cases // Conflict cases
if (conflict_ignore === true) { if (conflict_ignore === true) {
report.logAttachment(id, name, LOG_SKIP_CONFLICT_ATTACHMENT);
return; return;
} }
...@@ -359,7 +597,9 @@ ...@@ -359,7 +597,9 @@
if (remote_hash === null) { if (remote_hash === null) {
// Deleted remotely // Deleted remotely
return propagateAttachmentDeletion(context, return propagateAttachmentDeletion(context,
source, id, name); source, id, name,
(local_hash !== status_hash),
!from_local, report);
} }
return propagateAttachmentModification( return propagateAttachmentModification(
context, context,
...@@ -367,7 +607,10 @@ ...@@ -367,7 +607,10 @@
remote_blob, remote_blob,
remote_hash, remote_hash,
id, id,
name name,
!from_local,
(local_hash !== status_hash),
report
); );
} }
...@@ -376,12 +619,14 @@ ...@@ -376,12 +619,14 @@
// Copy remote modification remotely // Copy remote modification remotely
return propagateAttachmentModification(context, return propagateAttachmentModification(context,
destination, blob, destination, blob,
local_hash, id, name); local_hash, id, name, from_local,
false,
report);
} }
throw new jIO.util.jIOError("Conflict on '" + id + report.logAttachment(id, name, LOG_UNRESOLVED_ATTACHMENT_CONFLICT);
"' with attachment '" + })
name + "'", .push(undefined, function (error) {
409); report.logAttachment(id, name, LOG_UNEXPECTED_ERROR, error);
}); });
} }
...@@ -392,7 +637,9 @@ ...@@ -392,7 +637,9 @@
conflict_force, conflict_force,
conflict_revert, conflict_revert,
conflict_ignore, conflict_ignore,
is_creation, is_modification) { is_creation, is_modification,
from_local,
report) {
var blob, var blob,
status_hash; status_hash;
queue queue
...@@ -427,14 +674,20 @@ ...@@ -427,14 +674,20 @@
var array_buffer = evt.target.result, var array_buffer = evt.target.result,
local_hash = generateHashFromArrayBuffer(array_buffer); local_hash = generateHashFromArrayBuffer(array_buffer);
if (local_hash !== status_hash) { if (local_hash === status_hash) {
return checkAndPropagateAttachment(context, if (!from_local) {
skip_attachment_dict, report.logAttachment(id, name, LOG_NO_CHANGE_ATTACHMENT);
status_hash, local_hash, blob, }
source, destination, id, name, return;
conflict_force, conflict_revert,
conflict_ignore);
} }
return checkAndPropagateAttachment(context,
skip_attachment_dict,
status_hash, local_hash, blob,
source, destination, id, name,
conflict_force, conflict_revert,
conflict_ignore,
from_local,
report);
}); });
} }
...@@ -442,7 +695,7 @@ ...@@ -442,7 +695,7 @@
skip_attachment_dict, skip_attachment_dict,
destination, id, name, source, destination, id, name, source,
conflict_force, conflict_revert, conflict_force, conflict_revert,
conflict_ignore) { conflict_ignore, from_local, report) {
var status_hash; var status_hash;
queue queue
.push(function () { .push(function () {
...@@ -456,16 +709,17 @@ ...@@ -456,16 +709,17 @@
status_hash, null, null, status_hash, null, null,
source, destination, id, name, source, destination, id, name,
conflict_force, conflict_revert, conflict_force, conflict_revert,
conflict_ignore); conflict_ignore, from_local, report);
}); });
} }
function pushDocumentAttachment(context, function pushDocumentAttachment(context,
skip_attachment_dict, id, source, skip_attachment_dict, id, source,
destination, signature_allAttachments, destination, signature_allAttachments,
options) { report, options) {
var local_dict = {}, var local_dict = {},
signature_dict = {}; signature_dict = {},
from_local = options.from_local;
return source.allAttachments(id) return source.allAttachments(id)
.push(undefined, function (error) { .push(undefined, function (error) {
if ((error instanceof jIO.util.jIOError) && if ((error instanceof jIO.util.jIOError) &&
...@@ -510,7 +764,19 @@ ...@@ -510,7 +764,19 @@
options.conflict_revert, options.conflict_revert,
options.conflict_ignore, options.conflict_ignore,
is_creation, is_creation,
is_modification]); is_modification,
from_local,
report]);
} else {
if (signature_dict.hasOwnProperty(key)) {
report.logAttachment(id, key, from_local ?
LOG_SKIP_LOCAL_ATTACHMENT_MODIFICATION :
LOG_SKIP_REMOTE_ATTACHMENT_MODIFICATION);
} else {
report.logAttachment(id, key, from_local ?
LOG_SKIP_LOCAL_ATTACHMENT_CREATION :
LOG_SKIP_REMOTE_ATTACHMENT_CREATION);
}
} }
} }
} }
...@@ -523,10 +789,10 @@ ...@@ -523,10 +789,10 @@
}) })
.push(function () { .push(function () {
var key, argument_list = []; var key, argument_list = [];
if (options.check_deletion === true) { for (key in signature_dict) {
for (key in signature_dict) { if (signature_dict.hasOwnProperty(key)) {
if (signature_dict.hasOwnProperty(key)) { if (!local_dict.hasOwnProperty(key)) {
if (!local_dict.hasOwnProperty(key)) { if (options.check_deletion === true) {
argument_list.push([undefined, argument_list.push([undefined,
context, context,
skip_attachment_dict, skip_attachment_dict,
...@@ -534,29 +800,51 @@ ...@@ -534,29 +800,51 @@
source, source,
options.conflict_force, options.conflict_force,
options.conflict_revert, options.conflict_revert,
options.conflict_ignore]); options.conflict_ignore,
from_local,
report]);
} else {
report.logAttachment(id, key, from_local ?
LOG_SKIP_LOCAL_ATTACHMENT_DELETION :
LOG_SKIP_REMOTE_ATTACHMENT_DELETION);
} }
} }
} }
return dispatchQueue(
context,
checkAttachmentLocalDeletion,
argument_list,
context._parallel_operation_attachment_amount
);
} }
return dispatchQueue(
context,
checkAttachmentLocalDeletion,
argument_list,
context._parallel_operation_attachment_amount
);
}); });
} }
function propagateFastAttachmentDeletion(queue, id, name, storage) { function propagateFastAttachmentDeletion(queue, id, name, storage, signature,
from_local, report) {
report.logAttachment(id, name, from_local ? LOG_DELETE_REMOTE_ATTACHMENT :
LOG_DELETE_LOCAL_ATTACHMENT);
return queue return queue
.push(function () { .push(function () {
return storage.removeAttachment(id, name); return storage.removeAttachment(id, name);
})
.push(function () {
return signature.removeAttachment(id, name);
});
}
function propagateFastSignatureDeletion(queue, id, name, signature,
report) {
report.logAttachment(id, name, LOG_FALSE_CONFLICT_ATTACHMENT);
return queue
.push(function () {
return signature.removeAttachment(id, name);
}); });
} }
function propagateFastAttachmentModification(queue, id, key, source, function propagateFastAttachmentModification(queue, id, key, source,
destination, signature, hash) { destination, signature, hash,
from_local, report) {
return queue return queue
.push(function () { .push(function () {
return signature.getAttachment(id, key, {format: 'json'}) return signature.getAttachment(id, key, {format: 'json'})
...@@ -569,6 +857,9 @@ ...@@ -569,6 +857,9 @@
}) })
.push(function (result) { .push(function (result) {
if (result.hash !== hash) { if (result.hash !== hash) {
report.logAttachment(id, key, from_local ?
LOG_PUT_REMOTE_ATTACHMENT :
LOG_PUT_LOCAL_ATTACHMENT);
return source.getAttachment(id, key) return source.getAttachment(id, key)
.push(function (blob) { .push(function (blob) {
return destination.putAttachment(id, key, blob); return destination.putAttachment(id, key, blob);
...@@ -587,7 +878,8 @@ ...@@ -587,7 +878,8 @@
function repairFastDocumentAttachment(context, id, function repairFastDocumentAttachment(context, id,
signature_hash, signature_hash,
signature_attachment_hash, signature_attachment_hash,
signature_from_local) { signature_from_local,
report) {
if (signature_hash === signature_attachment_hash) { if (signature_hash === signature_attachment_hash) {
// No replication to do // No replication to do
return; return;
...@@ -608,6 +900,7 @@ ...@@ -608,6 +900,7 @@
destination, destination,
push_argument_list = [], push_argument_list = [],
delete_argument_list = [], delete_argument_list = [],
delete_signature_argument_list = [],
signature_attachment_dict = result_list[0], signature_attachment_dict = result_list[0],
local_attachment_dict = result_list[1], local_attachment_dict = result_list[1],
remote_attachment_list = result_list[2], remote_attachment_list = result_list[2],
...@@ -618,13 +911,15 @@ ...@@ -618,13 +911,15 @@
check_remote_modification = check_remote_modification =
context._check_remote_attachment_modification, context._check_remote_attachment_modification,
check_remote_creation = context._check_remote_attachment_creation, check_remote_creation = context._check_remote_attachment_creation,
check_remote_deletion = context._check_remote_attachment_deletion; check_remote_deletion = context._check_remote_attachment_deletion,
from_local;
if (signature_from_local) { if (signature_from_local) {
source_attachment_dict = local_attachment_dict; source_attachment_dict = local_attachment_dict;
destination_attachment_dict = remote_attachment_list; destination_attachment_dict = remote_attachment_list;
source = context._local_sub_storage; source = context._local_sub_storage;
destination = context._remote_sub_storage; destination = context._remote_sub_storage;
from_local = true;
} else { } else {
source_attachment_dict = remote_attachment_list; source_attachment_dict = remote_attachment_list;
destination_attachment_dict = local_attachment_dict; destination_attachment_dict = local_attachment_dict;
...@@ -635,6 +930,7 @@ ...@@ -635,6 +930,7 @@
check_local_deletion = check_remote_deletion; check_local_deletion = check_remote_deletion;
check_remote_creation = check_local_creation; check_remote_creation = check_local_creation;
check_remote_deletion = check_local_deletion; check_remote_deletion = check_local_deletion;
from_local = false;
} }
// Push all source attachments // Push all source attachments
...@@ -652,8 +948,20 @@ ...@@ -652,8 +948,20 @@
source, source,
destination, destination,
context._signature_sub_storage, context._signature_sub_storage,
signature_hash signature_hash,
from_local,
report
]); ]);
} else {
if (signature_attachment_dict.hasOwnProperty(key)) {
report.logAttachment(id, key, from_local ?
LOG_SKIP_LOCAL_ATTACHMENT_MODIFICATION :
LOG_SKIP_REMOTE_ATTACHMENT_MODIFICATION);
} else {
report.logAttachment(id, key, from_local ?
LOG_SKIP_LOCAL_ATTACHMENT_CREATION :
LOG_SKIP_REMOTE_ATTACHMENT_CREATION);
}
} }
} }
} }
...@@ -662,16 +970,19 @@ ...@@ -662,16 +970,19 @@
for (key in signature_attachment_dict) { for (key in signature_attachment_dict) {
if (signature_attachment_dict.hasOwnProperty(key)) { if (signature_attachment_dict.hasOwnProperty(key)) {
if (check_local_deletion && if (check_local_deletion &&
!source_attachment_dict.hasOwnProperty(key)) { !source_attachment_dict.hasOwnProperty(key) &&
delete_argument_list.push([ !destination_attachment_dict.hasOwnProperty(key)) {
delete_signature_argument_list.push([
undefined, undefined,
id, id,
key, key,
context._signature_sub_storage context._signature_sub_storage,
report
]); ]);
} }
} }
} }
for (key in destination_attachment_dict) { for (key in destination_attachment_dict) {
if (destination_attachment_dict.hasOwnProperty(key)) { if (destination_attachment_dict.hasOwnProperty(key)) {
if (!source_attachment_dict.hasOwnProperty(key)) { if (!source_attachment_dict.hasOwnProperty(key)) {
...@@ -683,8 +994,21 @@ ...@@ -683,8 +994,21 @@
undefined, undefined,
id, id,
key, key,
destination destination,
context._signature_sub_storage,
from_local,
report
]); ]);
} else {
if (signature_attachment_dict.hasOwnProperty(key)) {
report.logAttachment(id, key, from_local ?
LOG_SKIP_LOCAL_ATTACHMENT_DELETION :
LOG_SKIP_REMOTE_ATTACHMENT_DELETION);
} else {
report.logAttachment(id, key, from_local ?
LOG_SKIP_LOCAL_ATTACHMENT_CREATION :
LOG_SKIP_REMOTE_ATTACHMENT_CREATION);
}
} }
} }
} }
...@@ -702,6 +1026,12 @@ ...@@ -702,6 +1026,12 @@
propagateFastAttachmentDeletion, propagateFastAttachmentDeletion,
delete_argument_list, delete_argument_list,
context._parallel_operation_attachment_amount context._parallel_operation_attachment_amount
),
dispatchQueue(
context,
propagateFastSignatureDeletion,
delete_signature_argument_list,
context._parallel_operation_attachment_amount
) )
]); ]);
}) })
...@@ -715,7 +1045,7 @@ ...@@ -715,7 +1045,7 @@
}); });
} }
function repairDocumentAttachment(context, id, signature_hash_key, function repairDocumentAttachment(context, id, report, signature_hash_key,
signature_hash, signature_hash,
signature_attachment_hash, signature_attachment_hash,
signature_from_local) { signature_from_local) {
...@@ -723,7 +1053,7 @@ ...@@ -723,7 +1053,7 @@
return repairFastDocumentAttachment(context, id, return repairFastDocumentAttachment(context, id,
signature_hash, signature_hash,
signature_attachment_hash, signature_attachment_hash,
signature_from_local); signature_from_local, report);
} }
var skip_attachment_dict = {}; var skip_attachment_dict = {};
...@@ -757,6 +1087,7 @@ ...@@ -757,6 +1087,7 @@
context._local_sub_storage, context._local_sub_storage,
context._remote_sub_storage, context._remote_sub_storage,
signature_allAttachments, signature_allAttachments,
report,
{ {
conflict_force: (context._conflict_handling === conflict_force: (context._conflict_handling ===
CONFLICT_KEEP_LOCAL), CONFLICT_KEEP_LOCAL),
...@@ -767,7 +1098,8 @@ ...@@ -767,7 +1098,8 @@
check_modification: check_modification:
context._check_local_attachment_modification, context._check_local_attachment_modification,
check_creation: context._check_local_attachment_creation, check_creation: context._check_local_attachment_creation,
check_deletion: context._check_local_attachment_deletion check_deletion: context._check_local_attachment_deletion,
from_local: true
} }
) )
.push(function () { .push(function () {
...@@ -787,6 +1119,7 @@ ...@@ -787,6 +1119,7 @@
context._remote_sub_storage, context._remote_sub_storage,
context._local_sub_storage, context._local_sub_storage,
signature_allAttachments, signature_allAttachments,
report,
{ {
use_revert_post: context._use_remote_post, use_revert_post: context._use_remote_post,
conflict_force: (context._conflict_handling === conflict_force: (context._conflict_handling ===
...@@ -798,7 +1131,8 @@ ...@@ -798,7 +1131,8 @@
check_modification: check_modification:
context._check_remote_attachment_modification, context._check_remote_attachment_modification,
check_creation: context._check_remote_attachment_creation, check_creation: context._check_remote_attachment_creation,
check_deletion: context._check_remote_attachment_deletion check_deletion: context._check_remote_attachment_deletion,
from_local: false
} }
); );
} }
...@@ -808,14 +1142,17 @@ ...@@ -808,14 +1142,17 @@
function propagateModification(context, source, destination, doc, hash, id, function propagateModification(context, source, destination, doc, hash, id,
skip_document_dict, skip_document_dict,
skip_deleted_document_dict, skip_deleted_document_dict,
report,
options) { options) {
var result = new RSVP.Queue(), var result = new RSVP.Queue(),
post_id, post_id,
from_local; from_local,
conflict;
if (options === undefined) { if (options === undefined) {
options = {}; options = {};
} }
from_local = options.from_local; from_local = options.from_local;
conflict = options.conflict || false;
if (doc === null) { if (doc === null) {
result result
...@@ -835,6 +1172,7 @@ ...@@ -835,6 +1172,7 @@
if (options.use_post) { if (options.use_post) {
result result
.push(function () { .push(function () {
report.log(id, from_local ? LOG_POST_REMOTE : LOG_POST_LOCAL);
return destination.post(doc); return destination.post(doc);
}) })
.push(function (new_id) { .push(function (new_id) {
...@@ -886,6 +1224,12 @@ ...@@ -886,6 +1224,12 @@
} else { } else {
result result
.push(function () { .push(function () {
if (conflict) {
report.log(id, from_local ? LOG_FORCE_PUT_REMOTE :
LOG_FORCE_PUT_LOCAL);
} else {
report.log(id, from_local ? LOG_PUT_REMOTE : LOG_PUT_LOCAL);
}
// Drop signature if the destination document was empty // Drop signature if the destination document was empty
// but a signature exists // but a signature exists
if (options.create_new_document === true) { if (options.create_new_document === true) {
...@@ -913,29 +1257,45 @@ ...@@ -913,29 +1257,45 @@
} }
function propagateDeletion(context, destination, id, function propagateDeletion(context, destination, id,
skip_deleted_document_dict) { skip_deleted_document_dict, report, options) {
// Do not delete a document if it has an attachment // Do not delete a document if it has an attachment
// ie, replication should prevent losing user data // ie, replication should prevent losing user data
// Synchronize attachments before, to ensure // Synchronize attachments before, to ensure
// all of them will be deleted too // all of them will be deleted too
var result; var result;
if (context._signature_hash_key !== undefined) { if (context._signature_hash_key !== undefined) {
if (options.conflict) {
report.log(id, options.from_local ? LOG_FORCE_DELETE_REMOTE :
LOG_FORCE_DELETE_LOCAL);
} else {
report.log(id, options.from_local ? LOG_DELETE_REMOTE :
LOG_DELETE_LOCAL);
}
result = destination.remove(id) result = destination.remove(id)
.push(function () { .push(function () {
return context._signature_sub_storage.remove(id); return context._signature_sub_storage.remove(id);
}); });
} else { } else {
result = repairDocumentAttachment(context, id) result = repairDocumentAttachment(context, id, report)
.push(function () { .push(function () {
return destination.allAttachments(id); return destination.allAttachments(id);
}) })
.push(function (attachment_dict) { .push(function (attachment_dict) {
if (JSON.stringify(attachment_dict) === "{}") { if (JSON.stringify(attachment_dict) === "{}") {
if (options.conflict) {
report.log(id, options.from_local ? LOG_FORCE_DELETE_REMOTE :
LOG_FORCE_DELETE_LOCAL);
} else {
report.log(id, options.from_local ? LOG_DELETE_REMOTE :
LOG_DELETE_LOCAL);
}
return destination.remove(id) return destination.remove(id)
.push(function () { .push(function () {
return context._signature_sub_storage.remove(id); return context._signature_sub_storage.remove(id);
}); });
} }
report.log(id, options.from_local ? LOG_UNEXPECTED_REMOTE_ATTACHMENT :
LOG_UNEXPECTED_LOCAL_ATTACHMENT);
}, function (error) { }, function (error) {
if ((error instanceof jIO.util.jIOError) && if ((error instanceof jIO.util.jIOError) &&
(error.status_code === 404)) { (error.status_code === 404)) {
...@@ -958,6 +1318,7 @@ ...@@ -958,6 +1318,7 @@
source, destination, id, source, destination, id,
conflict_force, conflict_revert, conflict_force, conflict_revert,
conflict_ignore, conflict_ignore,
report,
options) { options) {
// No need to check twice // No need to check twice
skip_document_dict[id] = null; skip_document_dict[id] = null;
...@@ -991,6 +1352,7 @@ ...@@ -991,6 +1352,7 @@
remote_hash = remote_list[1]; remote_hash = remote_list[1];
if (local_hash === remote_hash) { if (local_hash === remote_hash) {
// Same modifications on both side // Same modifications on both side
report.log(id, LOG_FALSE_CONFLICT);
if (local_hash === null) { if (local_hash === null) {
// Deleted on both side, drop signature // Deleted on both side, drop signature
return context._signature_sub_storage.remove(id); return context._signature_sub_storage.remove(id);
...@@ -1007,13 +1369,19 @@ ...@@ -1007,13 +1369,19 @@
if (local_hash === null) { if (local_hash === null) {
// Deleted locally // Deleted locally
return propagateDeletion(context, destination, id, return propagateDeletion(context, destination, id,
skip_deleted_document_dict); skip_deleted_document_dict,
report,
{from_local: from_local,
conflict: (remote_hash !== status_hash)
});
} }
return propagateModification(context, source, destination, doc, return propagateModification(context, source, destination, doc,
local_hash, id, skip_document_dict, local_hash, id, skip_document_dict,
skip_deleted_document_dict, skip_deleted_document_dict,
report,
{use_post: ((options.use_post) && {use_post: ((options.use_post) &&
(remote_hash === null)), (remote_hash === null)),
conflict: (remote_hash !== status_hash),
from_local: from_local, from_local: from_local,
create_new_document: create_new_document:
((remote_hash === null) && ((remote_hash === null) &&
...@@ -1023,6 +1391,7 @@ ...@@ -1023,6 +1391,7 @@
// Conflict cases // Conflict cases
if (conflict_ignore === true) { if (conflict_ignore === true) {
report.log(id, LOG_SKIP_CONFLICT);
return; return;
} }
...@@ -1031,7 +1400,10 @@ ...@@ -1031,7 +1400,10 @@
if (remote_hash === null) { if (remote_hash === null) {
// Deleted remotely // Deleted remotely
return propagateDeletion(context, source, id, return propagateDeletion(context, source, id,
skip_deleted_document_dict); skip_deleted_document_dict, report,
{from_local: !from_local,
conflict: (local_hash !== null)
});
} }
return propagateModification( return propagateModification(
context, context,
...@@ -1042,9 +1414,11 @@ ...@@ -1042,9 +1414,11 @@
id, id,
skip_document_dict, skip_document_dict,
skip_deleted_document_dict, skip_deleted_document_dict,
report,
{use_post: ((options.use_revert_post) && {use_post: ((options.use_revert_post) &&
(local_hash === null)), (local_hash === null)),
from_local: !from_local, from_local: !from_local,
conflict: true,
create_new_document: ((local_hash === null) && create_new_document: ((local_hash === null) &&
(status_hash !== null))} (status_hash !== null))}
); );
...@@ -1056,17 +1430,17 @@ ...@@ -1056,17 +1430,17 @@
return propagateModification(context, source, destination, doc, return propagateModification(context, source, destination, doc,
local_hash, id, skip_document_dict, local_hash, id, skip_document_dict,
skip_deleted_document_dict, skip_deleted_document_dict,
report,
{use_post: options.use_post, {use_post: options.use_post,
conflict: true,
from_local: from_local, from_local: from_local,
create_new_document: create_new_document:
(status_hash !== null)}); (status_hash !== null)});
} }
doc = doc || local_hash; report.log(id, LOG_UNRESOLVED_CONFLICT);
remote_doc = remote_doc || remote_hash; })
throw new jIO.util.jIOError("Conflict on '" + id + "': " + .push(undefined, function (error) {
stringify(doc) + " !== " + report.log(id, LOG_UNEXPECTED_ERROR, error);
stringify(remote_doc),
409);
}); });
} }
...@@ -1075,7 +1449,7 @@ ...@@ -1075,7 +1449,7 @@
cache, destination_key, cache, destination_key,
destination, id, source, destination, id, source,
conflict_force, conflict_revert, conflict_force, conflict_revert,
conflict_ignore, options) { conflict_ignore, report, options) {
var status_hash; var status_hash;
queue queue
.push(function () { .push(function () {
...@@ -1089,7 +1463,7 @@ ...@@ -1089,7 +1463,7 @@
status_hash, null, null, status_hash, null, null,
source, destination, id, source, destination, id,
conflict_force, conflict_revert, conflict_force, conflict_revert,
conflict_ignore, conflict_ignore, report,
options); options);
}); });
} }
...@@ -1100,7 +1474,7 @@ ...@@ -1100,7 +1474,7 @@
source, destination, id, source, destination, id,
conflict_force, conflict_revert, conflict_force, conflict_revert,
conflict_ignore, conflict_ignore,
local_hash, status_hash, local_hash, status_hash, report,
options) { options) {
queue queue
.push(function () { .push(function () {
...@@ -1124,8 +1498,12 @@ ...@@ -1124,8 +1498,12 @@
source, destination, id, source, destination, id,
conflict_force, conflict_revert, conflict_force, conflict_revert,
conflict_ignore, conflict_ignore,
report,
options); options);
} }
if (!options.from_local) {
report.log(id, LOG_NO_CHANGE);
}
}); });
} }
...@@ -1133,7 +1511,7 @@ ...@@ -1133,7 +1511,7 @@
skip_deleted_document_dict, skip_deleted_document_dict,
cache, source_key, destination_key, cache, source_key, destination_key,
source, destination, signature_allDocs, source, destination, signature_allDocs,
options) { report, options) {
var argument_list = [], var argument_list = [],
argument_list_deletion = []; argument_list_deletion = [];
if (!options.hasOwnProperty("use_post")) { if (!options.hasOwnProperty("use_post")) {
...@@ -1214,7 +1592,19 @@ ...@@ -1214,7 +1592,19 @@
options.conflict_revert, options.conflict_revert,
options.conflict_ignore, options.conflict_ignore,
local_hash, status_hash, local_hash, status_hash,
report,
options]); options]);
} else if (local_hash === status_hash) {
report.log(key, LOG_NO_CHANGE);
} else {
if (signature_dict.hasOwnProperty(key)) {
report.log(key, options.from_local ?
LOG_SKIP_LOCAL_MODIFICATION :
LOG_SKIP_REMOTE_MODIFICATION);
} else {
report.log(key, options.from_local ? LOG_SKIP_LOCAL_CREATION :
LOG_SKIP_REMOTE_CREATION);
}
} }
} }
} }
...@@ -1241,8 +1631,11 @@ ...@@ -1241,8 +1631,11 @@
options.conflict_force, options.conflict_force,
options.conflict_revert, options.conflict_revert,
options.conflict_ignore, options.conflict_ignore,
report,
options]); options]);
} else { } else {
report.log(key, options.from_local ? LOG_SKIP_LOCAL_DELETION :
LOG_SKIP_REMOTE_DELETION);
skip_deleted_document_dict[key] = null; skip_deleted_document_dict[key] = null;
} }
} }
...@@ -1262,11 +1655,11 @@ ...@@ -1262,11 +1655,11 @@
}); });
} }
function repairDocument(queue, context, id, signature_hash_key, function repairDocument(queue, context, id, report, signature_hash_key,
signature_hash, signature_attachment_hash, signature_hash, signature_attachment_hash,
signature_from_local) { signature_from_local) {
queue.push(function () { queue.push(function () {
return repairDocumentAttachment(context, id, signature_hash_key, return repairDocumentAttachment(context, id, report, signature_hash_key,
signature_hash, signature_hash,
signature_attachment_hash, signature_attachment_hash,
signature_from_local); signature_from_local);
...@@ -1278,7 +1671,8 @@ ...@@ -1278,7 +1671,8 @@
argument_list = arguments, argument_list = arguments,
skip_document_dict = {}, skip_document_dict = {},
skip_deleted_document_dict = {}, skip_deleted_document_dict = {},
cache = {}; cache = {},
report = new ReplicateReport(this._log_level, this._log_console);
return new RSVP.Queue() return new RSVP.Queue()
.push(function () { .push(function () {
...@@ -1345,7 +1739,7 @@ ...@@ -1345,7 +1739,7 @@
cache, 'local', 'remote', cache, 'local', 'remote',
context._local_sub_storage, context._local_sub_storage,
context._remote_sub_storage, context._remote_sub_storage,
signature_allDocs, signature_allDocs, report,
{ {
use_post: context._use_remote_post, use_post: context._use_remote_post,
conflict_force: (context._conflict_handling === conflict_force: (context._conflict_handling ===
...@@ -1376,7 +1770,8 @@ ...@@ -1376,7 +1770,8 @@
cache, 'remote', 'local', cache, 'remote', 'local',
context._remote_sub_storage, context._remote_sub_storage,
context._local_sub_storage, context._local_sub_storage,
signature_allDocs, { signature_allDocs,
report, {
use_revert_post: context._use_remote_post, use_revert_post: context._use_remote_post,
conflict_force: (context._conflict_handling === conflict_force: (context._conflict_handling ===
CONFLICT_KEEP_REMOTE), CONFLICT_KEEP_REMOTE),
...@@ -1417,9 +1812,10 @@ ...@@ -1417,9 +1812,10 @@
// is deleted but not pushed to the other storage // is deleted but not pushed to the other storage
if (!skip_deleted_document_dict.hasOwnProperty(row.id)) { if (!skip_deleted_document_dict.hasOwnProperty(row.id)) {
local_argument_list.push( local_argument_list.push(
[undefined, context, row.id, context._signature_hash_key, [undefined, context, row.id, report,
context._signature_hash_key,
row.value.hash, row.value.attachment_hash, row.value.hash, row.value.attachment_hash,
row.value.from_local] row.value.from_local, report]
); );
} }
} }
...@@ -1431,6 +1827,12 @@ ...@@ -1431,6 +1827,12 @@
); );
}); });
} }
})
.push(function () {
if (report.has_error) {
throw report;
}
return report;
}); });
}; };
......
...@@ -100,6 +100,7 @@ ...@@ -100,6 +100,7 @@
// Uses memory substorage, so that it is flushed after each run // Uses memory substorage, so that it is flushed after each run
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
...@@ -136,7 +137,7 @@ ...@@ -136,7 +137,7 @@
test("local document creation", function () { test("local document creation", function () {
stop(); stop();
expect(2); expect(3);
var id, var id,
context = this; context = this;
...@@ -146,7 +147,10 @@ ...@@ -146,7 +147,10 @@
id = result; id = result;
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_PUT_REMOTE, id]
]);
return context.jio.__storage._remote_sub_storage.get(id); return context.jio.__storage._remote_sub_storage.get(id);
}) })
.then(function (result) { .then(function (result) {
...@@ -174,7 +178,7 @@ ...@@ -174,7 +178,7 @@
test("local document creation and use remote post", function () { test("local document creation and use remote post", function () {
stop(); stop();
expect(13); expect(14);
var id, var id,
post_id, post_id,
...@@ -183,6 +187,7 @@ ...@@ -183,6 +187,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
use_remote_post: true, use_remote_post: true,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
local_sub_storage: { local_sub_storage: {
...@@ -220,7 +225,10 @@ ...@@ -220,7 +225,10 @@
return context.jio.repair(); return context.jio.repair();
}) })
// Document 'id' has been deleted in both storages // Document 'id' has been deleted in both storages
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_POST_REMOTE, id]
]);
return context.jio.__storage._remote_sub_storage.get(id); return context.jio.__storage._remote_sub_storage.get(id);
}) })
.fail(function (error) { .fail(function (error) {
...@@ -294,7 +302,7 @@ ...@@ -294,7 +302,7 @@
test("local document creation, remote post and delayed allDocs", function () { test("local document creation, remote post and delayed allDocs", function () {
stop(); stop();
expect(11); expect(12);
var id, var id,
post_id = "_foobar", post_id = "_foobar",
...@@ -325,6 +333,7 @@ ...@@ -325,6 +333,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
use_remote_post: true, use_remote_post: true,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
local_sub_storage: { local_sub_storage: {
...@@ -359,7 +368,10 @@ ...@@ -359,7 +368,10 @@
return context.jio.repair(); return context.jio.repair();
}) })
// Document 'id' has been deleted in both storages // Document 'id' has been deleted in both storages
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_POST_REMOTE, id]
]);
return context.jio.__storage._remote_sub_storage.get(id); return context.jio.__storage._remote_sub_storage.get(id);
}) })
.fail(function (error) { .fail(function (error) {
...@@ -421,7 +433,7 @@ ...@@ -421,7 +433,7 @@
test("remote document creation", function () { test("remote document creation", function () {
stop(); stop();
expect(2); expect(3);
var id, var id,
context = this; context = this;
...@@ -432,7 +444,10 @@ ...@@ -432,7 +444,10 @@
id = result; id = result;
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_PUT_LOCAL, id]
]);
return context.jio.get(id); return context.jio.get(id);
}) })
.then(function (result) { .then(function (result) {
...@@ -460,7 +475,7 @@ ...@@ -460,7 +475,7 @@
test("local and remote document creations", function () { test("local and remote document creations", function () {
stop(); stop();
expect(5); expect(3);
var context = this; var context = this;
...@@ -476,11 +491,10 @@ ...@@ -476,11 +491,10 @@
.then(function () { .then(function () {
ok(false); ok(false);
}) })
.fail(function (error) { .fail(function (report) {
ok(error instanceof jIO.util.jIOError); deepEqual(report._list, [
equal(error.message, "Conflict on 'conflict': " + [report.LOG_UNRESOLVED_CONFLICT, 'conflict']
"\"foo dynetag\" !== \"bar dynetag\""); ]);
equal(error.status_code, 409);
}) })
.then(function () { .then(function () {
return context.jio.__storage._signature_sub_storage.get("conflict"); return context.jio.__storage._signature_sub_storage.get("conflict");
...@@ -498,7 +512,7 @@ ...@@ -498,7 +512,7 @@
test("local and remote document creations with same 'etag'", function () { test("local and remote document creations with same 'etag'", function () {
stop(); stop();
expect(3); expect(4);
var context = this; var context = this;
...@@ -511,7 +525,10 @@ ...@@ -511,7 +525,10 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_FALSE_CONFLICT, 'conflict']
]);
return context.jio.__storage._signature_sub_storage.get("conflict"); return context.jio.__storage._signature_sub_storage.get("conflict");
}) })
.then(function (result) { .then(function (result) {
...@@ -549,12 +566,13 @@ ...@@ -549,12 +566,13 @@
test("local and remote document creations: keep local", function () { test("local and remote document creations: keep local", function () {
stop(); stop();
expect(3); expect(4);
var context = this; var context = this;
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
local_sub_storage: { local_sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect",
...@@ -586,7 +604,10 @@ ...@@ -586,7 +604,10 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_FORCE_PUT_REMOTE, 'conflict']
]);
return context.jio.__storage._signature_sub_storage.get("conflict"); return context.jio.__storage._signature_sub_storage.get("conflict");
}) })
.then(function (result) { .then(function (result) {
...@@ -624,12 +645,13 @@ ...@@ -624,12 +645,13 @@
test("local and remote document creations: keep local, remote post", test("local and remote document creations: keep local, remote post",
function () { function () {
stop(); stop();
expect(3); expect(4);
var context = this; var context = this;
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
use_remote_post: 1, use_remote_post: 1,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
local_sub_storage: { local_sub_storage: {
...@@ -662,7 +684,10 @@ ...@@ -662,7 +684,10 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_FORCE_PUT_REMOTE, 'conflict']
]);
return context.jio.__storage._signature_sub_storage.get("conflict"); return context.jio.__storage._signature_sub_storage.get("conflict");
}) })
.then(function (result) { .then(function (result) {
...@@ -700,12 +725,13 @@ ...@@ -700,12 +725,13 @@
test("local and remote document creations: keep local, " + test("local and remote document creations: keep local, " +
"local not matching query", function () { "local not matching query", function () {
stop(); stop();
expect(3); expect(4);
var context = this; var context = this;
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
local_sub_storage: { local_sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect",
...@@ -740,7 +766,10 @@ ...@@ -740,7 +766,10 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_FORCE_PUT_REMOTE, 'conflict']
]);
return context.jio.__storage._signature_sub_storage.get("conflict"); return context.jio.__storage._signature_sub_storage.get("conflict");
}) })
.then(function (result) { .then(function (result) {
...@@ -778,12 +807,13 @@ ...@@ -778,12 +807,13 @@
test("local and remote document creations: keep local, " + test("local and remote document creations: keep local, " +
"remote not matching query", function () { "remote not matching query", function () {
stop(); stop();
expect(3); expect(4);
var context = this; var context = this;
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
local_sub_storage: { local_sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect",
...@@ -817,7 +847,10 @@ ...@@ -817,7 +847,10 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_FORCE_PUT_REMOTE, 'conflict']
]);
return context.jio.__storage._signature_sub_storage.get("conflict"); return context.jio.__storage._signature_sub_storage.get("conflict");
}) })
.then(function (result) { .then(function (result) {
...@@ -856,12 +889,13 @@ ...@@ -856,12 +889,13 @@
test("local and remote document creations: keep remote", function () { test("local and remote document creations: keep remote", function () {
stop(); stop();
expect(3); expect(4);
var context = this; var context = this;
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
local_sub_storage: { local_sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect",
...@@ -893,7 +927,10 @@ ...@@ -893,7 +927,10 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_FORCE_PUT_LOCAL, 'conflict']
]);
return context.jio.__storage._signature_sub_storage.get("conflict"); return context.jio.__storage._signature_sub_storage.get("conflict");
}) })
.then(function (result) { .then(function (result) {
...@@ -931,12 +968,13 @@ ...@@ -931,12 +968,13 @@
test("local and remote document creations: keep remote, remote post", test("local and remote document creations: keep remote, remote post",
function () { function () {
stop(); stop();
expect(3); expect(4);
var context = this; var context = this;
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
use_remote_post: 1, use_remote_post: 1,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
local_sub_storage: { local_sub_storage: {
...@@ -969,7 +1007,10 @@ ...@@ -969,7 +1007,10 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_FORCE_PUT_LOCAL, 'conflict']
]);
return context.jio.__storage._signature_sub_storage.get("conflict"); return context.jio.__storage._signature_sub_storage.get("conflict");
}) })
.then(function (result) { .then(function (result) {
...@@ -1007,12 +1048,13 @@ ...@@ -1007,12 +1048,13 @@
test("local and remote document creations: keep remote, " + test("local and remote document creations: keep remote, " +
"local not matching query", function () { "local not matching query", function () {
stop(); stop();
expect(3); expect(4);
var context = this; var context = this;
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
local_sub_storage: { local_sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect",
...@@ -1046,7 +1088,10 @@ ...@@ -1046,7 +1088,10 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_FORCE_PUT_LOCAL, 'conflict']
]);
return context.jio.__storage._signature_sub_storage.get("conflict"); return context.jio.__storage._signature_sub_storage.get("conflict");
}) })
.then(function (result) { .then(function (result) {
...@@ -1086,12 +1131,13 @@ ...@@ -1086,12 +1131,13 @@
test("local and remote document creations: keep remote, " + test("local and remote document creations: keep remote, " +
"remote not matching query", function () { "remote not matching query", function () {
stop(); stop();
expect(3); expect(4);
var context = this; var context = this;
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
local_sub_storage: { local_sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect",
...@@ -1125,7 +1171,10 @@ ...@@ -1125,7 +1171,10 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_FORCE_PUT_LOCAL, 'conflict']
]);
return context.jio.__storage._signature_sub_storage.get("conflict"); return context.jio.__storage._signature_sub_storage.get("conflict");
}) })
.then(function (result) { .then(function (result) {
...@@ -1162,12 +1211,13 @@ ...@@ -1162,12 +1211,13 @@
test("local and remote document creations: continue", function () { test("local and remote document creations: continue", function () {
stop(); stop();
expect(4); expect(5);
var context = this; var context = this;
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
local_sub_storage: { local_sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect",
...@@ -1199,7 +1249,10 @@ ...@@ -1199,7 +1249,10 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_SKIP_CONFLICT, 'conflict']
]);
return context.jio.__storage._signature_sub_storage.get("conflict"); return context.jio.__storage._signature_sub_storage.get("conflict");
}) })
.fail(function (error) { .fail(function (error) {
...@@ -1236,12 +1289,13 @@ ...@@ -1236,12 +1289,13 @@
test("local and remote document creations: continue, remote post", test("local and remote document creations: continue, remote post",
function () { function () {
stop(); stop();
expect(4); expect(5);
var context = this; var context = this;
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
use_remote_post: 1, use_remote_post: 1,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
local_sub_storage: { local_sub_storage: {
...@@ -1274,7 +1328,10 @@ ...@@ -1274,7 +1328,10 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_SKIP_CONFLICT, 'conflict']
]);
return context.jio.__storage._signature_sub_storage.get("conflict"); return context.jio.__storage._signature_sub_storage.get("conflict");
}) })
.fail(function (error) { .fail(function (error) {
...@@ -1310,7 +1367,7 @@ ...@@ -1310,7 +1367,7 @@
test("local and remote same document creations", function () { test("local and remote same document creations", function () {
stop(); stop();
expect(1); expect(2);
var context = this; var context = this;
...@@ -1323,7 +1380,10 @@ ...@@ -1323,7 +1380,10 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_FALSE_CONFLICT, 'conflict']
]);
return context.jio.__storage._signature_sub_storage.get("conflict"); return context.jio.__storage._signature_sub_storage.get("conflict");
}) })
.then(function (result) { .then(function (result) {
...@@ -1342,7 +1402,7 @@ ...@@ -1342,7 +1402,7 @@
test("no modification", function () { test("no modification", function () {
stop(); stop();
expect(2); expect(3);
var id, var id,
context = this; context = this;
...@@ -1355,7 +1415,11 @@ ...@@ -1355,7 +1415,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_NO_CHANGE, id],
[report.LOG_NO_CHANGE, id]
]);
return context.jio.__storage._remote_sub_storage.get(id); return context.jio.__storage._remote_sub_storage.get(id);
}) })
.then(function (result) { .then(function (result) {
...@@ -1383,7 +1447,7 @@ ...@@ -1383,7 +1447,7 @@
test("local document modification", function () { test("local document modification", function () {
stop(); stop();
expect(2); expect(3);
var id, var id,
context = this; context = this;
...@@ -1399,7 +1463,10 @@ ...@@ -1399,7 +1463,10 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_PUT_REMOTE, id]
]);
return context.jio.__storage._remote_sub_storage.get(id); return context.jio.__storage._remote_sub_storage.get(id);
}) })
.then(function (result) { .then(function (result) {
...@@ -1428,13 +1495,14 @@ ...@@ -1428,13 +1495,14 @@
test("local document modification: use remote post", function () { test("local document modification: use remote post", function () {
stop(); stop();
expect(2); expect(3);
var id, var id,
context = this; context = this;
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
use_remote_post: 1, use_remote_post: 1,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
local_sub_storage: { local_sub_storage: {
...@@ -1475,7 +1543,10 @@ ...@@ -1475,7 +1543,10 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_PUT_REMOTE, id]
]);
return context.jio.__storage._remote_sub_storage.get(id); return context.jio.__storage._remote_sub_storage.get(id);
}) })
.then(function (result) { .then(function (result) {
...@@ -1503,13 +1574,14 @@ ...@@ -1503,13 +1574,14 @@
test("local document modification not checked", function () { test("local document modification not checked", function () {
stop(); stop();
expect(3); expect(4);
var id, var id,
context = this; context = this;
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
check_local_modification: false, check_local_modification: false,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
local_sub_storage: { local_sub_storage: {
...@@ -1549,7 +1621,11 @@ ...@@ -1549,7 +1621,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_SKIP_LOCAL_MODIFICATION, id],
[report.LOG_NO_CHANGE, id]
]);
return context.jio.get(id); return context.jio.get(id);
}) })
.then(function (result) { .then(function (result) {
...@@ -1586,7 +1662,7 @@ ...@@ -1586,7 +1662,7 @@
test("remote document modification", function () { test("remote document modification", function () {
stop(); stop();
expect(2); expect(3);
var id, var id,
context = this; context = this;
...@@ -1605,7 +1681,11 @@ ...@@ -1605,7 +1681,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_NO_CHANGE, id],
[report.LOG_PUT_LOCAL, id]
]);
return context.jio.get(id); return context.jio.get(id);
}) })
.then(function (result) { .then(function (result) {
...@@ -1633,13 +1713,14 @@ ...@@ -1633,13 +1713,14 @@
test("remote document modification not checked", function () { test("remote document modification not checked", function () {
stop(); stop();
expect(3); expect(4);
var id, var id,
context = this; context = this;
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
check_remote_modification: false, check_remote_modification: false,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
local_sub_storage: { local_sub_storage: {
...@@ -1682,7 +1763,11 @@ ...@@ -1682,7 +1763,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_NO_CHANGE, id],
[report.LOG_SKIP_REMOTE_MODIFICATION, id]
]);
return context.jio.__storage._remote_sub_storage.get(id); return context.jio.__storage._remote_sub_storage.get(id);
}) })
.then(function (result) { .then(function (result) {
...@@ -1719,7 +1804,7 @@ ...@@ -1719,7 +1804,7 @@
test("local and remote document modifications", function () { test("local and remote document modifications", function () {
stop(); stop();
expect(4); expect(2);
var id, var id,
context = this; context = this;
...@@ -1747,11 +1832,10 @@ ...@@ -1747,11 +1832,10 @@
.then(function () { .then(function () {
ok(false); ok(false);
}) })
.fail(function (error) { .fail(function (report) {
ok(error instanceof jIO.util.jIOError); deepEqual(report._list, [
equal(error.message, "Conflict on '" + id + "': " + [report.LOG_UNRESOLVED_CONFLICT, id]
"\"foo4 dynetag\" !== \"foo5 dynetag\""); ]);
equal(error.status_code, 409);
}) })
.then(function () { .then(function () {
return context.jio.__storage._signature_sub_storage.get(id); return context.jio.__storage._signature_sub_storage.get(id);
...@@ -1769,13 +1853,14 @@ ...@@ -1769,13 +1853,14 @@
test("local and remote document modifications: keep local", function () { test("local and remote document modifications: keep local", function () {
stop(); stop();
expect(3); expect(4);
var id, var id,
context = this; context = this;
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
...@@ -1824,7 +1909,10 @@ ...@@ -1824,7 +1909,10 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_FORCE_PUT_REMOTE, id]
]);
return context.jio.__storage._signature_sub_storage.get(id); return context.jio.__storage._signature_sub_storage.get(id);
}) })
.then(function (result) { .then(function (result) {
...@@ -1861,13 +1949,14 @@ ...@@ -1861,13 +1949,14 @@
test("local and remote document modifications: keep remote", function () { test("local and remote document modifications: keep remote", function () {
stop(); stop();
expect(3); expect(4);
var id, var id,
context = this; context = this;
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
...@@ -1916,7 +2005,10 @@ ...@@ -1916,7 +2005,10 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_FORCE_PUT_LOCAL, id]
]);
return context.jio.__storage._signature_sub_storage.get(id); return context.jio.__storage._signature_sub_storage.get(id);
}) })
.then(function (result) { .then(function (result) {
...@@ -1953,13 +2045,14 @@ ...@@ -1953,13 +2045,14 @@
test("local and remote document modifications: continue", function () { test("local and remote document modifications: continue", function () {
stop(); stop();
expect(3); expect(4);
var id, var id,
context = this; context = this;
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
...@@ -2008,7 +2101,10 @@ ...@@ -2008,7 +2101,10 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_SKIP_CONFLICT, id]
]);
return context.jio.__storage._signature_sub_storage.get(id); return context.jio.__storage._signature_sub_storage.get(id);
}) })
.then(function (result) { .then(function (result) {
...@@ -2045,7 +2141,7 @@ ...@@ -2045,7 +2141,7 @@
test("local and remote document same modifications", function () { test("local and remote document same modifications", function () {
stop(); stop();
expect(1); expect(2);
var id, var id,
context = this; context = this;
...@@ -2070,7 +2166,10 @@ ...@@ -2070,7 +2166,10 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_FALSE_CONFLICT, id]
]);
return context.jio.__storage._signature_sub_storage.get(id); return context.jio.__storage._signature_sub_storage.get(id);
}) })
.then(function (result) { .then(function (result) {
...@@ -2089,7 +2188,7 @@ ...@@ -2089,7 +2188,7 @@
test("local document deletion", function () { test("local document deletion", function () {
stop(); stop();
expect(6); expect(7);
var id, var id,
context = this; context = this;
...@@ -2105,7 +2204,10 @@ ...@@ -2105,7 +2204,10 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_DELETE_REMOTE, id]
]);
ok(true, "Removal correctly synced"); ok(true, "Removal correctly synced");
}) })
.then(function () { .then(function () {
...@@ -2134,13 +2236,14 @@ ...@@ -2134,13 +2236,14 @@
test("local document deletion not checked", function () { test("local document deletion not checked", function () {
stop(); stop();
expect(6); expect(7);
var id, var id,
context = this; context = this;
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
check_local_deletion: false, check_local_deletion: false,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
local_sub_storage: { local_sub_storage: {
...@@ -2180,7 +2283,11 @@ ...@@ -2180,7 +2283,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_SKIP_LOCAL_DELETION, id],
[report.LOG_NO_CHANGE, id]
]);
ok(true, "Removal correctly synced"); ok(true, "Removal correctly synced");
}) })
.then(function () { .then(function () {
...@@ -2216,7 +2323,7 @@ ...@@ -2216,7 +2323,7 @@
test("local document deletion with attachment", function () { test("local document deletion with attachment", function () {
stop(); stop();
expect(10); expect(11);
var id, var id,
context = this, context = this,
...@@ -2237,7 +2344,10 @@ ...@@ -2237,7 +2344,10 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_DELETE_REMOTE, id]
]);
ok(true, "Removal correctly synced"); ok(true, "Removal correctly synced");
}) })
.then(function () { .then(function () {
...@@ -2279,7 +2389,7 @@ ...@@ -2279,7 +2389,7 @@
test("remote document deletion", function () { test("remote document deletion", function () {
stop(); stop();
expect(6); expect(7);
var id, var id,
context = this; context = this;
...@@ -2295,7 +2405,11 @@ ...@@ -2295,7 +2405,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_NO_CHANGE, id],
[report.LOG_DELETE_LOCAL, id]
]);
ok(true, "Removal correctly synced"); ok(true, "Removal correctly synced");
}) })
.then(function () { .then(function () {
...@@ -2324,13 +2438,14 @@ ...@@ -2324,13 +2438,14 @@
test("remote document deletion not checked", function () { test("remote document deletion not checked", function () {
stop(); stop();
expect(6); expect(7);
var id, var id,
context = this; context = this;
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
check_remote_deletion: false, check_remote_deletion: false,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
local_sub_storage: { local_sub_storage: {
...@@ -2370,7 +2485,11 @@ ...@@ -2370,7 +2485,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_NO_CHANGE, id],
[report.LOG_SKIP_REMOTE_DELETION, id]
]);
ok(true, "Removal correctly synced"); ok(true, "Removal correctly synced");
}) })
.then(function () { .then(function () {
...@@ -2406,7 +2525,7 @@ ...@@ -2406,7 +2525,7 @@
test("remote document deletion with attachment", function () { test("remote document deletion with attachment", function () {
stop(); stop();
expect(10); expect(11);
var id, var id,
context = this, context = this,
...@@ -2426,7 +2545,11 @@ ...@@ -2426,7 +2545,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_NO_CHANGE, id],
[report.LOG_DELETE_LOCAL, id]
]);
ok(true, "Removal correctly synced"); ok(true, "Removal correctly synced");
}) })
.then(function () { .then(function () {
...@@ -2468,7 +2591,7 @@ ...@@ -2468,7 +2591,7 @@
test("local and remote document deletions", function () { test("local and remote document deletions", function () {
stop(); stop();
expect(8); expect(9);
var id, var id,
context = this; context = this;
...@@ -2487,7 +2610,10 @@ ...@@ -2487,7 +2610,10 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_FALSE_CONFLICT, id]
]);
return context.jio.get(id) return context.jio.get(id)
.then(function () { .then(function () {
ok(false, "Document should be locally deleted"); ok(false, "Document should be locally deleted");
...@@ -2530,7 +2656,7 @@ ...@@ -2530,7 +2656,7 @@
test("local deletion and remote modifications", function () { test("local deletion and remote modifications", function () {
stop(); stop();
expect(2); expect(3);
var id, var id,
context = this; context = this;
...@@ -2555,7 +2681,10 @@ ...@@ -2555,7 +2681,10 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_FORCE_PUT_LOCAL, id]
]);
return context.jio.get(id); return context.jio.get(id);
}) })
.then(function (result) { .then(function (result) {
...@@ -2583,13 +2712,14 @@ ...@@ -2583,13 +2712,14 @@
test("local deletion and remote modifications: keep local", function () { test("local deletion and remote modifications: keep local", function () {
stop(); stop();
expect(9); expect(10);
var id, var id,
context = this; context = this;
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
conflict_handling: 1, conflict_handling: 1,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
local_sub_storage: { local_sub_storage: {
...@@ -2638,7 +2768,10 @@ ...@@ -2638,7 +2768,10 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_FORCE_DELETE_REMOTE, id]
]);
return context.jio.get(id); return context.jio.get(id);
}) })
.fail(function (error) { .fail(function (error) {
...@@ -2680,13 +2813,14 @@ ...@@ -2680,13 +2813,14 @@
test("local deletion and remote modifications: keep remote", function () { test("local deletion and remote modifications: keep remote", function () {
stop(); stop();
expect(3); expect(4);
var id, var id,
context = this; context = this;
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
conflict_handling: 2, conflict_handling: 2,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
local_sub_storage: { local_sub_storage: {
...@@ -2735,7 +2869,10 @@ ...@@ -2735,7 +2869,10 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_FORCE_PUT_LOCAL, id]
]);
return context.jio.get(id); return context.jio.get(id);
}) })
.then(function (result) { .then(function (result) {
...@@ -2772,13 +2909,14 @@ ...@@ -2772,13 +2909,14 @@
test("local deletion and remote modifications: ignore", function () { test("local deletion and remote modifications: ignore", function () {
stop(); stop();
expect(5); expect(6);
var id, var id,
context = this; context = this;
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
conflict_handling: 3, conflict_handling: 3,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
local_sub_storage: { local_sub_storage: {
...@@ -2827,7 +2965,10 @@ ...@@ -2827,7 +2965,10 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_SKIP_CONFLICT, id]
]);
return context.jio.get(id); return context.jio.get(id);
}) })
.fail(function (error) { .fail(function (error) {
...@@ -2863,7 +3004,7 @@ ...@@ -2863,7 +3004,7 @@
test("local modifications and remote deletion", function () { test("local modifications and remote deletion", function () {
stop(); stop();
expect(2); expect(3);
var id, var id,
context = this; context = this;
...@@ -2882,7 +3023,10 @@ ...@@ -2882,7 +3023,10 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_FORCE_PUT_REMOTE, id]
]);
return context.jio.__storage._remote_sub_storage.get(id); return context.jio.__storage._remote_sub_storage.get(id);
}) })
.then(function (result) { .then(function (result) {
...@@ -2910,7 +3054,7 @@ ...@@ -2910,7 +3054,7 @@
test("local modifications and remote deletion: use remote post", function () { test("local modifications and remote deletion: use remote post", function () {
stop(); stop();
expect(13); expect(14);
var id, var id,
context = this, context = this,
...@@ -2918,6 +3062,7 @@ ...@@ -2918,6 +3062,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
use_remote_post: true, use_remote_post: true,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
local_sub_storage: { local_sub_storage: {
...@@ -2962,7 +3107,10 @@ ...@@ -2962,7 +3107,10 @@
return context.jio.repair(); return context.jio.repair();
}) })
// Old id deleted // Old id deleted
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_POST_REMOTE, id]
]);
return context.jio.get(id); return context.jio.get(id);
}) })
.fail(function (error) { .fail(function (error) {
...@@ -3037,7 +3185,7 @@ ...@@ -3037,7 +3185,7 @@
test("local modif, remote del: remote post, no check loc mod", function () { test("local modif, remote del: remote post, no check loc mod", function () {
stop(); stop();
expect(13); expect(14);
var id, var id,
context = this, context = this,
...@@ -3045,6 +3193,7 @@ ...@@ -3045,6 +3193,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
use_remote_post: true, use_remote_post: true,
check_local_modification: false, check_local_modification: false,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
...@@ -3090,7 +3239,11 @@ ...@@ -3090,7 +3239,11 @@
return context.jio.repair(); return context.jio.repair();
}) })
// Old id deleted // Old id deleted
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_SKIP_LOCAL_MODIFICATION, id],
[report.LOG_POST_REMOTE, id]
]);
return context.jio.get(id); return context.jio.get(id);
}) })
.fail(function (error) { .fail(function (error) {
...@@ -3165,13 +3318,14 @@ ...@@ -3165,13 +3318,14 @@
test("local modifications and remote deletion: keep local", function () { test("local modifications and remote deletion: keep local", function () {
stop(); stop();
expect(3); expect(4);
var id, var id,
context = this; context = this;
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
conflict_handling: 1, conflict_handling: 1,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
local_sub_storage: { local_sub_storage: {
...@@ -3215,7 +3369,10 @@ ...@@ -3215,7 +3369,10 @@
return context.jio.repair(); return context.jio.repair();
}) })
// Old id deleted // Old id deleted
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_FORCE_PUT_REMOTE, id]
]);
return context.jio.get(id); return context.jio.get(id);
}) })
.then(function (result) { .then(function (result) {
...@@ -3252,7 +3409,7 @@ ...@@ -3252,7 +3409,7 @@
test("local modif and remote del: keep local, use remote post", function () { test("local modif and remote del: keep local, use remote post", function () {
stop(); stop();
expect(13); expect(14);
var id, var id,
context = this, context = this,
...@@ -3260,6 +3417,7 @@ ...@@ -3260,6 +3417,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
conflict_handling: 1, conflict_handling: 1,
use_remote_post: true, use_remote_post: true,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
...@@ -3305,7 +3463,10 @@ ...@@ -3305,7 +3463,10 @@
return context.jio.repair(); return context.jio.repair();
}) })
// Old id deleted // Old id deleted
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_POST_REMOTE, id]
]);
return context.jio.get(id); return context.jio.get(id);
}) })
.fail(function (error) { .fail(function (error) {
...@@ -3380,13 +3541,14 @@ ...@@ -3380,13 +3541,14 @@
test("local modifications and remote deletion: keep remote", function () { test("local modifications and remote deletion: keep remote", function () {
stop(); stop();
expect(9); expect(10);
var id, var id,
context = this; context = this;
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
conflict_handling: 2, conflict_handling: 2,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
local_sub_storage: { local_sub_storage: {
...@@ -3430,7 +3592,10 @@ ...@@ -3430,7 +3592,10 @@
return context.jio.repair(); return context.jio.repair();
}) })
// id deleted // id deleted
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_FORCE_DELETE_LOCAL, id]
]);
return context.jio.get(id); return context.jio.get(id);
}) })
.fail(function (error) { .fail(function (error) {
...@@ -3472,13 +3637,14 @@ ...@@ -3472,13 +3637,14 @@
test("local modif and remote del: keep remote, not check modif", function () { test("local modif and remote del: keep remote, not check modif", function () {
stop(); stop();
expect(9); expect(10);
var id, var id,
context = this; context = this;
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
conflict_handling: 2, conflict_handling: 2,
check_local_modification: false, check_local_modification: false,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
...@@ -3523,7 +3689,11 @@ ...@@ -3523,7 +3689,11 @@
return context.jio.repair(); return context.jio.repair();
}) })
// id deleted // id deleted
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_SKIP_LOCAL_MODIFICATION, id],
[report.LOG_FORCE_DELETE_LOCAL, id]
]);
return context.jio.get(id); return context.jio.get(id);
}) })
.fail(function (error) { .fail(function (error) {
...@@ -3565,13 +3735,14 @@ ...@@ -3565,13 +3735,14 @@
test("local modifications and remote deletion: ignore", function () { test("local modifications and remote deletion: ignore", function () {
stop(); stop();
expect(5); expect(6);
var id, var id,
context = this; context = this;
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
conflict_handling: 3, conflict_handling: 3,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
local_sub_storage: { local_sub_storage: {
...@@ -3615,7 +3786,10 @@ ...@@ -3615,7 +3786,10 @@
return context.jio.repair(); return context.jio.repair();
}) })
// id deleted // id deleted
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_SKIP_CONFLICT, id]
]);
return context.jio.get(id); return context.jio.get(id);
}) })
.then(function (result) { .then(function (result) {
...@@ -3659,6 +3833,7 @@ ...@@ -3659,6 +3833,7 @@
// in the same local sub storage // in the same local sub storage
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
...@@ -3759,6 +3934,7 @@ ...@@ -3759,6 +3934,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
local_sub_storage: { local_sub_storage: {
type: "replicatefaststorage200defaultquery" type: "replicatefaststorage200defaultquery"
...@@ -3815,6 +3991,7 @@ ...@@ -3815,6 +3991,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
local_sub_storage: { local_sub_storage: {
type: "replicatefaststorage200customquery" type: "replicatefaststorage200customquery"
...@@ -3864,6 +4041,7 @@ ...@@ -3864,6 +4041,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
local_sub_storage: { local_sub_storage: {
type: "query", type: "query",
......
...@@ -69,6 +69,65 @@ ...@@ -69,6 +69,65 @@
return (name !== 'bulk_get'); return (name !== 'bulk_get');
}; };
/////////////////////////////////////////////////////////////////
// replicateStorage.repair fast use cases
/////////////////////////////////////////////////////////////////
function StorageAllDocsDynamicSelect(spec) {
this._sub_storage = jIO.createJIO(spec.sub_storage);
}
StorageAllDocsDynamicSelect.prototype.get = function () {
return this._sub_storage.get.apply(this._sub_storage, arguments);
};
StorageAllDocsDynamicSelect.prototype.post = function () {
return this._sub_storage.post.apply(this._sub_storage, arguments);
};
StorageAllDocsDynamicSelect.prototype.put = function () {
return this._sub_storage.put.apply(this._sub_storage, arguments);
};
StorageAllDocsDynamicSelect.prototype.remove = function () {
return this._sub_storage.remove.apply(this._sub_storage, arguments);
};
StorageAllDocsDynamicSelect.prototype.hasCapacity = function () {
return this._sub_storage.hasCapacity.apply(this._sub_storage, arguments);
};
StorageAllDocsDynamicSelect.prototype.buildQuery = function (options) {
var is_replicate_query = false;
if ((options.select_list !== undefined) &&
(options.select_list[0] === 'foo_etag')) {
options = {
select_list: ['foo_etag', 'title']
};
is_replicate_query = true;
}
return this._sub_storage.buildQuery(options)
.push(function (result) {
var i;
if (is_replicate_query === true) {
for (i = 0; i < result.length; i += 1) {
result[i].value.foo_etag = result[i].value.title + ' dynetag';
}
}
return result;
});
};
StorageAllDocsDynamicSelect.prototype.allAttachments = function () {
return this._sub_storage.allAttachments.apply(this._sub_storage, arguments);
};
StorageAllDocsDynamicSelect.prototype.putAttachment = function () {
return this._sub_storage.putAttachment.apply(this._sub_storage, arguments);
};
StorageAllDocsDynamicSelect.prototype.getAttachment = function () {
return this._sub_storage.getAttachment.apply(this._sub_storage, arguments);
};
StorageAllDocsDynamicSelect.prototype.removeAttachment = function () {
return this._sub_storage.removeAttachment.apply(this._sub_storage,
arguments);
};
jIO.addStorage(
'storagealldocsdynamicselect2',
StorageAllDocsDynamicSelect
);
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// attachment replication // attachment replication
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
...@@ -77,6 +136,7 @@ ...@@ -77,6 +136,7 @@
// Uses memory substorage, so that it is flushed after each run // Uses memory substorage, so that it is flushed after each run
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
check_local_attachment_creation: true, check_local_attachment_creation: true,
check_local_attachment_modification: true, check_local_attachment_modification: true,
...@@ -87,7 +147,7 @@ ...@@ -87,7 +147,7 @@
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect2",
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -99,7 +159,7 @@ ...@@ -99,7 +159,7 @@
remote_sub_storage: { remote_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect2",
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -114,7 +174,7 @@ ...@@ -114,7 +174,7 @@
test("local attachment creation", function () { test("local attachment creation", function () {
stop(); stop();
expect(3); expect(4);
var id, var id,
context = this, context = this,
...@@ -134,7 +194,11 @@ ...@@ -134,7 +194,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_PUT_REMOTE, id],
[report.LOG_PUT_REMOTE_ATTACHMENT, id, 'foo']
]);
return context.jio.__storage._remote_sub_storage.getAttachment( return context.jio.__storage._remote_sub_storage.getAttachment(
id, id,
"foo", "foo",
...@@ -170,7 +234,7 @@ ...@@ -170,7 +234,7 @@
test("local attachment creation, local document creation not checked", test("local attachment creation, local document creation not checked",
function () { function () {
stop(); stop();
expect(6); expect(7);
var id, var id,
context = this, context = this,
...@@ -178,13 +242,14 @@ ...@@ -178,13 +242,14 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
check_local_creation: false, check_local_creation: false,
check_local_attachment_creation: true, check_local_attachment_creation: true,
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect2",
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -196,7 +261,7 @@ ...@@ -196,7 +261,7 @@
remote_sub_storage: { remote_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect2",
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -220,7 +285,10 @@ ...@@ -220,7 +285,10 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_SKIP_LOCAL_CREATION, id]
]);
return context.jio.__storage._remote_sub_storage.getAttachment( return context.jio.__storage._remote_sub_storage.getAttachment(
id, id,
"foo", "foo",
...@@ -238,7 +306,7 @@ ...@@ -238,7 +306,7 @@
ok(error instanceof jIO.util.jIOError); ok(error instanceof jIO.util.jIOError);
equal(error.status_code, 404); equal(error.status_code, 404);
var error_message = "Cannot find attachment: " + var error_message = "Cannot find attachment: " +
"_replicate_ae15d2189153f083c0e4a845fd580b1d86f7a512 , " + "_replicate_200e37c2a642ca3b7445acb600508c785e85610e , " +
"jio_attachment/"; "jio_attachment/";
equal( equal(
error.message.substring(0, error_message.length), error.message.substring(0, error_message.length),
...@@ -255,7 +323,7 @@ ...@@ -255,7 +323,7 @@
test("local attachment creation not checked", function () { test("local attachment creation not checked", function () {
stop(); stop();
expect(6); expect(7);
var id, var id,
context = this, context = this,
...@@ -263,13 +331,14 @@ ...@@ -263,13 +331,14 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
check_local_attachment_creation: false, check_local_attachment_creation: false,
check_local_attachment_modification: true, check_local_attachment_modification: true,
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect2",
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -281,7 +350,7 @@ ...@@ -281,7 +350,7 @@
remote_sub_storage: { remote_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect2",
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -306,7 +375,11 @@ ...@@ -306,7 +375,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_PUT_REMOTE, id],
[report.LOG_SKIP_LOCAL_ATTACHMENT_CREATION, id, 'foo']
]);
return context.jio.__storage._remote_sub_storage.getAttachment( return context.jio.__storage._remote_sub_storage.getAttachment(
id, id,
"foo", "foo",
...@@ -324,7 +397,7 @@ ...@@ -324,7 +397,7 @@
ok(error instanceof jIO.util.jIOError); ok(error instanceof jIO.util.jIOError);
equal(error.status_code, 404); equal(error.status_code, 404);
var error_message = "Cannot find attachment: " + var error_message = "Cannot find attachment: " +
"_replicate_ae15d2189153f083c0e4a845fd580b1d86f7a512 , " + "_replicate_200e37c2a642ca3b7445acb600508c785e85610e , " +
"jio_attachment/"; "jio_attachment/";
equal( equal(
error.message.substring(0, error_message.length), error.message.substring(0, error_message.length),
...@@ -342,22 +415,24 @@ ...@@ -342,22 +415,24 @@
test("local attachment creation, local document creation and use remote post", test("local attachment creation, local document creation and use remote post",
function () { function () {
stop(); stop();
expect(4); expect(5);
var id, var id,
context = this, context = this,
post_id, post_id,
blob = new Blob([big_string]); blob = new Blob([big_string]),
report;
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
use_remote_post: true, use_remote_post: true,
check_local_attachment_creation: true, check_local_attachment_creation: true,
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect2",
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -369,7 +444,7 @@ ...@@ -369,7 +444,7 @@
remote_sub_storage: { remote_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect2",
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -389,12 +464,17 @@ ...@@ -389,12 +464,17 @@
return context.jio.repair(); return context.jio.repair();
}) })
// Another document should have been created // Another document should have been created
.then(function () { .then(function (result) {
report = result;
return context.jio.__storage._remote_sub_storage.allDocs(); return context.jio.__storage._remote_sub_storage.allDocs();
}) })
.then(function (result) { .then(function (result) {
equal(result.data.total_rows, 1); equal(result.data.total_rows, 1);
post_id = result.data.rows[0].id; post_id = result.data.rows[0].id;
deepEqual(report._list, [
[report.LOG_POST_REMOTE, id],
[report.LOG_PUT_REMOTE_ATTACHMENT, post_id, 'foo']
]);
return context.jio.getAttachment( return context.jio.getAttachment(
post_id, post_id,
"foo", "foo",
...@@ -429,7 +509,7 @@ ...@@ -429,7 +509,7 @@
test("remote attachment creation", function () { test("remote attachment creation", function () {
stop(); stop();
expect(2); expect(3);
var id, var id,
context = this, context = this,
...@@ -457,7 +537,12 @@ ...@@ -457,7 +537,12 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_NO_CHANGE, id],
[report.LOG_PUT_LOCAL, id],
[report.LOG_PUT_LOCAL_ATTACHMENT, id, 'foo']
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"foo", "foo",
...@@ -485,7 +570,7 @@ ...@@ -485,7 +570,7 @@
test("remote attachment creation, remote document creation not checked", test("remote attachment creation, remote document creation not checked",
function () { function () {
stop(); stop();
expect(6); expect(7);
var id, var id,
context = this, context = this,
...@@ -493,13 +578,14 @@ ...@@ -493,13 +578,14 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
check_remote_creation: false, check_remote_creation: false,
check_local_attachment_creation: true, check_local_attachment_creation: true,
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect2",
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -511,7 +597,7 @@ ...@@ -511,7 +597,7 @@
remote_sub_storage: { remote_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect2",
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -544,7 +630,10 @@ ...@@ -544,7 +630,10 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_SKIP_REMOTE_CREATION, id]
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"foo", "foo",
...@@ -562,7 +651,7 @@ ...@@ -562,7 +651,7 @@
ok(error instanceof jIO.util.jIOError); ok(error instanceof jIO.util.jIOError);
equal(error.status_code, 404); equal(error.status_code, 404);
var error_message = "Cannot find attachment: " + var error_message = "Cannot find attachment: " +
"_replicate_ae15d2189153f083c0e4a845fd580b1d86f7a512 , " + "_replicate_200e37c2a642ca3b7445acb600508c785e85610e , " +
"jio_attachment/"; "jio_attachment/";
equal( equal(
error.message.substring(0, error_message.length), error.message.substring(0, error_message.length),
...@@ -579,7 +668,7 @@ ...@@ -579,7 +668,7 @@
test("remote attachment creation not checked", function () { test("remote attachment creation not checked", function () {
stop(); stop();
expect(6); expect(7);
var id, var id,
context = this, context = this,
...@@ -587,12 +676,14 @@ ...@@ -587,12 +676,14 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
check_remote_attachment_creation: false, check_remote_attachment_creation: false,
check_remote_attachment_modification: true,
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect2",
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -604,7 +695,7 @@ ...@@ -604,7 +695,7 @@
remote_sub_storage: { remote_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect2",
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -637,7 +728,12 @@ ...@@ -637,7 +728,12 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_NO_CHANGE, id],
[report.LOG_PUT_LOCAL, id],
[report.LOG_SKIP_REMOTE_ATTACHMENT_CREATION, id, 'foo']
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"foo", "foo",
...@@ -655,7 +751,7 @@ ...@@ -655,7 +751,7 @@
ok(error instanceof jIO.util.jIOError); ok(error instanceof jIO.util.jIOError);
equal(error.status_code, 404); equal(error.status_code, 404);
var error_message = "Cannot find attachment: " + var error_message = "Cannot find attachment: " +
"_replicate_ae15d2189153f083c0e4a845fd580b1d86f7a512 , " + "_replicate_200e37c2a642ca3b7445acb600508c785e85610e , " +
"jio_attachment/"; "jio_attachment/";
equal( equal(
error.message.substring(0, error_message.length), error.message.substring(0, error_message.length),
...@@ -672,7 +768,7 @@ ...@@ -672,7 +768,7 @@
test("local and remote attachment creations", function () { test("local and remote attachment creations", function () {
stop(); stop();
expect(2); expect(3);
var context = this, var context = this,
id = 'foobar', id = 'foobar',
blob = new Blob(["a"]), blob = new Blob(["a"]),
...@@ -701,7 +797,11 @@ ...@@ -701,7 +797,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_FALSE_CONFLICT, id],
[report.LOG_PUT_REMOTE_ATTACHMENT, id, 'conflict']
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"conflict", "conflict",
...@@ -728,7 +828,7 @@ ...@@ -728,7 +828,7 @@
test("local and remote attachment creations: keep local", function () { test("local and remote attachment creations: keep local", function () {
stop(); stop();
expect(3); expect(4);
var context = this, var context = this,
id = 'foobar', id = 'foobar',
...@@ -737,6 +837,7 @@ ...@@ -737,6 +837,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
conflict_handling: 1, conflict_handling: 1,
check_local_attachment_creation: true, check_local_attachment_creation: true,
...@@ -744,7 +845,7 @@ ...@@ -744,7 +845,7 @@
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect2",
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -756,7 +857,7 @@ ...@@ -756,7 +857,7 @@
remote_sub_storage: { remote_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect2",
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -790,7 +891,11 @@ ...@@ -790,7 +891,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_FALSE_CONFLICT, id],
[report.LOG_PUT_REMOTE_ATTACHMENT, id, 'conflict']
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"conflict", "conflict",
...@@ -826,7 +931,7 @@ ...@@ -826,7 +931,7 @@
test("local and remote attachment creations: keep local, " + test("local and remote attachment creations: keep local, " +
"local not matching allAttachments", function () { "local not matching allAttachments", function () {
stop(); stop();
expect(7); expect(8);
var context = this, var context = this,
id = 'foobar', id = 'foobar',
...@@ -835,6 +940,7 @@ ...@@ -835,6 +940,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
conflict_handling: 1, conflict_handling: 1,
check_local_attachment_creation: true, check_local_attachment_creation: true,
...@@ -854,7 +960,7 @@ ...@@ -854,7 +960,7 @@
remote_sub_storage: { remote_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect2",
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -892,7 +998,11 @@ ...@@ -892,7 +998,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_FORCE_PUT_REMOTE, id],
[report.LOG_DELETE_REMOTE_ATTACHMENT, id, 'conflict']
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"conflict", "conflict",
...@@ -930,7 +1040,7 @@ ...@@ -930,7 +1040,7 @@
test("local and remote attachment creations: keep local, " + test("local and remote attachment creations: keep local, " +
"remote not matching allAttachments", function () { "remote not matching allAttachments", function () {
stop(); stop();
expect(3); expect(4);
var context = this, var context = this,
id = 'foobar', id = 'foobar',
...@@ -939,6 +1049,7 @@ ...@@ -939,6 +1049,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
conflict_handling: 1, conflict_handling: 1,
check_local_attachment_creation: true, check_local_attachment_creation: true,
...@@ -946,7 +1057,7 @@ ...@@ -946,7 +1057,7 @@
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect2",
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -987,7 +1098,11 @@ ...@@ -987,7 +1098,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_FORCE_PUT_REMOTE, id],
[report.LOG_PUT_REMOTE_ATTACHMENT, id, 'conflict']
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"conflict", "conflict",
...@@ -1022,7 +1137,7 @@ ...@@ -1022,7 +1137,7 @@
test("local and remote attachment creations: keep remote", function () { test("local and remote attachment creations: keep remote", function () {
stop(); stop();
expect(3); expect(4);
var context = this, var context = this,
id = 'foobar', id = 'foobar',
...@@ -1031,6 +1146,7 @@ ...@@ -1031,6 +1146,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
conflict_handling: 2, conflict_handling: 2,
check_local_attachment_creation: true, check_local_attachment_creation: true,
...@@ -1038,7 +1154,7 @@ ...@@ -1038,7 +1154,7 @@
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect2",
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -1050,7 +1166,7 @@ ...@@ -1050,7 +1166,7 @@
remote_sub_storage: { remote_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect2",
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -1084,7 +1200,11 @@ ...@@ -1084,7 +1200,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_FORCE_PUT_LOCAL, id],
[report.LOG_PUT_LOCAL_ATTACHMENT, id, 'conflict']
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"conflict", "conflict",
...@@ -1120,7 +1240,7 @@ ...@@ -1120,7 +1240,7 @@
test("local and remote attachment creations: keep remote, " + test("local and remote attachment creations: keep remote, " +
"local not matching allAttachments", function () { "local not matching allAttachments", function () {
stop(); stop();
expect(3); expect(4);
var context = this, var context = this,
id = 'foobar', id = 'foobar',
...@@ -1129,6 +1249,7 @@ ...@@ -1129,6 +1249,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
conflict_handling: 2, conflict_handling: 2,
check_local_attachment_creation: true, check_local_attachment_creation: true,
...@@ -1148,7 +1269,7 @@ ...@@ -1148,7 +1269,7 @@
remote_sub_storage: { remote_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect2",
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -1186,7 +1307,11 @@ ...@@ -1186,7 +1307,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_FORCE_PUT_LOCAL, id],
[report.LOG_PUT_LOCAL_ATTACHMENT, id, 'conflict']
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"conflict", "conflict",
...@@ -1222,7 +1347,7 @@ ...@@ -1222,7 +1347,7 @@
test("local and remote attachment creations: keep remote, " + test("local and remote attachment creations: keep remote, " +
"remote not matching allAttachments", function () { "remote not matching allAttachments", function () {
stop(); stop();
expect(7); expect(8);
var context = this, var context = this,
id = 'foobar', id = 'foobar',
...@@ -1231,6 +1356,7 @@ ...@@ -1231,6 +1356,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
conflict_handling: 2, conflict_handling: 2,
check_local_attachment_creation: true, check_local_attachment_creation: true,
...@@ -1238,7 +1364,7 @@ ...@@ -1238,7 +1364,7 @@
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect2",
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -1279,7 +1405,11 @@ ...@@ -1279,7 +1405,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_FORCE_PUT_LOCAL, id],
[report.LOG_DELETE_LOCAL_ATTACHMENT, id, 'conflict']
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"conflict", "conflict",
...@@ -1306,7 +1436,7 @@ ...@@ -1306,7 +1436,7 @@
ok(error instanceof jIO.util.jIOError); ok(error instanceof jIO.util.jIOError);
equal(error.status_code, 404); equal(error.status_code, 404);
var error_message = "Cannot find attachment: " + var error_message = "Cannot find attachment: " +
"_replicate_44c4bbda10d24c5e61597a46decdad1142ec8566 , " + "_replicate_7c9eb264c153b7919aa88a0ffb9ad81ae18e2ace , " +
"jio_attachment/"; "jio_attachment/";
equal( equal(
error.message.substring(0, error_message.length), error.message.substring(0, error_message.length),
...@@ -1323,7 +1453,7 @@ ...@@ -1323,7 +1453,7 @@
test("local and remote attachment creations: continue", function () { test("local and remote attachment creations: continue", function () {
stop(); stop();
expect(4); expect(5);
var context = this, var context = this,
id = 'foobar', id = 'foobar',
...@@ -1332,6 +1462,7 @@ ...@@ -1332,6 +1462,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
conflict_handling: 3, conflict_handling: 3,
check_local_attachment_creation: true, check_local_attachment_creation: true,
...@@ -1339,7 +1470,7 @@ ...@@ -1339,7 +1470,7 @@
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect2",
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -1351,7 +1482,7 @@ ...@@ -1351,7 +1482,7 @@
remote_sub_storage: { remote_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect2",
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -1385,7 +1516,10 @@ ...@@ -1385,7 +1516,10 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_SKIP_CONFLICT, id]
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"conflict", "conflict",
...@@ -1420,11 +1554,12 @@ ...@@ -1420,11 +1554,12 @@
test("local and remote same attachment creations", function () { test("local and remote same attachment creations", function () {
stop(); stop();
expect(3); expect(4);
var context = this, var context = this,
id = 'foobar', id = 'foobar',
blob = new Blob([big_string]); blob = new Blob([big_string]),
blob2 = new Blob(['a']);
context.jio.put(id, {"title": "foo"}) context.jio.put(id, {"title": "foo"})
.push(function () { .push(function () {
...@@ -1443,13 +1578,17 @@ ...@@ -1443,13 +1578,17 @@
), ),
context.jio.__storage._remote_sub_storage.putAttachment(id, context.jio.__storage._remote_sub_storage.putAttachment(id,
"conflict", "conflict",
blob) blob2)
]); ]);
}) })
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_FALSE_CONFLICT, id],
[report.LOG_PUT_REMOTE_ATTACHMENT, id, 'conflict']
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"conflict", "conflict",
...@@ -1484,7 +1623,7 @@ ...@@ -1484,7 +1623,7 @@
test("no attachment modification", function () { test("no attachment modification", function () {
stop(); stop();
expect(3); expect(4);
var context = this, var context = this,
id = 'foobar', id = 'foobar',
...@@ -1500,7 +1639,11 @@ ...@@ -1500,7 +1639,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_NO_CHANGE, id],
[report.LOG_NO_CHANGE, id]
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"conflict", "conflict",
...@@ -1535,7 +1678,7 @@ ...@@ -1535,7 +1678,7 @@
test("local attachment modification", function () { test("local attachment modification", function () {
stop(); stop();
expect(3); expect(4);
var context = this, var context = this,
id = 'foobar', id = 'foobar',
...@@ -1558,7 +1701,11 @@ ...@@ -1558,7 +1701,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_PUT_REMOTE, id],
[report.LOG_PUT_REMOTE_ATTACHMENT, id, 'conflict']
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"conflict", "conflict",
...@@ -1593,7 +1740,7 @@ ...@@ -1593,7 +1740,7 @@
test("local attachment modification not checked", function () { test("local attachment modification not checked", function () {
stop(); stop();
expect(3); expect(4);
var context = this, var context = this,
id = 'foobar', id = 'foobar',
...@@ -1602,13 +1749,14 @@ ...@@ -1602,13 +1749,14 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
check_local_attachment_creation: true, check_local_attachment_creation: true,
check_local_attachment_modification: false, check_local_attachment_modification: false,
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect2",
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -1620,7 +1768,7 @@ ...@@ -1620,7 +1768,7 @@
remote_sub_storage: { remote_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect2",
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -1647,7 +1795,11 @@ ...@@ -1647,7 +1795,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_PUT_REMOTE, id],
[report.LOG_SKIP_LOCAL_ATTACHMENT_MODIFICATION, id, 'conflict']
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"conflict", "conflict",
...@@ -1682,7 +1834,7 @@ ...@@ -1682,7 +1834,7 @@
test("remote attachment modification", function () { test("remote attachment modification", function () {
stop(); stop();
expect(3); expect(4);
var context = this, var context = this,
id = 'foobar', id = 'foobar',
...@@ -1712,7 +1864,12 @@ ...@@ -1712,7 +1864,12 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_NO_CHANGE, id],
[report.LOG_PUT_LOCAL, id],
[report.LOG_PUT_LOCAL_ATTACHMENT, id, 'conflict']
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"conflict", "conflict",
...@@ -1747,7 +1904,7 @@ ...@@ -1747,7 +1904,7 @@
test("remote attachment modification not checked", function () { test("remote attachment modification not checked", function () {
stop(); stop();
expect(3); expect(4);
var context = this, var context = this,
id = 'foobar', id = 'foobar',
...@@ -1756,13 +1913,14 @@ ...@@ -1756,13 +1913,14 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
check_local_attachment_creation: true, check_local_attachment_creation: true,
check_remote_attachment_modification: false, check_remote_attachment_modification: false,
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect2",
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -1774,7 +1932,7 @@ ...@@ -1774,7 +1932,7 @@
remote_sub_storage: { remote_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect2",
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -1808,7 +1966,12 @@ ...@@ -1808,7 +1966,12 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_NO_CHANGE, id],
[report.LOG_PUT_LOCAL, id],
[report.LOG_SKIP_REMOTE_ATTACHMENT_MODIFICATION, id, 'conflict']
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"conflict", "conflict",
...@@ -1843,7 +2006,7 @@ ...@@ -1843,7 +2006,7 @@
test("local and remote attachment modifications", function () { test("local and remote attachment modifications", function () {
stop(); stop();
expect(3); expect(4);
var context = this, var context = this,
id = 'foobar', id = 'foobar',
...@@ -1883,7 +2046,11 @@ ...@@ -1883,7 +2046,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_FALSE_CONFLICT, id],
[report.LOG_PUT_REMOTE_ATTACHMENT, id, 'conflict']
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"conflict", "conflict",
...@@ -1918,7 +2085,7 @@ ...@@ -1918,7 +2085,7 @@
test("local and remote attachment modifications: keep local", function () { test("local and remote attachment modifications: keep local", function () {
stop(); stop();
expect(3); expect(4);
var context = this, var context = this,
id = 'foobar', id = 'foobar',
...@@ -1928,6 +2095,7 @@ ...@@ -1928,6 +2095,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
conflict_handling: 1, conflict_handling: 1,
check_local_attachment_creation: true, check_local_attachment_creation: true,
...@@ -1937,7 +2105,7 @@ ...@@ -1937,7 +2105,7 @@
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect2",
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -1949,7 +2117,7 @@ ...@@ -1949,7 +2117,7 @@
remote_sub_storage: { remote_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect2",
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -1992,7 +2160,11 @@ ...@@ -1992,7 +2160,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_FORCE_PUT_REMOTE, id],
[report.LOG_PUT_REMOTE_ATTACHMENT, id, 'conflict']
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"conflict", "conflict",
...@@ -2027,7 +2199,7 @@ ...@@ -2027,7 +2199,7 @@
test("local and remote attachment modifications: keep remote", function () { test("local and remote attachment modifications: keep remote", function () {
stop(); stop();
expect(3); expect(4);
var context = this, var context = this,
id = 'foobar', id = 'foobar',
...@@ -2037,6 +2209,7 @@ ...@@ -2037,6 +2209,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
conflict_handling: 2, conflict_handling: 2,
check_local_attachment_creation: true, check_local_attachment_creation: true,
...@@ -2046,7 +2219,7 @@ ...@@ -2046,7 +2219,7 @@
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect2",
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -2058,7 +2231,7 @@ ...@@ -2058,7 +2231,7 @@
remote_sub_storage: { remote_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect2",
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -2101,7 +2274,11 @@ ...@@ -2101,7 +2274,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_FORCE_PUT_LOCAL, id],
[report.LOG_PUT_LOCAL_ATTACHMENT, id, 'conflict']
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"conflict", "conflict",
...@@ -2136,7 +2313,7 @@ ...@@ -2136,7 +2313,7 @@
test("local and remote attachment modifications: continue", function () { test("local and remote attachment modifications: continue", function () {
stop(); stop();
expect(3); expect(4);
var context = this, var context = this,
id = 'foobar', id = 'foobar',
...@@ -2146,6 +2323,7 @@ ...@@ -2146,6 +2323,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
conflict_handling: 3, conflict_handling: 3,
check_local_attachment_creation: true, check_local_attachment_creation: true,
...@@ -2155,7 +2333,7 @@ ...@@ -2155,7 +2333,7 @@
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect2",
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -2167,7 +2345,7 @@ ...@@ -2167,7 +2345,7 @@
remote_sub_storage: { remote_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect2",
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -2210,7 +2388,10 @@ ...@@ -2210,7 +2388,10 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_SKIP_CONFLICT, id]
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"conflict", "conflict",
...@@ -2245,7 +2426,7 @@ ...@@ -2245,7 +2426,7 @@
test("local attachment deletion", function () { test("local attachment deletion", function () {
stop(); stop();
expect(9); expect(10);
var id, var id,
context = this, context = this,
...@@ -2268,7 +2449,11 @@ ...@@ -2268,7 +2449,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_PUT_REMOTE, id],
[report.LOG_DELETE_REMOTE_ATTACHMENT, id, 'foo']
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"foo", "foo",
...@@ -2299,7 +2484,7 @@ ...@@ -2299,7 +2484,7 @@
ok(error instanceof jIO.util.jIOError); ok(error instanceof jIO.util.jIOError);
equal(error.status_code, 404); equal(error.status_code, 404);
var error_message = "Cannot find attachment: " + var error_message = "Cannot find attachment: " +
"_replicate_ae15d2189153f083c0e4a845fd580b1d86f7a512 , " + "_replicate_200e37c2a642ca3b7445acb600508c785e85610e , " +
"jio_attachment/"; "jio_attachment/";
equal( equal(
error.message.substring(0, error_message.length), error.message.substring(0, error_message.length),
...@@ -2317,7 +2502,7 @@ ...@@ -2317,7 +2502,7 @@
test("local attachment deletion not checked", function () { test("local attachment deletion not checked", function () {
stop(); stop();
expect(5); expect(6);
var id, var id,
context = this, context = this,
...@@ -2325,6 +2510,7 @@ ...@@ -2325,6 +2510,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
check_local_attachment_creation: true, check_local_attachment_creation: true,
check_local_attachment_deletion: false, check_local_attachment_deletion: false,
...@@ -2335,7 +2521,7 @@ ...@@ -2335,7 +2521,7 @@
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect2",
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -2347,7 +2533,7 @@ ...@@ -2347,7 +2533,7 @@
remote_sub_storage: { remote_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect2",
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -2375,7 +2561,11 @@ ...@@ -2375,7 +2561,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_PUT_REMOTE, id],
[report.LOG_SKIP_LOCAL_ATTACHMENT_DELETION, id, 'foo']
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"foo", "foo",
...@@ -2412,7 +2602,7 @@ ...@@ -2412,7 +2602,7 @@
test("remote attachment deletion", function () { test("remote attachment deletion", function () {
stop(); stop();
expect(9); expect(10);
var id, var id,
context = this, context = this,
...@@ -2435,7 +2625,12 @@ ...@@ -2435,7 +2625,12 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_NO_CHANGE, id],
[report.LOG_PUT_LOCAL, id],
[report.LOG_DELETE_LOCAL_ATTACHMENT, id, 'foo']
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"foo", "foo",
...@@ -2463,7 +2658,7 @@ ...@@ -2463,7 +2658,7 @@
ok(error instanceof jIO.util.jIOError); ok(error instanceof jIO.util.jIOError);
equal(error.status_code, 404); equal(error.status_code, 404);
var error_message = "Cannot find attachment: " + var error_message = "Cannot find attachment: " +
"_replicate_ae15d2189153f083c0e4a845fd580b1d86f7a512 , " + "_replicate_200e37c2a642ca3b7445acb600508c785e85610e , " +
"jio_attachment/"; "jio_attachment/";
equal( equal(
error.message.substring(0, error_message.length), error.message.substring(0, error_message.length),
...@@ -2481,7 +2676,7 @@ ...@@ -2481,7 +2676,7 @@
test("remote attachment deletion not checked", function () { test("remote attachment deletion not checked", function () {
stop(); stop();
expect(5); expect(6);
var id, var id,
context = this, context = this,
...@@ -2489,6 +2684,7 @@ ...@@ -2489,6 +2684,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
check_local_attachment_creation: true, check_local_attachment_creation: true,
check_local_attachment_deletion: true, check_local_attachment_deletion: true,
...@@ -2499,7 +2695,7 @@ ...@@ -2499,7 +2695,7 @@
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect2",
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -2511,7 +2707,7 @@ ...@@ -2511,7 +2707,7 @@
remote_sub_storage: { remote_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect2",
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -2539,7 +2735,12 @@ ...@@ -2539,7 +2735,12 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_NO_CHANGE, id],
[report.LOG_PUT_LOCAL, id],
[report.LOG_SKIP_REMOTE_ATTACHMENT_DELETION, id, 'foo']
]);
return context.jio.__storage._remote_sub_storage.getAttachment( return context.jio.__storage._remote_sub_storage.getAttachment(
id, id,
"foo", "foo",
...@@ -2576,7 +2777,7 @@ ...@@ -2576,7 +2777,7 @@
test("local and remote attachment deletions", function () { test("local and remote attachment deletions", function () {
stop(); stop();
expect(9); expect(10);
var id, var id,
context = this, context = this,
...@@ -2602,7 +2803,11 @@ ...@@ -2602,7 +2803,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_FALSE_CONFLICT, id],
[report.LOG_FALSE_CONFLICT_ATTACHMENT, id, 'foo']
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"foo", "foo",
...@@ -2630,7 +2835,7 @@ ...@@ -2630,7 +2835,7 @@
ok(error instanceof jIO.util.jIOError); ok(error instanceof jIO.util.jIOError);
equal(error.status_code, 404); equal(error.status_code, 404);
var error_message = "Cannot find attachment: " + var error_message = "Cannot find attachment: " +
"_replicate_ae15d2189153f083c0e4a845fd580b1d86f7a512 , " + "_replicate_200e37c2a642ca3b7445acb600508c785e85610e , " +
"jio_attachment/"; "jio_attachment/";
equal( equal(
error.message.substring(0, error_message.length), error.message.substring(0, error_message.length),
...@@ -2647,7 +2852,7 @@ ...@@ -2647,7 +2852,7 @@
test("local deletion and remote modifications", function () { test("local deletion and remote modifications", function () {
stop(); stop();
expect(3); expect(4);
var id, var id,
context = this, context = this,
...@@ -2674,7 +2879,11 @@ ...@@ -2674,7 +2879,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_FORCE_PUT_LOCAL, id],
[report.LOG_PUT_LOCAL_ATTACHMENT, id, 'foo']
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"foo", "foo",
...@@ -2709,7 +2918,7 @@ ...@@ -2709,7 +2918,7 @@
test("local deletion and remote modifications: keep local", function () { test("local deletion and remote modifications: keep local", function () {
stop(); stop();
expect(9); expect(10);
var id, var id,
context = this, context = this,
...@@ -2718,6 +2927,7 @@ ...@@ -2718,6 +2927,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
conflict_handling: 1, conflict_handling: 1,
check_local_attachment_creation: true, check_local_attachment_creation: true,
...@@ -2729,7 +2939,7 @@ ...@@ -2729,7 +2939,7 @@
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect2",
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -2741,7 +2951,7 @@ ...@@ -2741,7 +2951,7 @@
remote_sub_storage: { remote_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect2",
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -2772,7 +2982,11 @@ ...@@ -2772,7 +2982,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_FORCE_PUT_REMOTE, id],
[report.LOG_DELETE_REMOTE_ATTACHMENT, id, 'foo']
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"foo", "foo",
...@@ -2800,7 +3014,7 @@ ...@@ -2800,7 +3014,7 @@
ok(error instanceof jIO.util.jIOError); ok(error instanceof jIO.util.jIOError);
equal(error.status_code, 404); equal(error.status_code, 404);
var error_message = "Cannot find attachment: " + var error_message = "Cannot find attachment: " +
"_replicate_ae15d2189153f083c0e4a845fd580b1d86f7a512 , " + "_replicate_200e37c2a642ca3b7445acb600508c785e85610e , " +
"jio_attachment/"; "jio_attachment/";
equal( equal(
error.message.substring(0, error_message.length), error.message.substring(0, error_message.length),
...@@ -2818,7 +3032,7 @@ ...@@ -2818,7 +3032,7 @@
test("local deletion and remote modifications: keep local, dont check local", test("local deletion and remote modifications: keep local, dont check local",
function () { function () {
stop(); stop();
expect(5); expect(6);
var id, var id,
context = this, context = this,
...@@ -2827,6 +3041,7 @@ ...@@ -2827,6 +3041,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
conflict_handling: 1, conflict_handling: 1,
check_local_attachment_creation: true, check_local_attachment_creation: true,
...@@ -2838,7 +3053,7 @@ ...@@ -2838,7 +3053,7 @@
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect2",
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -2850,7 +3065,7 @@ ...@@ -2850,7 +3065,7 @@
remote_sub_storage: { remote_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect2",
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -2881,7 +3096,11 @@ ...@@ -2881,7 +3096,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_FORCE_PUT_REMOTE, id],
[report.LOG_SKIP_LOCAL_ATTACHMENT_DELETION, id, 'foo']
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"foo", "foo",
...@@ -2918,7 +3137,7 @@ ...@@ -2918,7 +3137,7 @@
test("local deletion and remote modifications: keep remote", function () { test("local deletion and remote modifications: keep remote", function () {
stop(); stop();
expect(3); expect(4);
var id, var id,
context = this, context = this,
...@@ -2927,6 +3146,7 @@ ...@@ -2927,6 +3146,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
conflict_handling: 2, conflict_handling: 2,
check_local_attachment_creation: true, check_local_attachment_creation: true,
...@@ -2938,7 +3158,7 @@ ...@@ -2938,7 +3158,7 @@
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect2",
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -2950,7 +3170,7 @@ ...@@ -2950,7 +3170,7 @@
remote_sub_storage: { remote_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect2",
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -2981,7 +3201,11 @@ ...@@ -2981,7 +3201,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_FORCE_PUT_LOCAL, id],
[report.LOG_PUT_LOCAL_ATTACHMENT, id, 'foo']
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"foo", "foo",
...@@ -3016,7 +3240,7 @@ ...@@ -3016,7 +3240,7 @@
test("local deletion and remote modifications: ignore", function () { test("local deletion and remote modifications: ignore", function () {
stop(); stop();
expect(5); expect(6);
var id, var id,
context = this, context = this,
...@@ -3025,6 +3249,7 @@ ...@@ -3025,6 +3249,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
conflict_handling: 3, conflict_handling: 3,
check_local_attachment_creation: true, check_local_attachment_creation: true,
...@@ -3036,7 +3261,7 @@ ...@@ -3036,7 +3261,7 @@
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect2",
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -3048,7 +3273,7 @@ ...@@ -3048,7 +3273,7 @@
remote_sub_storage: { remote_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect2",
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -3079,7 +3304,10 @@ ...@@ -3079,7 +3304,10 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_SKIP_CONFLICT, id]
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"foo", "foo",
...@@ -3116,7 +3344,7 @@ ...@@ -3116,7 +3344,7 @@
test("local modifications and remote deletion", function () { test("local modifications and remote deletion", function () {
stop(); stop();
expect(3); expect(4);
var id, var id,
context = this, context = this,
...@@ -3148,7 +3376,11 @@ ...@@ -3148,7 +3376,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_FORCE_PUT_REMOTE, id],
[report.LOG_PUT_REMOTE_ATTACHMENT, id, 'foo']
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"foo", "foo",
...@@ -3183,7 +3415,7 @@ ...@@ -3183,7 +3415,7 @@
test("local modifications and remote deletion: keep remote", function () { test("local modifications and remote deletion: keep remote", function () {
stop(); stop();
expect(9); expect(10);
var id, var id,
context = this, context = this,
...@@ -3192,6 +3424,7 @@ ...@@ -3192,6 +3424,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
conflict_handling: 2, conflict_handling: 2,
check_local_attachment_creation: true, check_local_attachment_creation: true,
...@@ -3203,7 +3436,7 @@ ...@@ -3203,7 +3436,7 @@
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect2",
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -3215,7 +3448,7 @@ ...@@ -3215,7 +3448,7 @@
remote_sub_storage: { remote_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect2",
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -3246,7 +3479,11 @@ ...@@ -3246,7 +3479,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_FORCE_PUT_LOCAL, id],
[report.LOG_DELETE_LOCAL_ATTACHMENT, id, 'foo']
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"foo", "foo",
...@@ -3274,7 +3511,7 @@ ...@@ -3274,7 +3511,7 @@
ok(error instanceof jIO.util.jIOError); ok(error instanceof jIO.util.jIOError);
equal(error.status_code, 404); equal(error.status_code, 404);
var error_message = "Cannot find attachment: " + var error_message = "Cannot find attachment: " +
"_replicate_ae15d2189153f083c0e4a845fd580b1d86f7a512 , " + "_replicate_200e37c2a642ca3b7445acb600508c785e85610e , " +
"jio_attachment/"; "jio_attachment/";
equal( equal(
error.message.substring(0, error_message.length), error.message.substring(0, error_message.length),
...@@ -3291,7 +3528,7 @@ ...@@ -3291,7 +3528,7 @@
test("local modifications and remote deletion: keep local", function () { test("local modifications and remote deletion: keep local", function () {
stop(); stop();
expect(3); expect(4);
var id, var id,
context = this, context = this,
...@@ -3300,6 +3537,7 @@ ...@@ -3300,6 +3537,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
conflict_handling: 1, conflict_handling: 1,
check_local_attachment_creation: true, check_local_attachment_creation: true,
...@@ -3311,7 +3549,7 @@ ...@@ -3311,7 +3549,7 @@
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect2",
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -3323,7 +3561,7 @@ ...@@ -3323,7 +3561,7 @@
remote_sub_storage: { remote_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect2",
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -3354,7 +3592,11 @@ ...@@ -3354,7 +3592,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_FORCE_PUT_REMOTE, id],
[report.LOG_PUT_REMOTE_ATTACHMENT, id, 'foo']
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"foo", "foo",
...@@ -3389,7 +3631,7 @@ ...@@ -3389,7 +3631,7 @@
test("local modif and remote del: keep remote, not check modif", function () { test("local modif and remote del: keep remote, not check modif", function () {
stop(); stop();
expect(9); expect(10);
var id, var id,
context = this, context = this,
...@@ -3398,6 +3640,7 @@ ...@@ -3398,6 +3640,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
conflict_handling: 2, conflict_handling: 2,
check_local_attachment_creation: true, check_local_attachment_creation: true,
...@@ -3409,7 +3652,7 @@ ...@@ -3409,7 +3652,7 @@
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect2",
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -3421,7 +3664,7 @@ ...@@ -3421,7 +3664,7 @@
remote_sub_storage: { remote_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect2",
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -3452,7 +3695,11 @@ ...@@ -3452,7 +3695,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_FORCE_PUT_LOCAL, id],
[report.LOG_DELETE_LOCAL_ATTACHMENT, id, 'foo']
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"foo", "foo",
...@@ -3480,7 +3727,7 @@ ...@@ -3480,7 +3727,7 @@
ok(error instanceof jIO.util.jIOError); ok(error instanceof jIO.util.jIOError);
equal(error.status_code, 404); equal(error.status_code, 404);
var error_message = "Cannot find attachment: " + var error_message = "Cannot find attachment: " +
"_replicate_ae15d2189153f083c0e4a845fd580b1d86f7a512 , " + "_replicate_200e37c2a642ca3b7445acb600508c785e85610e , " +
"jio_attachment/"; "jio_attachment/";
equal( equal(
error.message.substring(0, error_message.length), error.message.substring(0, error_message.length),
...@@ -3497,7 +3744,7 @@ ...@@ -3497,7 +3744,7 @@
test("local modifications and remote deletion: ignore", function () { test("local modifications and remote deletion: ignore", function () {
stop(); stop();
expect(5); expect(6);
var id, var id,
context = this, context = this,
...@@ -3506,6 +3753,7 @@ ...@@ -3506,6 +3753,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
conflict_handling: 3, conflict_handling: 3,
check_local_attachment_creation: true, check_local_attachment_creation: true,
...@@ -3517,7 +3765,7 @@ ...@@ -3517,7 +3765,7 @@
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect2",
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -3529,7 +3777,7 @@ ...@@ -3529,7 +3777,7 @@
remote_sub_storage: { remote_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect2",
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -3560,7 +3808,10 @@ ...@@ -3560,7 +3808,10 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_SKIP_CONFLICT, id]
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"foo", "foo",
...@@ -3600,7 +3851,7 @@ ...@@ -3600,7 +3851,7 @@
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
test("document and attachment deletion performance", function () { test("document and attachment deletion performance", function () {
stop(); stop();
expect(12); expect(13);
var id, var id,
context = this, context = this,
...@@ -3620,7 +3871,10 @@ ...@@ -3620,7 +3871,10 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_DELETE_REMOTE, id]
]);
return context.jio.__storage._remote_sub_storage.getAttachment( return context.jio.__storage._remote_sub_storage.getAttachment(
id, id,
"foo", "foo",
...@@ -3644,7 +3898,7 @@ ...@@ -3644,7 +3898,7 @@
ok(error instanceof jIO.util.jIOError); ok(error instanceof jIO.util.jIOError);
equal(error.status_code, 404); equal(error.status_code, 404);
var error_message = "Cannot find attachment: " + var error_message = "Cannot find attachment: " +
"_replicate_ae15d2189153f083c0e4a845fd580b1d86f7a512 , " + "_replicate_200e37c2a642ca3b7445acb600508c785e85610e , " +
"jio_attachment/"; "jio_attachment/";
equal( equal(
error.message.substring(0, error_message.length), error.message.substring(0, error_message.length),
...@@ -3656,7 +3910,7 @@ ...@@ -3656,7 +3910,7 @@
ok(error instanceof jIO.util.jIOError); ok(error instanceof jIO.util.jIOError);
equal(error.status_code, 404); equal(error.status_code, 404);
var error_message = "Cannot find attachment: " + var error_message = "Cannot find attachment: " +
"_replicate_ae15d2189153f083c0e4a845fd580b1d86f7a512 , " + "_replicate_200e37c2a642ca3b7445acb600508c785e85610e , " +
"jio_document/"; "jio_document/";
equal( equal(
error.message.substring(0, error_message.length), error.message.substring(0, error_message.length),
...@@ -3747,12 +4001,13 @@ ...@@ -3747,12 +4001,13 @@
); );
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
check_local_attachment_creation: true, check_local_attachment_creation: true,
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect2",
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -3764,7 +4019,7 @@ ...@@ -3764,7 +4019,7 @@
remote_sub_storage: { remote_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect2",
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -3906,13 +4161,14 @@ ...@@ -3906,13 +4161,14 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
check_local_attachment_creation: true, check_local_attachment_creation: true,
parallel_operation_attachment_amount: 2, parallel_operation_attachment_amount: 2,
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect2",
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -3924,7 +4180,7 @@ ...@@ -3924,7 +4180,7 @@
remote_sub_storage: { remote_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect2",
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -4046,13 +4302,14 @@ ...@@ -4046,13 +4302,14 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
check_local_attachment_creation: true, check_local_attachment_creation: true,
parallel_operation_attachment_amount: 4, parallel_operation_attachment_amount: 4,
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect2",
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -4064,7 +4321,7 @@ ...@@ -4064,7 +4321,7 @@
remote_sub_storage: { remote_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect2",
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -4104,7 +4361,7 @@ ...@@ -4104,7 +4361,7 @@
test("attachment skipped when local document deletion skipped", function () { test("attachment skipped when local document deletion skipped", function () {
stop(); stop();
expect(18); expect(19);
var id, var id,
context = this, context = this,
...@@ -4113,6 +4370,7 @@ ...@@ -4113,6 +4370,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
check_local_deletion: false, check_local_deletion: false,
check_local_attachment_modification: true, check_local_attachment_modification: true,
...@@ -4124,7 +4382,7 @@ ...@@ -4124,7 +4382,7 @@
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect2",
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -4136,7 +4394,7 @@ ...@@ -4136,7 +4394,7 @@
remote_sub_storage: { remote_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect2",
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -4174,7 +4432,11 @@ ...@@ -4174,7 +4432,11 @@
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_SKIP_LOCAL_DELETION, id],
[report.LOG_NO_CHANGE, id]
]);
ok(true, 'second repair success'); ok(true, 'second repair success');
// local document still deleted // local document still deleted
...@@ -4235,7 +4497,7 @@ ...@@ -4235,7 +4497,7 @@
ok(error instanceof jIO.util.jIOError); ok(error instanceof jIO.util.jIOError);
equal(error.status_code, 404); equal(error.status_code, 404);
var error_message = "Cannot find attachment: " + var error_message = "Cannot find attachment: " +
"_replicate_ae15d2189153f083c0e4a845fd580b1d86f7a512 , " + "_replicate_200e37c2a642ca3b7445acb600508c785e85610e , " +
"jio_attachment/"; "jio_attachment/";
equal( equal(
error.message.substring(0, error_message.length), error.message.substring(0, error_message.length),
...@@ -4292,7 +4554,7 @@ ...@@ -4292,7 +4554,7 @@
test("attachment skipped when remot document deletion skipped", function () { test("attachment skipped when remot document deletion skipped", function () {
stop(); stop();
expect(18); expect(19);
var id, var id,
context = this, context = this,
...@@ -4301,6 +4563,7 @@ ...@@ -4301,6 +4563,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
check_remote_deletion: false, check_remote_deletion: false,
check_local_attachment_modification: true, check_local_attachment_modification: true,
...@@ -4312,7 +4575,7 @@ ...@@ -4312,7 +4575,7 @@
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect2",
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -4324,7 +4587,7 @@ ...@@ -4324,7 +4587,7 @@
remote_sub_storage: { remote_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect2",
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -4359,7 +4622,11 @@ ...@@ -4359,7 +4622,11 @@
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_NO_CHANGE, id],
[report.LOG_SKIP_REMOTE_DELETION, id]
]);
ok(true, 'second repair success'); ok(true, 'second repair success');
// remote document still deleted // remote document still deleted
...@@ -4420,7 +4687,7 @@ ...@@ -4420,7 +4687,7 @@
ok(error instanceof jIO.util.jIOError); ok(error instanceof jIO.util.jIOError);
equal(error.status_code, 404); equal(error.status_code, 404);
var error_message = "Cannot find attachment: " + var error_message = "Cannot find attachment: " +
"_replicate_ae15d2189153f083c0e4a845fd580b1d86f7a512 , " + "_replicate_200e37c2a642ca3b7445acb600508c785e85610e , " +
"jio_attachment/"; "jio_attachment/";
equal( equal(
error.message.substring(0, error_message.length), error.message.substring(0, error_message.length),
...@@ -4477,7 +4744,7 @@ ...@@ -4477,7 +4744,7 @@
test("att sig deleted when local doc del resolved", function () { test("att sig deleted when local doc del resolved", function () {
stop(); stop();
expect(16); expect(17);
var id, var id,
context = this, context = this,
...@@ -4513,7 +4780,13 @@ ...@@ -4513,7 +4780,13 @@
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_FORCE_PUT_LOCAL, id],
[report.LOG_PUT_LOCAL_ATTACHMENT, id, 'foo'],
[report.LOG_PUT_LOCAL_ATTACHMENT, id, 'foomod'],
[report.LOG_PUT_LOCAL_ATTACHMENT, id, 'foocre']
]);
ok(true, 'second repair success'); ok(true, 'second repair success');
// local document recreated // local document recreated
...@@ -4611,7 +4884,7 @@ ...@@ -4611,7 +4884,7 @@
ok(error instanceof jIO.util.jIOError); ok(error instanceof jIO.util.jIOError);
equal(error.status_code, 404); equal(error.status_code, 404);
var error_message = "Cannot find attachment: " + var error_message = "Cannot find attachment: " +
"_replicate_ae15d2189153f083c0e4a845fd580b1d86f7a512 , " + "_replicate_200e37c2a642ca3b7445acb600508c785e85610e , " +
"jio_attachment/"; "jio_attachment/";
equal( equal(
error.message.substring(0, error_message.length), error.message.substring(0, error_message.length),
...@@ -4629,7 +4902,7 @@ ...@@ -4629,7 +4902,7 @@
test("att sig deleted when remot doc del resolved", function () { test("att sig deleted when remot doc del resolved", function () {
stop(); stop();
expect(16); expect(17);
var id, var id,
context = this, context = this,
...@@ -4661,7 +4934,13 @@ ...@@ -4661,7 +4934,13 @@
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_FORCE_PUT_REMOTE, id],
[report.LOG_PUT_REMOTE_ATTACHMENT, id, 'foo'],
[report.LOG_PUT_REMOTE_ATTACHMENT, id, 'foomod'],
[report.LOG_PUT_REMOTE_ATTACHMENT, id, 'foocre']
]);
ok(true, 'second repair success'); ok(true, 'second repair success');
// remote document recreated // remote document recreated
...@@ -4759,7 +5038,7 @@ ...@@ -4759,7 +5038,7 @@
ok(error instanceof jIO.util.jIOError); ok(error instanceof jIO.util.jIOError);
equal(error.status_code, 404); equal(error.status_code, 404);
var error_message = "Cannot find attachment: " + var error_message = "Cannot find attachment: " +
"_replicate_ae15d2189153f083c0e4a845fd580b1d86f7a512 , " + "_replicate_200e37c2a642ca3b7445acb600508c785e85610e , " +
"jio_attachment/"; "jio_attachment/";
equal( equal(
error.message.substring(0, error_message.length), error.message.substring(0, error_message.length),
...@@ -4777,7 +5056,7 @@ ...@@ -4777,7 +5056,7 @@
test("att sig deleted when local not checked doc del resolved", function () { test("att sig deleted when local not checked doc del resolved", function () {
stop(); stop();
expect(16); expect(17);
var id, var id,
context = this, context = this,
...@@ -4786,6 +5065,7 @@ ...@@ -4786,6 +5065,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
check_local_deletion: false, check_local_deletion: false,
check_local_attachment_modification: true, check_local_attachment_modification: true,
...@@ -4797,7 +5077,7 @@ ...@@ -4797,7 +5077,7 @@
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect2",
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -4809,7 +5089,7 @@ ...@@ -4809,7 +5089,7 @@
remote_sub_storage: { remote_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect2",
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -4849,7 +5129,14 @@ ...@@ -4849,7 +5129,14 @@
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_SKIP_LOCAL_DELETION, id],
[report.LOG_FORCE_PUT_LOCAL, id],
[report.LOG_PUT_LOCAL_ATTACHMENT, id, 'foo'],
[report.LOG_PUT_LOCAL_ATTACHMENT, id, 'foomod'],
[report.LOG_PUT_LOCAL_ATTACHMENT, id, 'foocre']
]);
ok(true, 'second repair success'); ok(true, 'second repair success');
// local document recreated // local document recreated
...@@ -4947,7 +5234,7 @@ ...@@ -4947,7 +5234,7 @@
ok(error instanceof jIO.util.jIOError); ok(error instanceof jIO.util.jIOError);
equal(error.status_code, 404); equal(error.status_code, 404);
var error_message = "Cannot find attachment: " + var error_message = "Cannot find attachment: " +
"_replicate_ae15d2189153f083c0e4a845fd580b1d86f7a512 , " + "_replicate_200e37c2a642ca3b7445acb600508c785e85610e , " +
"jio_attachment/"; "jio_attachment/";
equal( equal(
error.message.substring(0, error_message.length), error.message.substring(0, error_message.length),
...@@ -4965,7 +5252,7 @@ ...@@ -4965,7 +5252,7 @@
test("att sig deleted when remot doc not checked del resolved", function () { test("att sig deleted when remot doc not checked del resolved", function () {
stop(); stop();
expect(16); expect(17);
var id, var id,
context = this, context = this,
...@@ -4974,6 +5261,7 @@ ...@@ -4974,6 +5261,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
signature_hash_key: 'foo_etag', signature_hash_key: 'foo_etag',
check_remote_deletion: false, check_remote_deletion: false,
check_local_attachment_modification: true, check_local_attachment_modification: true,
...@@ -4985,7 +5273,7 @@ ...@@ -4985,7 +5273,7 @@
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect2",
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -4997,7 +5285,7 @@ ...@@ -4997,7 +5285,7 @@
remote_sub_storage: { remote_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "storagealldocsdynamicselect", type: "storagealldocsdynamicselect2",
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -5033,7 +5321,13 @@ ...@@ -5033,7 +5321,13 @@
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_FORCE_PUT_REMOTE, id],
[report.LOG_PUT_REMOTE_ATTACHMENT, id, 'foo'],
[report.LOG_PUT_REMOTE_ATTACHMENT, id, 'foomod'],
[report.LOG_PUT_REMOTE_ATTACHMENT, id, 'foocre']
]);
ok(true, 'second repair success'); ok(true, 'second repair success');
// remote document recreated // remote document recreated
...@@ -5131,7 +5425,7 @@ ...@@ -5131,7 +5425,7 @@
ok(error instanceof jIO.util.jIOError); ok(error instanceof jIO.util.jIOError);
equal(error.status_code, 404); equal(error.status_code, 404);
var error_message = "Cannot find attachment: " + var error_message = "Cannot find attachment: " +
"_replicate_ae15d2189153f083c0e4a845fd580b1d86f7a512 , " + "_replicate_200e37c2a642ca3b7445acb600508c785e85610e , " +
"jio_attachment/"; "jio_attachment/";
equal( equal(
error.message.substring(0, error_message.length), error.message.substring(0, error_message.length),
......
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
// Uses memory substorage, so that it is flushed after each run // Uses memory substorage, so that it is flushed after each run
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
...@@ -67,7 +68,7 @@ ...@@ -67,7 +68,7 @@
test("local document creation", function () { test("local document creation", function () {
stop(); stop();
expect(2); expect(3);
var id, var id,
context = this; context = this;
...@@ -77,7 +78,8 @@ ...@@ -77,7 +78,8 @@
id = result; id = result;
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [[report.LOG_PUT_REMOTE, id]]);
return context.jio.__storage._remote_sub_storage.get(id); return context.jio.__storage._remote_sub_storage.get(id);
}) })
.then(function (result) { .then(function (result) {
...@@ -104,10 +106,11 @@ ...@@ -104,10 +106,11 @@
test("local document creation not checked", function () { test("local document creation not checked", function () {
stop(); stop();
expect(6); expect(7);
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
check_local_creation: false, check_local_creation: false,
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
...@@ -131,7 +134,8 @@ ...@@ -131,7 +134,8 @@
id = result; id = result;
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [[report.LOG_SKIP_LOCAL_CREATION, id]]);
return context.jio.get(id); return context.jio.get(id);
}) })
.then(function (result) { .then(function (result) {
...@@ -161,7 +165,7 @@ ...@@ -161,7 +165,7 @@
test("local document creation and use remote post", function () { test("local document creation and use remote post", function () {
stop(); stop();
expect(13); expect(14);
var id, var id,
post_id, post_id,
...@@ -170,6 +174,7 @@ ...@@ -170,6 +174,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
use_remote_post: true, use_remote_post: true,
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
...@@ -194,7 +199,8 @@ ...@@ -194,7 +199,8 @@
return context.jio.repair(); return context.jio.repair();
}) })
// Document 'id' has been deleted in both storages // Document 'id' has been deleted in both storages
.then(function () { .then(function (report) {
deepEqual(report._list, [[report.LOG_POST_REMOTE, id]]);
return context.jio.__storage._remote_sub_storage.get(id); return context.jio.__storage._remote_sub_storage.get(id);
}) })
.fail(function (error) { .fail(function (error) {
...@@ -266,7 +272,7 @@ ...@@ -266,7 +272,7 @@
test("local document creation, remote post and delayed allDocs", function () { test("local document creation, remote post and delayed allDocs", function () {
stop(); stop();
expect(11); expect(12);
var id, var id,
post_id = "_foobar", post_id = "_foobar",
...@@ -297,6 +303,7 @@ ...@@ -297,6 +303,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
use_remote_post: true, use_remote_post: true,
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
...@@ -318,7 +325,8 @@ ...@@ -318,7 +325,8 @@
return context.jio.repair(); return context.jio.repair();
}) })
// Document 'id' has been deleted in both storages // Document 'id' has been deleted in both storages
.then(function () { .then(function (report) {
deepEqual(report._list, [[report.LOG_POST_REMOTE, id]]);
return context.jio.__storage._remote_sub_storage.get(id); return context.jio.__storage._remote_sub_storage.get(id);
}) })
.fail(function (error) { .fail(function (error) {
...@@ -378,7 +386,7 @@ ...@@ -378,7 +386,7 @@
test("remote document creation", function () { test("remote document creation", function () {
stop(); stop();
expect(2); expect(3);
var id, var id,
context = this; context = this;
...@@ -388,7 +396,8 @@ ...@@ -388,7 +396,8 @@
id = result; id = result;
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [[report.LOG_PUT_LOCAL, id]]);
return context.jio.get(id); return context.jio.get(id);
}) })
.then(function (result) { .then(function (result) {
...@@ -415,13 +424,14 @@ ...@@ -415,13 +424,14 @@
test("remote document creation not checked", function () { test("remote document creation not checked", function () {
stop(); stop();
expect(6); expect(7);
var id, var id,
context = this; context = this;
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
check_remote_creation: false, check_remote_creation: false,
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
...@@ -442,7 +452,8 @@ ...@@ -442,7 +452,8 @@
id = result; id = result;
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [[report.LOG_SKIP_REMOTE_CREATION, id]]);
return context.jio.__storage._remote_sub_storage.get(id); return context.jio.__storage._remote_sub_storage.get(id);
}) })
.then(function (result) { .then(function (result) {
...@@ -475,7 +486,7 @@ ...@@ -475,7 +486,7 @@
test("local and remote document creations", function () { test("local and remote document creations", function () {
stop(); stop();
expect(5); expect(3);
var context = this; var context = this;
...@@ -491,10 +502,7 @@ ...@@ -491,10 +502,7 @@
ok(false); ok(false);
}) })
.fail(function (error) { .fail(function (error) {
ok(error instanceof jIO.util.jIOError); deepEqual(error._list, [[error.LOG_UNRESOLVED_CONFLICT, 'conflict']]);
equal(error.message, "Conflict on 'conflict': " +
"{\"title\":\"foo\"} !== {\"title\":\"bar\"}");
equal(error.status_code, 409);
}) })
.then(function () { .then(function () {
return context.jio.__storage._signature_sub_storage.get("conflict"); return context.jio.__storage._signature_sub_storage.get("conflict");
...@@ -511,12 +519,13 @@ ...@@ -511,12 +519,13 @@
test("local and remote document creations: keep local", function () { test("local and remote document creations: keep local", function () {
stop(); stop();
expect(3); expect(4);
var context = this; var context = this;
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
...@@ -540,7 +549,8 @@ ...@@ -540,7 +549,8 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [[report.LOG_FORCE_PUT_REMOTE, 'conflict']]);
return context.jio.__storage._signature_sub_storage.get("conflict"); return context.jio.__storage._signature_sub_storage.get("conflict");
}) })
.then(function (result) { .then(function (result) {
...@@ -576,12 +586,13 @@ ...@@ -576,12 +586,13 @@
test("local and remote document creations: keep local, remote post", test("local and remote document creations: keep local, remote post",
function () { function () {
stop(); stop();
expect(3); expect(4);
var context = this; var context = this;
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
use_remote_post: 1, use_remote_post: 1,
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
...@@ -606,7 +617,8 @@ ...@@ -606,7 +617,8 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [[report.LOG_FORCE_PUT_REMOTE, 'conflict']]);
return context.jio.__storage._signature_sub_storage.get("conflict"); return context.jio.__storage._signature_sub_storage.get("conflict");
}) })
.then(function (result) { .then(function (result) {
...@@ -642,12 +654,13 @@ ...@@ -642,12 +654,13 @@
test("local and remote document creations: keep local, " + test("local and remote document creations: keep local, " +
"local not matching query", function () { "local not matching query", function () {
stop(); stop();
expect(3); expect(4);
var context = this; var context = this;
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
local_sub_storage: { local_sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -673,7 +686,8 @@ ...@@ -673,7 +686,8 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [[report.LOG_FORCE_PUT_REMOTE, 'conflict']]);
return context.jio.__storage._signature_sub_storage.get("conflict"); return context.jio.__storage._signature_sub_storage.get("conflict");
}) })
.then(function (result) { .then(function (result) {
...@@ -709,12 +723,13 @@ ...@@ -709,12 +723,13 @@
test("local and remote document creations: keep local, " + test("local and remote document creations: keep local, " +
"remote not matching query", function () { "remote not matching query", function () {
stop(); stop();
expect(3); expect(4);
var context = this; var context = this;
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
local_sub_storage: { local_sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -739,7 +754,8 @@ ...@@ -739,7 +754,8 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [[report.LOG_FORCE_PUT_REMOTE, 'conflict']]);
return context.jio.__storage._signature_sub_storage.get("conflict"); return context.jio.__storage._signature_sub_storage.get("conflict");
}) })
.then(function (result) { .then(function (result) {
...@@ -776,12 +792,13 @@ ...@@ -776,12 +792,13 @@
test("local and remote document creations: keep remote", function () { test("local and remote document creations: keep remote", function () {
stop(); stop();
expect(3); expect(4);
var context = this; var context = this;
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
...@@ -805,7 +822,8 @@ ...@@ -805,7 +822,8 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [[report.LOG_FORCE_PUT_LOCAL, 'conflict']]);
return context.jio.__storage._signature_sub_storage.get("conflict"); return context.jio.__storage._signature_sub_storage.get("conflict");
}) })
.then(function (result) { .then(function (result) {
...@@ -841,12 +859,13 @@ ...@@ -841,12 +859,13 @@
test("local and remote document creations: keep remote, remote post", test("local and remote document creations: keep remote, remote post",
function () { function () {
stop(); stop();
expect(3); expect(4);
var context = this; var context = this;
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
use_remote_post: 1, use_remote_post: 1,
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
...@@ -871,7 +890,8 @@ ...@@ -871,7 +890,8 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [[report.LOG_FORCE_PUT_LOCAL, 'conflict']]);
return context.jio.__storage._signature_sub_storage.get("conflict"); return context.jio.__storage._signature_sub_storage.get("conflict");
}) })
.then(function (result) { .then(function (result) {
...@@ -907,12 +927,13 @@ ...@@ -907,12 +927,13 @@
test("local and remote document creations: keep remote, " + test("local and remote document creations: keep remote, " +
"local not matching query", function () { "local not matching query", function () {
stop(); stop();
expect(3); expect(4);
var context = this; var context = this;
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
local_sub_storage: { local_sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -938,7 +959,8 @@ ...@@ -938,7 +959,8 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [[report.LOG_FORCE_PUT_LOCAL, 'conflict']]);
return context.jio.__storage._signature_sub_storage.get("conflict"); return context.jio.__storage._signature_sub_storage.get("conflict");
}) })
.then(function (result) { .then(function (result) {
...@@ -976,12 +998,13 @@ ...@@ -976,12 +998,13 @@
test("local and remote document creations: keep remote, " + test("local and remote document creations: keep remote, " +
"remote not matching query", function () { "remote not matching query", function () {
stop(); stop();
expect(3); expect(4);
var context = this; var context = this;
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
local_sub_storage: { local_sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
...@@ -1006,7 +1029,8 @@ ...@@ -1006,7 +1029,8 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [[report.LOG_FORCE_PUT_LOCAL, 'conflict']]);
return context.jio.__storage._signature_sub_storage.get("conflict"); return context.jio.__storage._signature_sub_storage.get("conflict");
}) })
.then(function (result) { .then(function (result) {
...@@ -1041,12 +1065,13 @@ ...@@ -1041,12 +1065,13 @@
test("local and remote document creations: continue", function () { test("local and remote document creations: continue", function () {
stop(); stop();
expect(4); expect(5);
var context = this; var context = this;
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
...@@ -1070,7 +1095,8 @@ ...@@ -1070,7 +1095,8 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [[report.LOG_SKIP_CONFLICT, 'conflict']]);
return context.jio.__storage._signature_sub_storage.get("conflict"); return context.jio.__storage._signature_sub_storage.get("conflict");
}) })
.fail(function (error) { .fail(function (error) {
...@@ -1105,12 +1131,13 @@ ...@@ -1105,12 +1131,13 @@
test("local and remote document creations: continue, remote post", test("local and remote document creations: continue, remote post",
function () { function () {
stop(); stop();
expect(4); expect(5);
var context = this; var context = this;
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
use_remote_post: 1, use_remote_post: 1,
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
...@@ -1135,7 +1162,8 @@ ...@@ -1135,7 +1162,8 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [[report.LOG_SKIP_CONFLICT, 'conflict']]);
return context.jio.__storage._signature_sub_storage.get("conflict"); return context.jio.__storage._signature_sub_storage.get("conflict");
}) })
.fail(function (error) { .fail(function (error) {
...@@ -1169,7 +1197,7 @@ ...@@ -1169,7 +1197,7 @@
test("local and remote same document creations", function () { test("local and remote same document creations", function () {
stop(); stop();
expect(1); expect(2);
var context = this; var context = this;
...@@ -1181,7 +1209,8 @@ ...@@ -1181,7 +1209,8 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [[report.LOG_FALSE_CONFLICT, 'conflict']]);
return context.jio.__storage._signature_sub_storage.get("conflict"); return context.jio.__storage._signature_sub_storage.get("conflict");
}) })
.then(function (result) { .then(function (result) {
...@@ -1200,7 +1229,7 @@ ...@@ -1200,7 +1229,7 @@
test("no modification", function () { test("no modification", function () {
stop(); stop();
expect(2); expect(3);
var id, var id,
context = this; context = this;
...@@ -1213,7 +1242,8 @@ ...@@ -1213,7 +1242,8 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [[report.LOG_NO_CHANGE, id]]);
return context.jio.__storage._remote_sub_storage.get(id); return context.jio.__storage._remote_sub_storage.get(id);
}) })
.then(function (result) { .then(function (result) {
...@@ -1240,7 +1270,7 @@ ...@@ -1240,7 +1270,7 @@
test("local document modification", function () { test("local document modification", function () {
stop(); stop();
expect(2); expect(3);
var id, var id,
context = this; context = this;
...@@ -1256,7 +1286,8 @@ ...@@ -1256,7 +1286,8 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [[report.LOG_PUT_REMOTE, id]]);
return context.jio.__storage._remote_sub_storage.get(id); return context.jio.__storage._remote_sub_storage.get(id);
}) })
.then(function (result) { .then(function (result) {
...@@ -1284,13 +1315,14 @@ ...@@ -1284,13 +1315,14 @@
test("local document modification: use remote post", function () { test("local document modification: use remote post", function () {
stop(); stop();
expect(2); expect(3);
var id, var id,
context = this; context = this;
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
use_remote_post: true, use_remote_post: true,
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
...@@ -1317,7 +1349,8 @@ ...@@ -1317,7 +1349,8 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [[report.LOG_PUT_REMOTE, id]]);
return context.jio.__storage._remote_sub_storage.get(id); return context.jio.__storage._remote_sub_storage.get(id);
}) })
.then(function (result) { .then(function (result) {
...@@ -1344,13 +1377,14 @@ ...@@ -1344,13 +1377,14 @@
test("local document modification not checked", function () { test("local document modification not checked", function () {
stop(); stop();
expect(3); expect(4);
var id, var id,
context = this; context = this;
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
check_local_modification: false, check_local_modification: false,
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
...@@ -1377,7 +1411,11 @@ ...@@ -1377,7 +1411,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_SKIP_LOCAL_MODIFICATION, id],
[report.LOG_NO_CHANGE, id],
]);
return context.jio.get(id); return context.jio.get(id);
}) })
.then(function (result) { .then(function (result) {
...@@ -1412,7 +1450,7 @@ ...@@ -1412,7 +1450,7 @@
test("remote document modification", function () { test("remote document modification", function () {
stop(); stop();
expect(2); expect(3);
var id, var id,
context = this; context = this;
...@@ -1431,7 +1469,10 @@ ...@@ -1431,7 +1469,10 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_PUT_LOCAL, id]
]);
return context.jio.get(id); return context.jio.get(id);
}) })
.then(function (result) { .then(function (result) {
...@@ -1458,13 +1499,14 @@ ...@@ -1458,13 +1499,14 @@
test("remote document modification not checked", function () { test("remote document modification not checked", function () {
stop(); stop();
expect(3); expect(4);
var id, var id,
context = this; context = this;
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
check_remote_modification: false, check_remote_modification: false,
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
...@@ -1494,7 +1536,10 @@ ...@@ -1494,7 +1536,10 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_SKIP_REMOTE_MODIFICATION, id]
]);
return context.jio.__storage._remote_sub_storage.get(id); return context.jio.__storage._remote_sub_storage.get(id);
}) })
.then(function (result) { .then(function (result) {
...@@ -1529,7 +1574,7 @@ ...@@ -1529,7 +1574,7 @@
test("local and remote document modifications", function () { test("local and remote document modifications", function () {
stop(); stop();
expect(4); expect(2);
var id, var id,
context = this; context = this;
...@@ -1552,10 +1597,7 @@ ...@@ -1552,10 +1597,7 @@
ok(false); ok(false);
}) })
.fail(function (error) { .fail(function (error) {
ok(error instanceof jIO.util.jIOError); deepEqual(error._list, [[error.LOG_UNRESOLVED_CONFLICT, id]]);
equal(error.message, "Conflict on '" + id + "': " +
"{\"title\":\"foo4\"} !== {\"title\":\"foo5\"}");
equal(error.status_code, 409);
}) })
.then(function () { .then(function () {
return context.jio.__storage._signature_sub_storage.get(id); return context.jio.__storage._signature_sub_storage.get(id);
...@@ -1573,13 +1615,14 @@ ...@@ -1573,13 +1615,14 @@
test("local and remote document modifications: keep local", function () { test("local and remote document modifications: keep local", function () {
stop(); stop();
expect(3); expect(4);
var id, var id,
context = this; context = this;
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
...@@ -1609,7 +1652,8 @@ ...@@ -1609,7 +1652,8 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [[report.LOG_FORCE_PUT_REMOTE, id]]);
return context.jio.__storage._signature_sub_storage.get(id); return context.jio.__storage._signature_sub_storage.get(id);
}) })
.then(function (result) { .then(function (result) {
...@@ -1644,13 +1688,14 @@ ...@@ -1644,13 +1688,14 @@
test("local and remote document modifications: keep remote", function () { test("local and remote document modifications: keep remote", function () {
stop(); stop();
expect(3); expect(4);
var id, var id,
context = this; context = this;
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
...@@ -1680,7 +1725,8 @@ ...@@ -1680,7 +1725,8 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [[report.LOG_FORCE_PUT_LOCAL, id]]);
return context.jio.__storage._signature_sub_storage.get(id); return context.jio.__storage._signature_sub_storage.get(id);
}) })
.then(function (result) { .then(function (result) {
...@@ -1715,13 +1761,14 @@ ...@@ -1715,13 +1761,14 @@
test("local and remote document modifications: continue", function () { test("local and remote document modifications: continue", function () {
stop(); stop();
expect(3); expect(4);
var id, var id,
context = this; context = this;
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
...@@ -1751,7 +1798,8 @@ ...@@ -1751,7 +1798,8 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [[report.LOG_SKIP_CONFLICT, id]]);
return context.jio.__storage._signature_sub_storage.get(id); return context.jio.__storage._signature_sub_storage.get(id);
}) })
.then(function (result) { .then(function (result) {
...@@ -1786,7 +1834,7 @@ ...@@ -1786,7 +1834,7 @@
test("local and remote document same modifications", function () { test("local and remote document same modifications", function () {
stop(); stop();
expect(1); expect(2);
var id, var id,
context = this; context = this;
...@@ -1805,7 +1853,8 @@ ...@@ -1805,7 +1853,8 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [[report.LOG_FALSE_CONFLICT, id]]);
return context.jio.__storage._signature_sub_storage.get(id); return context.jio.__storage._signature_sub_storage.get(id);
}) })
.then(function (result) { .then(function (result) {
...@@ -1824,7 +1873,7 @@ ...@@ -1824,7 +1873,7 @@
test("local document deletion", function () { test("local document deletion", function () {
stop(); stop();
expect(6); expect(7);
var id, var id,
context = this; context = this;
...@@ -1840,7 +1889,8 @@ ...@@ -1840,7 +1889,8 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [[report.LOG_DELETE_REMOTE, id]]);
ok(true, "Removal correctly synced"); ok(true, "Removal correctly synced");
}) })
.then(function () { .then(function () {
...@@ -1869,13 +1919,14 @@ ...@@ -1869,13 +1919,14 @@
test("local document deletion not checked", function () { test("local document deletion not checked", function () {
stop(); stop();
expect(6); expect(7);
var id, var id,
context = this; context = this;
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
check_local_deletion: false, check_local_deletion: false,
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
...@@ -1902,7 +1953,11 @@ ...@@ -1902,7 +1953,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_SKIP_LOCAL_DELETION, id],
[report.LOG_NO_CHANGE, id]
]);
ok(true, "Removal correctly synced"); ok(true, "Removal correctly synced");
}) })
.then(function () { .then(function () {
...@@ -1958,8 +2013,10 @@ ...@@ -1958,8 +2013,10 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .fail(function (report) {
ok(true, "Removal correctly synced"); deepEqual(report._list, [
[report.LOG_UNEXPECTED_REMOTE_ATTACHMENT, id]
]);
}) })
.then(function () { .then(function () {
return context.jio.get(id); return context.jio.get(id);
...@@ -2000,7 +2057,7 @@ ...@@ -2000,7 +2057,7 @@
test("remote document deletion", function () { test("remote document deletion", function () {
stop(); stop();
expect(6); expect(7);
var id, var id,
context = this; context = this;
...@@ -2016,7 +2073,10 @@ ...@@ -2016,7 +2073,10 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_DELETE_LOCAL, id]
]);
ok(true, "Removal correctly synced"); ok(true, "Removal correctly synced");
}) })
.then(function () { .then(function () {
...@@ -2045,13 +2105,14 @@ ...@@ -2045,13 +2105,14 @@
test("remote document deletion not checked", function () { test("remote document deletion not checked", function () {
stop(); stop();
expect(6); expect(7);
var id, var id,
context = this; context = this;
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
check_remote_deletion: false, check_remote_deletion: false,
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
...@@ -2078,7 +2139,10 @@ ...@@ -2078,7 +2139,10 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_SKIP_REMOTE_DELETION, id]
]);
ok(true, "Removal correctly synced"); ok(true, "Removal correctly synced");
}) })
.then(function () { .then(function () {
...@@ -2133,8 +2197,10 @@ ...@@ -2133,8 +2197,10 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .fail(function (report) {
ok(true, "Removal correctly synced"); deepEqual(report._list, [
[report.LOG_UNEXPECTED_LOCAL_ATTACHMENT, id]
]);
}) })
.then(function () { .then(function () {
return context.jio.__storage._remote_sub_storage.get(id); return context.jio.__storage._remote_sub_storage.get(id);
...@@ -2174,7 +2240,7 @@ ...@@ -2174,7 +2240,7 @@
test("local and remote document deletions", function () { test("local and remote document deletions", function () {
stop(); stop();
expect(8); expect(9);
var id, var id,
context = this; context = this;
...@@ -2193,7 +2259,10 @@ ...@@ -2193,7 +2259,10 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_FALSE_CONFLICT, id]
]);
return context.jio.get(id) return context.jio.get(id)
.then(function () { .then(function () {
ok(false, "Document should be locally deleted"); ok(false, "Document should be locally deleted");
...@@ -2236,7 +2305,7 @@ ...@@ -2236,7 +2305,7 @@
test("local deletion and remote modifications", function () { test("local deletion and remote modifications", function () {
stop(); stop();
expect(2); expect(3);
var id, var id,
context = this; context = this;
...@@ -2255,7 +2324,10 @@ ...@@ -2255,7 +2324,10 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_FORCE_PUT_LOCAL, id]
]);
return context.jio.get(id); return context.jio.get(id);
}) })
.then(function (result) { .then(function (result) {
...@@ -2282,13 +2354,14 @@ ...@@ -2282,13 +2354,14 @@
test("local deletion and remote modifications: keep local", function () { test("local deletion and remote modifications: keep local", function () {
stop(); stop();
expect(9); expect(10);
var id, var id,
context = this; context = this;
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
conflict_handling: 1, conflict_handling: 1,
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
...@@ -2318,7 +2391,10 @@ ...@@ -2318,7 +2391,10 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_FORCE_DELETE_REMOTE, id]
]);
return context.jio.get(id); return context.jio.get(id);
}) })
.fail(function (error) { .fail(function (error) {
...@@ -2359,13 +2435,14 @@ ...@@ -2359,13 +2435,14 @@
test("local deletion and remote modifications: keep remote", function () { test("local deletion and remote modifications: keep remote", function () {
stop(); stop();
expect(3); expect(4);
var id, var id,
context = this; context = this;
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
conflict_handling: 2, conflict_handling: 2,
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
...@@ -2395,7 +2472,10 @@ ...@@ -2395,7 +2472,10 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_FORCE_PUT_LOCAL, id]
]);
return context.jio.get(id); return context.jio.get(id);
}) })
.then(function (result) { .then(function (result) {
...@@ -2430,13 +2510,14 @@ ...@@ -2430,13 +2510,14 @@
test("local deletion and remote modifications: ignore", function () { test("local deletion and remote modifications: ignore", function () {
stop(); stop();
expect(5); expect(6);
var id, var id,
context = this; context = this;
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
conflict_handling: 3, conflict_handling: 3,
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
...@@ -2466,7 +2547,10 @@ ...@@ -2466,7 +2547,10 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_SKIP_CONFLICT, id]
]);
return context.jio.get(id); return context.jio.get(id);
}) })
.fail(function (error) { .fail(function (error) {
...@@ -2501,7 +2585,7 @@ ...@@ -2501,7 +2585,7 @@
test("local modifications and remote deletion", function () { test("local modifications and remote deletion", function () {
stop(); stop();
expect(2); expect(3);
var id, var id,
context = this; context = this;
...@@ -2520,7 +2604,10 @@ ...@@ -2520,7 +2604,10 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_FORCE_PUT_REMOTE, id]
]);
return context.jio.__storage._remote_sub_storage.get(id); return context.jio.__storage._remote_sub_storage.get(id);
}) })
.then(function (result) { .then(function (result) {
...@@ -2547,7 +2634,7 @@ ...@@ -2547,7 +2634,7 @@
test("local modifications and remote deletion: use remote post", function () { test("local modifications and remote deletion: use remote post", function () {
stop(); stop();
expect(13); expect(14);
var id, var id,
context = this, context = this,
...@@ -2555,6 +2642,7 @@ ...@@ -2555,6 +2642,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
use_remote_post: true, use_remote_post: true,
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
...@@ -2585,7 +2673,10 @@ ...@@ -2585,7 +2673,10 @@
return context.jio.repair(); return context.jio.repair();
}) })
// Old id deleted // Old id deleted
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_POST_REMOTE, id]
]);
return context.jio.get(id); return context.jio.get(id);
}) })
.fail(function (error) { .fail(function (error) {
...@@ -2658,7 +2749,7 @@ ...@@ -2658,7 +2749,7 @@
test("local modif, remote del: remote post, no check loc mod", function () { test("local modif, remote del: remote post, no check loc mod", function () {
stop(); stop();
expect(13); expect(14);
var id, var id,
context = this, context = this,
...@@ -2666,6 +2757,7 @@ ...@@ -2666,6 +2757,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
use_remote_post: true, use_remote_post: true,
check_local_modification: false, check_local_modification: false,
local_sub_storage: { local_sub_storage: {
...@@ -2697,7 +2789,11 @@ ...@@ -2697,7 +2789,11 @@
return context.jio.repair(); return context.jio.repair();
}) })
// Old id deleted // Old id deleted
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_SKIP_LOCAL_MODIFICATION, id],
[report.LOG_POST_REMOTE, id]
]);
return context.jio.get(id); return context.jio.get(id);
}) })
.fail(function (error) { .fail(function (error) {
...@@ -2769,13 +2865,14 @@ ...@@ -2769,13 +2865,14 @@
test("local modifications and remote deletion: keep local", function () { test("local modifications and remote deletion: keep local", function () {
stop(); stop();
expect(3); expect(4);
var id, var id,
context = this; context = this;
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
conflict_handling: 1, conflict_handling: 1,
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
...@@ -2806,7 +2903,10 @@ ...@@ -2806,7 +2903,10 @@
return context.jio.repair(); return context.jio.repair();
}) })
// Old id deleted // Old id deleted
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_FORCE_PUT_REMOTE, id]
]);
return context.jio.get(id); return context.jio.get(id);
}) })
.then(function (result) { .then(function (result) {
...@@ -2841,7 +2941,7 @@ ...@@ -2841,7 +2941,7 @@
test("local modif and remote del: keep local, use remote post", function () { test("local modif and remote del: keep local, use remote post", function () {
stop(); stop();
expect(13); expect(14);
var id, var id,
context = this, context = this,
...@@ -2849,6 +2949,7 @@ ...@@ -2849,6 +2949,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
conflict_handling: 1, conflict_handling: 1,
use_remote_post: true, use_remote_post: true,
local_sub_storage: { local_sub_storage: {
...@@ -2880,7 +2981,10 @@ ...@@ -2880,7 +2981,10 @@
return context.jio.repair(); return context.jio.repair();
}) })
// Old id deleted // Old id deleted
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_POST_REMOTE, id]
]);
return context.jio.get(id); return context.jio.get(id);
}) })
.fail(function (error) { .fail(function (error) {
...@@ -2952,13 +3056,14 @@ ...@@ -2952,13 +3056,14 @@
test("local modifications and remote deletion: keep remote", function () { test("local modifications and remote deletion: keep remote", function () {
stop(); stop();
expect(9); expect(10);
var id, var id,
context = this; context = this;
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
conflict_handling: 2, conflict_handling: 2,
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
...@@ -2989,7 +3094,10 @@ ...@@ -2989,7 +3094,10 @@
return context.jio.repair(); return context.jio.repair();
}) })
// id deleted // id deleted
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_FORCE_DELETE_LOCAL, id]
]);
return context.jio.get(id); return context.jio.get(id);
}) })
.fail(function (error) { .fail(function (error) {
...@@ -3030,13 +3138,14 @@ ...@@ -3030,13 +3138,14 @@
test("local modif and remote del: keep remote, not check modif", function () { test("local modif and remote del: keep remote, not check modif", function () {
stop(); stop();
expect(9); expect(10);
var id, var id,
context = this; context = this;
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
conflict_handling: 2, conflict_handling: 2,
check_local_modification: false, check_local_modification: false,
local_sub_storage: { local_sub_storage: {
...@@ -3068,7 +3177,11 @@ ...@@ -3068,7 +3177,11 @@
return context.jio.repair(); return context.jio.repair();
}) })
// id deleted // id deleted
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_SKIP_LOCAL_MODIFICATION, id],
[report.LOG_FORCE_DELETE_LOCAL, id]
]);
return context.jio.get(id); return context.jio.get(id);
}) })
.fail(function (error) { .fail(function (error) {
...@@ -3109,13 +3222,14 @@ ...@@ -3109,13 +3222,14 @@
test("local modifications and remote deletion: ignore", function () { test("local modifications and remote deletion: ignore", function () {
stop(); stop();
expect(5); expect(6);
var id, var id,
context = this; context = this;
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
conflict_handling: 3, conflict_handling: 3,
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
...@@ -3146,7 +3260,10 @@ ...@@ -3146,7 +3260,10 @@
return context.jio.repair(); return context.jio.repair();
}) })
// id deleted // id deleted
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_SKIP_CONFLICT, id]
]);
return context.jio.get(id); return context.jio.get(id);
}) })
.then(function (result) { .then(function (result) {
...@@ -3294,6 +3411,7 @@ ...@@ -3294,6 +3411,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
local_sub_storage: { local_sub_storage: {
type: "replicatestorage200chechrepair" type: "replicatestorage200chechrepair"
}, },
...@@ -3342,6 +3460,7 @@ ...@@ -3342,6 +3460,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
local_sub_storage: { local_sub_storage: {
type: "replicatestorage200defaultquery" type: "replicatestorage200defaultquery"
}, },
...@@ -3391,6 +3510,7 @@ ...@@ -3391,6 +3510,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
local_sub_storage: { local_sub_storage: {
type: "replicatestorage200customquery" type: "replicatestorage200customquery"
}, },
...@@ -3479,6 +3599,7 @@ ...@@ -3479,6 +3599,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
local_sub_storage: { local_sub_storage: {
type: "memory" type: "memory"
}, },
...@@ -3601,6 +3722,7 @@ ...@@ -3601,6 +3722,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
parallel_operation_amount: 2, parallel_operation_amount: 2,
local_sub_storage: { local_sub_storage: {
type: "memory" type: "memory"
...@@ -3698,6 +3820,7 @@ ...@@ -3698,6 +3820,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
parallel_operation_amount: 4, parallel_operation_amount: 4,
local_sub_storage: { local_sub_storage: {
type: "memory" type: "memory"
......
...@@ -77,6 +77,7 @@ ...@@ -77,6 +77,7 @@
// Uses memory substorage, so that it is flushed after each run // Uses memory substorage, so that it is flushed after each run
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
check_local_attachment_creation: true, check_local_attachment_creation: true,
check_local_attachment_modification: true, check_local_attachment_modification: true,
check_local_attachment_deletion: true, check_local_attachment_deletion: true,
...@@ -102,7 +103,7 @@ ...@@ -102,7 +103,7 @@
test("local attachment creation", function () { test("local attachment creation", function () {
stop(); stop();
expect(2); expect(3);
var id, var id,
context = this, context = this,
...@@ -116,7 +117,11 @@ ...@@ -116,7 +117,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_PUT_REMOTE, id],
[report.LOG_PUT_REMOTE_ATTACHMENT, id, 'foo']
]);
return context.jio.__storage._remote_sub_storage.getAttachment( return context.jio.__storage._remote_sub_storage.getAttachment(
id, id,
"foo", "foo",
...@@ -144,7 +149,7 @@ ...@@ -144,7 +149,7 @@
test("local attachment creation, local document creation not checked", test("local attachment creation, local document creation not checked",
function () { function () {
stop(); stop();
expect(6); expect(7);
var id, var id,
context = this, context = this,
...@@ -152,6 +157,7 @@ ...@@ -152,6 +157,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
check_local_creation: false, check_local_creation: false,
check_local_attachment_creation: true, check_local_attachment_creation: true,
local_sub_storage: { local_sub_storage: {
...@@ -176,7 +182,10 @@ ...@@ -176,7 +182,10 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_SKIP_LOCAL_CREATION, id]
]);
return context.jio.__storage._remote_sub_storage.getAttachment( return context.jio.__storage._remote_sub_storage.getAttachment(
id, id,
"foo", "foo",
...@@ -211,7 +220,7 @@ ...@@ -211,7 +220,7 @@
test("local attachment creation not checked", function () { test("local attachment creation not checked", function () {
stop(); stop();
expect(6); expect(7);
var id, var id,
context = this, context = this,
...@@ -219,7 +228,9 @@ ...@@ -219,7 +228,9 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
check_local_attachment_creation: false, check_local_attachment_creation: false,
check_local_attachment_modification: true,
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
...@@ -242,7 +253,11 @@ ...@@ -242,7 +253,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_PUT_REMOTE, id],
[report.LOG_SKIP_LOCAL_ATTACHMENT_CREATION, id, 'foo']
]);
return context.jio.__storage._remote_sub_storage.getAttachment( return context.jio.__storage._remote_sub_storage.getAttachment(
id, id,
"foo", "foo",
...@@ -278,15 +293,17 @@ ...@@ -278,15 +293,17 @@
test("local attachment creation, local document creation and use remote post", test("local attachment creation, local document creation and use remote post",
function () { function () {
stop(); stop();
expect(4); expect(5);
var id, var id,
context = this, context = this,
post_id, post_id,
blob = new Blob([big_string]); blob = new Blob([big_string]),
report;
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
use_remote_post: true, use_remote_post: true,
check_local_attachment_creation: true, check_local_attachment_creation: true,
local_sub_storage: { local_sub_storage: {
...@@ -312,12 +329,17 @@ ...@@ -312,12 +329,17 @@
return context.jio.repair(); return context.jio.repair();
}) })
// Another document should have been created // Another document should have been created
.then(function () { .then(function (result) {
report = result;
return context.jio.__storage._remote_sub_storage.allDocs(); return context.jio.__storage._remote_sub_storage.allDocs();
}) })
.then(function (result) { .then(function (result) {
equal(result.data.total_rows, 1); equal(result.data.total_rows, 1);
post_id = result.data.rows[0].id; post_id = result.data.rows[0].id;
deepEqual(report._list, [
[report.LOG_POST_REMOTE, id],
[report.LOG_PUT_REMOTE_ATTACHMENT, post_id, 'foo']
]);
return context.jio.getAttachment( return context.jio.getAttachment(
post_id, post_id,
"foo", "foo",
...@@ -352,7 +374,7 @@ ...@@ -352,7 +374,7 @@
test("remote attachment creation", function () { test("remote attachment creation", function () {
stop(); stop();
expect(2); expect(3);
var id, var id,
context = this, context = this,
...@@ -367,7 +389,11 @@ ...@@ -367,7 +389,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_PUT_LOCAL, id],
[report.LOG_PUT_LOCAL_ATTACHMENT, id, 'foo']
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"foo", "foo",
...@@ -395,7 +421,7 @@ ...@@ -395,7 +421,7 @@
test("remote attachment creation, remote document creation not checked", test("remote attachment creation, remote document creation not checked",
function () { function () {
stop(); stop();
expect(6); expect(7);
var id, var id,
context = this, context = this,
...@@ -403,6 +429,7 @@ ...@@ -403,6 +429,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
check_remote_creation: false, check_remote_creation: false,
check_local_attachment_creation: true, check_local_attachment_creation: true,
local_sub_storage: { local_sub_storage: {
...@@ -428,7 +455,10 @@ ...@@ -428,7 +455,10 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_SKIP_REMOTE_CREATION, id],
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"foo", "foo",
...@@ -464,7 +494,7 @@ ...@@ -464,7 +494,7 @@
test("remote attachment creation not checked", function () { test("remote attachment creation not checked", function () {
stop(); stop();
expect(6); expect(7);
var id, var id,
context = this, context = this,
...@@ -472,7 +502,9 @@ ...@@ -472,7 +502,9 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
check_remote_attachment_creation: false, check_remote_attachment_creation: false,
check_remote_attachment_modification: true,
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
...@@ -496,7 +528,11 @@ ...@@ -496,7 +528,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_PUT_LOCAL, id],
[report.LOG_SKIP_REMOTE_ATTACHMENT_CREATION, id, 'foo']
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"foo", "foo",
...@@ -531,7 +567,7 @@ ...@@ -531,7 +567,7 @@
test("local and remote attachment creations", function () { test("local and remote attachment creations", function () {
stop(); stop();
expect(5); expect(3);
var context = this, var context = this,
id = 'foobar', id = 'foobar',
...@@ -556,10 +592,11 @@ ...@@ -556,10 +592,11 @@
.then(function () { .then(function () {
ok(false); ok(false);
}) })
.fail(function (error) { .fail(function (report) {
ok(error instanceof jIO.util.jIOError); deepEqual(report._list, [
equal(error.message, "Conflict on 'foobar' with attachment 'conflict'"); [report.LOG_NO_CHANGE, id],
equal(error.status_code, 409); [report.LOG_UNRESOLVED_ATTACHMENT_CONFLICT, id, 'conflict']
]);
}) })
.then(function () { .then(function () {
return context.jio.__storage._signature_sub_storage.getAttachment( return context.jio.__storage._signature_sub_storage.getAttachment(
...@@ -579,7 +616,7 @@ ...@@ -579,7 +616,7 @@
test("local and remote attachment creations: keep local", function () { test("local and remote attachment creations: keep local", function () {
stop(); stop();
expect(3); expect(4);
var context = this, var context = this,
id = 'foobar', id = 'foobar',
...@@ -588,6 +625,7 @@ ...@@ -588,6 +625,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
conflict_handling: 1, conflict_handling: 1,
check_local_attachment_creation: true, check_local_attachment_creation: true,
check_remote_attachment_creation: true, check_remote_attachment_creation: true,
...@@ -620,7 +658,11 @@ ...@@ -620,7 +658,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_NO_CHANGE, id],
[report.LOG_FORCE_PUT_REMOTE_ATTACHMENT, id, 'conflict']
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"conflict", "conflict",
...@@ -656,7 +698,7 @@ ...@@ -656,7 +698,7 @@
test("local and remote attachment creations: keep local, " + test("local and remote attachment creations: keep local, " +
"local not matching allAttachments", function () { "local not matching allAttachments", function () {
stop(); stop();
expect(3); expect(4);
var context = this, var context = this,
id = 'foobar', id = 'foobar',
...@@ -665,6 +707,7 @@ ...@@ -665,6 +707,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
conflict_handling: 1, conflict_handling: 1,
check_local_attachment_creation: true, check_local_attachment_creation: true,
check_remote_attachment_creation: true, check_remote_attachment_creation: true,
...@@ -709,7 +752,11 @@ ...@@ -709,7 +752,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_NO_CHANGE, id],
[report.LOG_FORCE_PUT_REMOTE_ATTACHMENT, id, 'conflict']
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"conflict", "conflict",
...@@ -745,7 +792,7 @@ ...@@ -745,7 +792,7 @@
test("local and remote attachment creations: keep local, " + test("local and remote attachment creations: keep local, " +
"remote not matching allAttachments", function () { "remote not matching allAttachments", function () {
stop(); stop();
expect(3); expect(4);
var context = this, var context = this,
id = 'foobar', id = 'foobar',
...@@ -754,6 +801,7 @@ ...@@ -754,6 +801,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
conflict_handling: 1, conflict_handling: 1,
check_local_attachment_creation: true, check_local_attachment_creation: true,
check_remote_attachment_creation: true, check_remote_attachment_creation: true,
...@@ -789,7 +837,11 @@ ...@@ -789,7 +837,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_NO_CHANGE, id],
[report.LOG_FORCE_PUT_REMOTE_ATTACHMENT, id, 'conflict']
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"conflict", "conflict",
...@@ -824,7 +876,7 @@ ...@@ -824,7 +876,7 @@
test("local and remote attachment creations: keep remote", function () { test("local and remote attachment creations: keep remote", function () {
stop(); stop();
expect(3); expect(4);
var context = this, var context = this,
id = 'foobar', id = 'foobar',
...@@ -833,6 +885,7 @@ ...@@ -833,6 +885,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
conflict_handling: 2, conflict_handling: 2,
check_local_attachment_creation: true, check_local_attachment_creation: true,
check_remote_attachment_creation: true, check_remote_attachment_creation: true,
...@@ -865,7 +918,11 @@ ...@@ -865,7 +918,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_NO_CHANGE, id],
[report.LOG_FORCE_PUT_LOCAL_ATTACHMENT, id, 'conflict']
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"conflict", "conflict",
...@@ -901,7 +958,7 @@ ...@@ -901,7 +958,7 @@
test("local and remote attachment creations: keep remote, " + test("local and remote attachment creations: keep remote, " +
"local not matching allAttachments", function () { "local not matching allAttachments", function () {
stop(); stop();
expect(3); expect(4);
var context = this, var context = this,
id = 'foobar', id = 'foobar',
...@@ -910,6 +967,7 @@ ...@@ -910,6 +967,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
conflict_handling: 2, conflict_handling: 2,
check_local_attachment_creation: true, check_local_attachment_creation: true,
check_remote_attachment_creation: true, check_remote_attachment_creation: true,
...@@ -954,7 +1012,11 @@ ...@@ -954,7 +1012,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_NO_CHANGE, id],
[report.LOG_FORCE_PUT_LOCAL_ATTACHMENT, id, 'conflict']
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"conflict", "conflict",
...@@ -990,7 +1052,7 @@ ...@@ -990,7 +1052,7 @@
test("local and remote attachment creations: keep remote, " + test("local and remote attachment creations: keep remote, " +
"remote not matching allAttachments", function () { "remote not matching allAttachments", function () {
stop(); stop();
expect(3); expect(4);
var context = this, var context = this,
id = 'foobar', id = 'foobar',
...@@ -999,6 +1061,7 @@ ...@@ -999,6 +1061,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
conflict_handling: 2, conflict_handling: 2,
check_local_attachment_creation: true, check_local_attachment_creation: true,
check_remote_attachment_creation: true, check_remote_attachment_creation: true,
...@@ -1034,7 +1097,11 @@ ...@@ -1034,7 +1097,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_NO_CHANGE, id],
[report.LOG_FORCE_PUT_LOCAL_ATTACHMENT, id, 'conflict']
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"conflict", "conflict",
...@@ -1069,7 +1136,7 @@ ...@@ -1069,7 +1136,7 @@
test("local and remote attachment creations: continue", function () { test("local and remote attachment creations: continue", function () {
stop(); stop();
expect(4); expect(5);
var context = this, var context = this,
id = 'foobar', id = 'foobar',
...@@ -1078,6 +1145,7 @@ ...@@ -1078,6 +1145,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
conflict_handling: 3, conflict_handling: 3,
check_local_attachment_creation: true, check_local_attachment_creation: true,
check_remote_attachment_creation: true, check_remote_attachment_creation: true,
...@@ -1110,7 +1178,11 @@ ...@@ -1110,7 +1178,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_NO_CHANGE, id],
[report.LOG_SKIP_CONFLICT_ATTACHMENT, id, 'conflict']
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"conflict", "conflict",
...@@ -1145,7 +1217,7 @@ ...@@ -1145,7 +1217,7 @@
test("local and remote same attachment creations", function () { test("local and remote same attachment creations", function () {
stop(); stop();
expect(3); expect(4);
var context = this, var context = this,
id = 'foobar', id = 'foobar',
...@@ -1167,7 +1239,11 @@ ...@@ -1167,7 +1239,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_NO_CHANGE, id],
[report.LOG_FALSE_CONFLICT_ATTACHMENT, id, 'conflict']
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"conflict", "conflict",
...@@ -1202,7 +1278,7 @@ ...@@ -1202,7 +1278,7 @@
test("no attachment modification", function () { test("no attachment modification", function () {
stop(); stop();
expect(3); expect(4);
var context = this, var context = this,
id = 'foobar', id = 'foobar',
...@@ -1221,7 +1297,11 @@ ...@@ -1221,7 +1297,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_NO_CHANGE, id],
[report.LOG_NO_CHANGE_ATTACHMENT, id, 'conflict']
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"conflict", "conflict",
...@@ -1256,7 +1336,7 @@ ...@@ -1256,7 +1336,7 @@
test("local attachment modification", function () { test("local attachment modification", function () {
stop(); stop();
expect(3); expect(4);
var context = this, var context = this,
id = 'foobar', id = 'foobar',
...@@ -1279,7 +1359,11 @@ ...@@ -1279,7 +1359,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_NO_CHANGE, id],
[report.LOG_PUT_REMOTE_ATTACHMENT, id, 'conflict']
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"conflict", "conflict",
...@@ -1314,7 +1398,7 @@ ...@@ -1314,7 +1398,7 @@
test("local attachment modification not checked", function () { test("local attachment modification not checked", function () {
stop(); stop();
expect(3); expect(4);
var context = this, var context = this,
id = 'foobar', id = 'foobar',
...@@ -1323,6 +1407,7 @@ ...@@ -1323,6 +1407,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
check_local_attachment_creation: true, check_local_attachment_creation: true,
check_local_attachment_modification: false, check_local_attachment_modification: false,
local_sub_storage: { local_sub_storage: {
...@@ -1355,7 +1440,11 @@ ...@@ -1355,7 +1440,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_NO_CHANGE, id],
[report.LOG_SKIP_LOCAL_ATTACHMENT_MODIFICATION, id, 'conflict']
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"conflict", "conflict",
...@@ -1390,7 +1479,7 @@ ...@@ -1390,7 +1479,7 @@
test("remote attachment modification", function () { test("remote attachment modification", function () {
stop(); stop();
expect(3); expect(4);
var context = this, var context = this,
id = 'foobar', id = 'foobar',
...@@ -1414,7 +1503,11 @@ ...@@ -1414,7 +1503,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_NO_CHANGE, id],
[report.LOG_PUT_LOCAL_ATTACHMENT, id, 'conflict']
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"conflict", "conflict",
...@@ -1449,7 +1542,7 @@ ...@@ -1449,7 +1542,7 @@
test("remote attachment modification not checked", function () { test("remote attachment modification not checked", function () {
stop(); stop();
expect(3); expect(4);
var context = this, var context = this,
id = 'foobar', id = 'foobar',
...@@ -1458,8 +1551,11 @@ ...@@ -1458,8 +1551,11 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
check_local_attachment_creation: true, check_local_attachment_creation: true,
check_local_attachment_modification: true,
check_remote_attachment_modification: false, check_remote_attachment_modification: false,
check_remote_attachment_creation: true,
local_sub_storage: { local_sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
...@@ -1491,7 +1587,11 @@ ...@@ -1491,7 +1587,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_NO_CHANGE, id],
[report.LOG_SKIP_REMOTE_ATTACHMENT_MODIFICATION, id, 'conflict']
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"conflict", "conflict",
...@@ -1526,7 +1626,7 @@ ...@@ -1526,7 +1626,7 @@
test("local and remote attachment modifications", function () { test("local and remote attachment modifications", function () {
stop(); stop();
expect(6); expect(4);
var context = this, var context = this,
id = 'foobar', id = 'foobar',
...@@ -1557,11 +1657,11 @@ ...@@ -1557,11 +1657,11 @@
.then(function () { .then(function () {
ok(false); ok(false);
}) })
.fail(function (error) { .fail(function (report) {
ok(error instanceof jIO.util.jIOError); deepEqual(report._list, [
equal(error.message, "Conflict on 'foobar' " + [report.LOG_NO_CHANGE, id],
"with attachment 'conflict'"); [report.LOG_UNRESOLVED_ATTACHMENT_CONFLICT, id, 'conflict']
equal(error.status_code, 409); ]);
}) })
.then(function () { .then(function () {
return context.jio.getAttachment( return context.jio.getAttachment(
...@@ -1598,7 +1698,7 @@ ...@@ -1598,7 +1698,7 @@
test("local and remote attachment modifications: keep local", function () { test("local and remote attachment modifications: keep local", function () {
stop(); stop();
expect(3); expect(4);
var context = this, var context = this,
id = 'foobar', id = 'foobar',
...@@ -1608,6 +1708,7 @@ ...@@ -1608,6 +1708,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
conflict_handling: 1, conflict_handling: 1,
check_local_attachment_creation: true, check_local_attachment_creation: true,
check_remote_attachment_creation: true, check_remote_attachment_creation: true,
...@@ -1647,7 +1748,11 @@ ...@@ -1647,7 +1748,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_NO_CHANGE, id],
[report.LOG_FORCE_PUT_REMOTE_ATTACHMENT, id, 'conflict']
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"conflict", "conflict",
...@@ -1682,7 +1787,7 @@ ...@@ -1682,7 +1787,7 @@
test("local and remote attachment modifications: keep remote", function () { test("local and remote attachment modifications: keep remote", function () {
stop(); stop();
expect(3); expect(4);
var context = this, var context = this,
id = 'foobar', id = 'foobar',
...@@ -1692,6 +1797,7 @@ ...@@ -1692,6 +1797,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
conflict_handling: 2, conflict_handling: 2,
check_local_attachment_creation: true, check_local_attachment_creation: true,
check_remote_attachment_creation: true, check_remote_attachment_creation: true,
...@@ -1731,7 +1837,11 @@ ...@@ -1731,7 +1837,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_NO_CHANGE, id],
[report.LOG_FORCE_PUT_LOCAL_ATTACHMENT, id, 'conflict']
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"conflict", "conflict",
...@@ -1766,7 +1876,7 @@ ...@@ -1766,7 +1876,7 @@
test("local and remote attachment modifications: continue", function () { test("local and remote attachment modifications: continue", function () {
stop(); stop();
expect(3); expect(4);
var context = this, var context = this,
id = 'foobar', id = 'foobar',
...@@ -1776,6 +1886,7 @@ ...@@ -1776,6 +1886,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
conflict_handling: 3, conflict_handling: 3,
check_local_attachment_creation: true, check_local_attachment_creation: true,
check_remote_attachment_creation: true, check_remote_attachment_creation: true,
...@@ -1815,7 +1926,11 @@ ...@@ -1815,7 +1926,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_NO_CHANGE, id],
[report.LOG_SKIP_CONFLICT_ATTACHMENT, id, 'conflict']
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"conflict", "conflict",
...@@ -1850,7 +1965,7 @@ ...@@ -1850,7 +1965,7 @@
test("local and remote attachment same modifications", function () { test("local and remote attachment same modifications", function () {
stop(); stop();
expect(3); expect(4);
var context = this, var context = this,
id = 'foobar', id = 'foobar',
...@@ -1877,7 +1992,11 @@ ...@@ -1877,7 +1992,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_NO_CHANGE, id],
[report.LOG_FALSE_CONFLICT_ATTACHMENT, id, 'conflict']
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"conflict", "conflict",
...@@ -1912,7 +2031,7 @@ ...@@ -1912,7 +2031,7 @@
test("local attachment deletion", function () { test("local attachment deletion", function () {
stop(); stop();
expect(9); expect(10);
var id, var id,
context = this, context = this,
...@@ -1932,7 +2051,11 @@ ...@@ -1932,7 +2051,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_NO_CHANGE, id],
[report.LOG_DELETE_REMOTE_ATTACHMENT, id, 'foo']
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"foo", "foo",
...@@ -1978,7 +2101,7 @@ ...@@ -1978,7 +2101,7 @@
test("local attachment deletion not checked", function () { test("local attachment deletion not checked", function () {
stop(); stop();
expect(5); expect(6);
var id, var id,
context = this, context = this,
...@@ -1986,6 +2109,7 @@ ...@@ -1986,6 +2109,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
check_local_attachment_creation: true, check_local_attachment_creation: true,
check_local_attachment_deletion: false, check_local_attachment_deletion: false,
check_local_attachment_modification: true, check_local_attachment_modification: true,
...@@ -2020,7 +2144,12 @@ ...@@ -2020,7 +2144,12 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_NO_CHANGE, id],
[report.LOG_SKIP_LOCAL_ATTACHMENT_DELETION, id, 'foo'],
[report.LOG_NO_CHANGE_ATTACHMENT, id, 'foo']
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"foo", "foo",
...@@ -2057,7 +2186,7 @@ ...@@ -2057,7 +2186,7 @@
test("remote attachment deletion", function () { test("remote attachment deletion", function () {
stop(); stop();
expect(9); expect(10);
var id, var id,
context = this, context = this,
...@@ -2078,7 +2207,11 @@ ...@@ -2078,7 +2207,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_NO_CHANGE, id],
[report.LOG_DELETE_LOCAL_ATTACHMENT, id, 'foo']
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"foo", "foo",
...@@ -2124,7 +2257,7 @@ ...@@ -2124,7 +2257,7 @@
test("remote attachment deletion not checked", function () { test("remote attachment deletion not checked", function () {
stop(); stop();
expect(5); expect(6);
var id, var id,
context = this, context = this,
...@@ -2132,6 +2265,7 @@ ...@@ -2132,6 +2265,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
check_local_attachment_creation: true, check_local_attachment_creation: true,
check_local_attachment_deletion: true, check_local_attachment_deletion: true,
check_local_attachment_modification: true, check_local_attachment_modification: true,
...@@ -2167,7 +2301,11 @@ ...@@ -2167,7 +2301,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_NO_CHANGE, id],
[report.LOG_SKIP_REMOTE_ATTACHMENT_DELETION, id, 'foo']
]);
return context.jio.__storage._remote_sub_storage.getAttachment( return context.jio.__storage._remote_sub_storage.getAttachment(
id, id,
"foo", "foo",
...@@ -2204,7 +2342,7 @@ ...@@ -2204,7 +2342,7 @@
test("local and remote attachment deletions", function () { test("local and remote attachment deletions", function () {
stop(); stop();
expect(9); expect(10);
var id, var id,
context = this, context = this,
...@@ -2228,7 +2366,11 @@ ...@@ -2228,7 +2366,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_NO_CHANGE, id],
[report.LOG_FALSE_CONFLICT_ATTACHMENT, id, 'foo']
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"foo", "foo",
...@@ -2273,7 +2415,7 @@ ...@@ -2273,7 +2415,7 @@
test("local deletion and remote modifications", function () { test("local deletion and remote modifications", function () {
stop(); stop();
expect(3); expect(4);
var id, var id,
context = this, context = this,
...@@ -2298,7 +2440,11 @@ ...@@ -2298,7 +2440,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_NO_CHANGE, id],
[report.LOG_FORCE_PUT_LOCAL_ATTACHMENT, id, 'foo']
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"foo", "foo",
...@@ -2333,7 +2479,7 @@ ...@@ -2333,7 +2479,7 @@
test("local deletion and remote modifications: keep local", function () { test("local deletion and remote modifications: keep local", function () {
stop(); stop();
expect(9); expect(10);
var id, var id,
context = this, context = this,
...@@ -2342,6 +2488,7 @@ ...@@ -2342,6 +2488,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
conflict_handling: 1, conflict_handling: 1,
check_local_attachment_creation: true, check_local_attachment_creation: true,
check_local_attachment_deletion: true, check_local_attachment_deletion: true,
...@@ -2381,7 +2528,11 @@ ...@@ -2381,7 +2528,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_NO_CHANGE, id],
[report.LOG_FORCE_DELETE_REMOTE_ATTACHMENT, id, 'foo']
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"foo", "foo",
...@@ -2427,7 +2578,7 @@ ...@@ -2427,7 +2578,7 @@
test("local deletion and remote modifications: keep local, dont check local", test("local deletion and remote modifications: keep local, dont check local",
function () { function () {
stop(); stop();
expect(9); expect(10);
var id, var id,
context = this, context = this,
...@@ -2436,6 +2587,7 @@ ...@@ -2436,6 +2587,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
conflict_handling: 1, conflict_handling: 1,
check_local_attachment_creation: true, check_local_attachment_creation: true,
check_local_attachment_deletion: false, check_local_attachment_deletion: false,
...@@ -2475,7 +2627,12 @@ ...@@ -2475,7 +2627,12 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_NO_CHANGE, id],
[report.LOG_SKIP_LOCAL_ATTACHMENT_DELETION, id, 'foo'],
[report.LOG_FORCE_DELETE_REMOTE_ATTACHMENT, id, 'foo']
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"foo", "foo",
...@@ -2520,7 +2677,7 @@ ...@@ -2520,7 +2677,7 @@
test("local deletion and remote modifications: keep remote", function () { test("local deletion and remote modifications: keep remote", function () {
stop(); stop();
expect(3); expect(4);
var id, var id,
context = this, context = this,
...@@ -2529,6 +2686,7 @@ ...@@ -2529,6 +2686,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
conflict_handling: 2, conflict_handling: 2,
check_local_attachment_creation: true, check_local_attachment_creation: true,
check_local_attachment_deletion: true, check_local_attachment_deletion: true,
...@@ -2568,7 +2726,11 @@ ...@@ -2568,7 +2726,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_NO_CHANGE, id],
[report.LOG_FORCE_PUT_LOCAL_ATTACHMENT, id, 'foo']
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"foo", "foo",
...@@ -2603,7 +2765,7 @@ ...@@ -2603,7 +2765,7 @@
test("local deletion and remote modifications: ignore", function () { test("local deletion and remote modifications: ignore", function () {
stop(); stop();
expect(5); expect(6);
var id, var id,
context = this, context = this,
...@@ -2612,6 +2774,7 @@ ...@@ -2612,6 +2774,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
conflict_handling: 3, conflict_handling: 3,
check_local_attachment_creation: true, check_local_attachment_creation: true,
check_local_attachment_deletion: true, check_local_attachment_deletion: true,
...@@ -2651,7 +2814,11 @@ ...@@ -2651,7 +2814,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_NO_CHANGE, id],
[report.LOG_SKIP_CONFLICT_ATTACHMENT, id, 'foo']
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"foo", "foo",
...@@ -2688,7 +2855,7 @@ ...@@ -2688,7 +2855,7 @@
test("local modifications and remote deletion", function () { test("local modifications and remote deletion", function () {
stop(); stop();
expect(3); expect(4);
var id, var id,
context = this, context = this,
...@@ -2713,7 +2880,11 @@ ...@@ -2713,7 +2880,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_NO_CHANGE, id],
[report.LOG_PUT_REMOTE_ATTACHMENT, id, 'foo']
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"foo", "foo",
...@@ -2748,7 +2919,7 @@ ...@@ -2748,7 +2919,7 @@
test("local modifications and remote deletion: keep remote", function () { test("local modifications and remote deletion: keep remote", function () {
stop(); stop();
expect(9); expect(10);
var id, var id,
context = this, context = this,
...@@ -2757,6 +2928,7 @@ ...@@ -2757,6 +2928,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
conflict_handling: 2, conflict_handling: 2,
check_local_attachment_creation: true, check_local_attachment_creation: true,
check_local_attachment_deletion: true, check_local_attachment_deletion: true,
...@@ -2795,7 +2967,11 @@ ...@@ -2795,7 +2967,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_NO_CHANGE, id],
[report.LOG_FORCE_DELETE_LOCAL_ATTACHMENT, id, 'foo']
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"foo", "foo",
...@@ -2840,7 +3016,7 @@ ...@@ -2840,7 +3016,7 @@
test("local modifications and remote deletion: keep local", function () { test("local modifications and remote deletion: keep local", function () {
stop(); stop();
expect(3); expect(4);
var id, var id,
context = this, context = this,
...@@ -2849,6 +3025,7 @@ ...@@ -2849,6 +3025,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
conflict_handling: 1, conflict_handling: 1,
check_local_attachment_creation: true, check_local_attachment_creation: true,
check_local_attachment_deletion: true, check_local_attachment_deletion: true,
...@@ -2887,7 +3064,11 @@ ...@@ -2887,7 +3064,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_NO_CHANGE, id],
[report.LOG_FORCE_PUT_REMOTE_ATTACHMENT, id, 'foo']
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"foo", "foo",
...@@ -2922,7 +3103,7 @@ ...@@ -2922,7 +3103,7 @@
test("local modif and remote del: keep remote, not check modif", function () { test("local modif and remote del: keep remote, not check modif", function () {
stop(); stop();
expect(9); expect(10);
var id, var id,
context = this, context = this,
...@@ -2931,6 +3112,7 @@ ...@@ -2931,6 +3112,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
conflict_handling: 2, conflict_handling: 2,
check_local_attachment_creation: true, check_local_attachment_creation: true,
check_local_attachment_deletion: true, check_local_attachment_deletion: true,
...@@ -2969,7 +3151,12 @@ ...@@ -2969,7 +3151,12 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_NO_CHANGE, id],
[report.LOG_SKIP_LOCAL_ATTACHMENT_MODIFICATION, id, 'foo'],
[report.LOG_FORCE_DELETE_LOCAL_ATTACHMENT, id, 'foo']
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"foo", "foo",
...@@ -3014,7 +3201,7 @@ ...@@ -3014,7 +3201,7 @@
test("local modifications and remote deletion: ignore", function () { test("local modifications and remote deletion: ignore", function () {
stop(); stop();
expect(5); expect(6);
var id, var id,
context = this, context = this,
...@@ -3023,6 +3210,7 @@ ...@@ -3023,6 +3210,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
conflict_handling: 3, conflict_handling: 3,
check_local_attachment_creation: true, check_local_attachment_creation: true,
check_local_attachment_deletion: true, check_local_attachment_deletion: true,
...@@ -3061,7 +3249,11 @@ ...@@ -3061,7 +3249,11 @@
.then(function () { .then(function () {
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_NO_CHANGE, id],
[report.LOG_SKIP_CONFLICT_ATTACHMENT, id, 'foo']
]);
return context.jio.getAttachment( return context.jio.getAttachment(
id, id,
"foo", "foo",
...@@ -3289,6 +3481,7 @@ ...@@ -3289,6 +3481,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
check_local_attachment_creation: true, check_local_attachment_creation: true,
local_sub_storage: { local_sub_storage: {
type: "memory" type: "memory"
...@@ -3480,6 +3673,7 @@ ...@@ -3480,6 +3673,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
check_local_attachment_creation: true, check_local_attachment_creation: true,
parallel_operation_attachment_amount: 2, parallel_operation_attachment_amount: 2,
local_sub_storage: { local_sub_storage: {
...@@ -3649,6 +3843,7 @@ ...@@ -3649,6 +3843,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
check_local_attachment_creation: true, check_local_attachment_creation: true,
parallel_operation_attachment_amount: 4, parallel_operation_attachment_amount: 4,
local_sub_storage: { local_sub_storage: {
...@@ -3688,7 +3883,7 @@ ...@@ -3688,7 +3883,7 @@
test("attachment skipped when local document deletion skipped", function () { test("attachment skipped when local document deletion skipped", function () {
stop(); stop();
expect(18); expect(19);
var id, var id,
context = this, context = this,
...@@ -3697,6 +3892,7 @@ ...@@ -3697,6 +3892,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
check_local_deletion: false, check_local_deletion: false,
check_local_attachment_modification: true, check_local_attachment_modification: true,
check_local_attachment_creation: true, check_local_attachment_creation: true,
...@@ -3745,7 +3941,11 @@ ...@@ -3745,7 +3941,11 @@
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_SKIP_LOCAL_DELETION, id],
[report.LOG_NO_CHANGE, id]
]);
ok(true, 'second repair success'); ok(true, 'second repair success');
// local document still deleted // local document still deleted
...@@ -3862,7 +4062,7 @@ ...@@ -3862,7 +4062,7 @@
test("attachment skipped when remot document deletion skipped", function () { test("attachment skipped when remot document deletion skipped", function () {
stop(); stop();
expect(18); expect(19);
var id, var id,
context = this, context = this,
...@@ -3871,6 +4071,7 @@ ...@@ -3871,6 +4071,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
check_remote_deletion: false, check_remote_deletion: false,
check_local_attachment_modification: true, check_local_attachment_modification: true,
check_local_attachment_creation: true, check_local_attachment_creation: true,
...@@ -3916,7 +4117,10 @@ ...@@ -3916,7 +4117,10 @@
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_SKIP_REMOTE_DELETION, id]
]);
ok(true, 'second repair success'); ok(true, 'second repair success');
// remote document still deleted // remote document still deleted
...@@ -4033,7 +4237,7 @@ ...@@ -4033,7 +4237,7 @@
test("att sig deleted when local doc del resolved", function () { test("att sig deleted when local doc del resolved", function () {
stop(); stop();
expect(16); expect(17);
var id, var id,
context = this, context = this,
...@@ -4042,6 +4246,7 @@ ...@@ -4042,6 +4246,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
check_local_attachment_modification: true, check_local_attachment_modification: true,
check_local_attachment_creation: true, check_local_attachment_creation: true,
check_local_attachment_deletion: true, check_local_attachment_deletion: true,
...@@ -4091,7 +4296,13 @@ ...@@ -4091,7 +4296,13 @@
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_FORCE_PUT_LOCAL, id],
[report.LOG_PUT_LOCAL_ATTACHMENT, id, 'foo'],
[report.LOG_PUT_LOCAL_ATTACHMENT, id, 'foomod'],
[report.LOG_PUT_LOCAL_ATTACHMENT, id, 'foocre']
]);
ok(true, 'second repair success'); ok(true, 'second repair success');
// local document recreated // local document recreated
...@@ -4206,7 +4417,7 @@ ...@@ -4206,7 +4417,7 @@
test("att sig deleted when remot doc del resolved", function () { test("att sig deleted when remot doc del resolved", function () {
stop(); stop();
expect(16); expect(17);
var id, var id,
context = this, context = this,
...@@ -4215,6 +4426,7 @@ ...@@ -4215,6 +4426,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
check_local_attachment_modification: true, check_local_attachment_modification: true,
check_local_attachment_creation: true, check_local_attachment_creation: true,
check_local_attachment_deletion: true, check_local_attachment_deletion: true,
...@@ -4260,7 +4472,13 @@ ...@@ -4260,7 +4472,13 @@
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_FORCE_PUT_REMOTE, id],
[report.LOG_PUT_REMOTE_ATTACHMENT, id, 'foo'],
[report.LOG_PUT_REMOTE_ATTACHMENT, id, 'foomod'],
[report.LOG_PUT_REMOTE_ATTACHMENT, id, 'foocre']
]);
ok(true, 'second repair success'); ok(true, 'second repair success');
// remote document recreated // remote document recreated
...@@ -4375,7 +4593,7 @@ ...@@ -4375,7 +4593,7 @@
test("att sig deleted when local not checked doc del resolved", function () { test("att sig deleted when local not checked doc del resolved", function () {
stop(); stop();
expect(16); expect(17);
var id, var id,
context = this, context = this,
...@@ -4384,6 +4602,7 @@ ...@@ -4384,6 +4602,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
check_local_deletion: false, check_local_deletion: false,
check_local_attachment_modification: true, check_local_attachment_modification: true,
check_local_attachment_creation: true, check_local_attachment_creation: true,
...@@ -4434,7 +4653,14 @@ ...@@ -4434,7 +4653,14 @@
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_SKIP_LOCAL_DELETION, id],
[report.LOG_FORCE_PUT_LOCAL, id],
[report.LOG_PUT_LOCAL_ATTACHMENT, id, 'foo'],
[report.LOG_PUT_LOCAL_ATTACHMENT, id, 'foomod'],
[report.LOG_PUT_LOCAL_ATTACHMENT, id, 'foocre']
]);
ok(true, 'second repair success'); ok(true, 'second repair success');
// local document recreated // local document recreated
...@@ -4549,7 +4775,7 @@ ...@@ -4549,7 +4775,7 @@
test("att sig deleted when remot doc not checked del resolved", function () { test("att sig deleted when remot doc not checked del resolved", function () {
stop(); stop();
expect(16); expect(17);
var id, var id,
context = this, context = this,
...@@ -4558,6 +4784,7 @@ ...@@ -4558,6 +4784,7 @@
this.jio = jIO.createJIO({ this.jio = jIO.createJIO({
type: "replicate", type: "replicate",
report_level: 1000,
check_remote_deletion: false, check_remote_deletion: false,
check_local_attachment_modification: true, check_local_attachment_modification: true,
check_local_attachment_creation: true, check_local_attachment_creation: true,
...@@ -4604,7 +4831,13 @@ ...@@ -4604,7 +4831,13 @@
return context.jio.repair(); return context.jio.repair();
}) })
.then(function () { .then(function (report) {
deepEqual(report._list, [
[report.LOG_FORCE_PUT_REMOTE, id],
[report.LOG_PUT_REMOTE_ATTACHMENT, id, 'foo'],
[report.LOG_PUT_REMOTE_ATTACHMENT, id, 'foomod'],
[report.LOG_PUT_REMOTE_ATTACHMENT, id, 'foocre']
]);
ok(true, 'second repair success'); ok(true, 'second repair success');
// remote document recreated // remote document recreated
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment