summaryrefslogtreecommitdiff
path: root/share/www/script/test/replication.js
diff options
context:
space:
mode:
authorJohn Christopher Anderson <jchris@apache.org>2009-03-13 22:15:34 +0000
committerJohn Christopher Anderson <jchris@apache.org>2009-03-13 22:15:34 +0000
commit9007e2d21dea8b0185c0096b30364a8ee40a3867 (patch)
tree7d8dacb2c8cd619f18dfab8fdb40d146ac28c85a /share/www/script/test/replication.js
parent65608e14e8911b33c30178d717d745edc9f66c17 (diff)
Commit Damien's rep_security branch to trunk.
Changes bulk_docs conflict checking. Breaks file format, see mailing list for data upgrade procedure, or http://wiki.apache.org/couchdb/Breaking_changes git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@753448 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'share/www/script/test/replication.js')
-rw-r--r--share/www/script/test/replication.js41
1 files changed, 34 insertions, 7 deletions
diff --git a/share/www/script/test/replication.js b/share/www/script/test/replication.js
index 59dc4700..944c8e47 100644
--- a/share/www/script/test/replication.js
+++ b/share/www/script/test/replication.js
@@ -59,7 +59,7 @@ couchTests.replication = function(debug) {
simple_test: new function () {
this.init = function(dbA, dbB) {
var docs = makeDocs(0, numDocs);
- T(dbA.bulkSave(docs).ok);
+ dbA.bulkSave(docs);
};
this.afterAB1 = function(dbA, dbB) {
@@ -160,7 +160,7 @@ couchTests.replication = function(debug) {
dbA.deleteDoc({_id:"foo", _rev:docA._conflicts[0]});
};
- this.afterBA2 = function(dbA, dbB) {
+ this.afterBA2 = function(dbA, dbB) {
// open documents and include the conflict meta data
var docA = dbA.open("foo", {conflicts: true});
var docB = dbB.open("foo", {conflicts: true});
@@ -179,29 +179,56 @@ couchTests.replication = function(debug) {
}
}
- T(CouchDB.replicate(A, B).ok);
+ var result = CouchDB.replicate(A, B);
+
+ var seqA = result.source_last_seq;
+ T(0 == result.history[0].start_last_seq);
+ T(result.history[1] === undefined)
for(test in repTests) {
if(repTests[test].afterAB1) repTests[test].afterAB1(dbA, dbB);
}
- T(CouchDB.replicate(B, A).ok);
+ result = CouchDB.replicate(B, A);
+
+ var seqB = result.source_last_seq;
+ T(0 == result.history[0].start_last_seq);
+ T(result.history[1] === undefined)
for(test in repTests) {
if(repTests[test].afterBA1) repTests[test].afterBA1(dbA, dbB);
}
- T(CouchDB.replicate(A, B).ok);
+ var result2 = CouchDB.replicate(A, B);
+
+ // each successful replication produces a new session id
+ T(result2.session_id != result.session_id);
+
+ T(seqA < result2.source_last_seq);
+ T(seqA == result2.history[0].start_last_seq);
+ T(result2.history[1].end_last_seq == seqA)
+
+ seqA = result2.source_last_seq;
for(test in repTests) {
if(repTests[test].afterAB2) repTests[test].afterAB2(dbA, dbB);
}
- T(CouchDB.replicate(B, A).ok);
+ result = CouchDB.replicate(B, A)
+
+ T(seqB < result.source_last_seq);
+ T(seqB == result.history[0].start_last_seq);
+ T(result.history[1].end_last_seq == seqB)
+
+ seqB = result.source_last_seq;
for(test in repTests) {
if(repTests[test].afterBA2) repTests[test].afterBA2(dbA, dbB);
}
-
+
+ // do an replication where nothing has changed
+ result2 = CouchDB.replicate(B, A);
+ T(result2.no_changes == true);
+ T(result2.session_id == result.session_id);
}
};