You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by fd...@apache.org on 2010/07/11 19:43:55 UTC
svn commit: r963116 -
/couchdb/branches/new_replicator/share/www/script/test/new_replication.js
Author: fdmanana
Date: Sun Jul 11 17:43:55 2010
New Revision: 963116
URL: http://svn.apache.org/viewvc?rev=963116&view=rev
Log:
Added more extensive testing to the new replicator's filtered replication.
Modified:
couchdb/branches/new_replicator/share/www/script/test/new_replication.js
Modified: couchdb/branches/new_replicator/share/www/script/test/new_replication.js
URL: http://svn.apache.org/viewvc/couchdb/branches/new_replicator/share/www/script/test/new_replication.js?rev=963116&r1=963115&r2=963116&view=diff
==============================================================================
--- couchdb/branches/new_replicator/share/www/script/test/new_replication.js (original)
+++ couchdb/branches/new_replicator/share/www/script/test/new_replication.js Sun Jul 11 17:43:55 2010
@@ -43,9 +43,11 @@ couchTests.new_replication = function(de
var i, j;
- function populateDb(db, docs) {
- db.deleteDb();
- db.createDb();
+ function populateDb(db, docs, dontRecreateDb) {
+ if (dontRecreateDb !== true) {
+ db.deleteDb();
+ db.createDb();
+ }
for (var i = 0; i < docs.length; i++) {
var doc = docs[i];
delete doc._rev;
@@ -345,6 +347,69 @@ couchTests.new_replication = function(de
T(copy === null);
}
}
+
+ T(repResult.history instanceof Array);
+ T(repResult.history.length === 1);
+ // NOT 31 (31 is db seq for last doc - the ddoc, which was not replicated)
+ T(repResult.source_last_seq === 30);
+ T(repResult.history[0].start_last_seq === 0);
+ T(repResult.history[0].end_last_seq === 30);
+ T(repResult.history[0].recorded_seq === 30);
+ // 16 => 15 docs with even integer field + 1 doc with string field "7"
+ T(repResult.history[0].missing_checked === 16);
+ T(repResult.history[0].missing_found === 16);
+ T(repResult.history[0].docs_read === 16);
+ T(repResult.history[0].docs_written === 16);
+ T(repResult.history[0].doc_write_failures === 0);
+
+
+ // add new docs to source and resume the same replication
+ var newDocs = makeDocs(50, 56);
+ populateDb(sourceDb, newDocs, true);
+
+ repResult = CouchDB.new_replicate(
+ dbPairs[i].source,
+ dbPairs[i].target,
+ {
+ body: {
+ filter: "mydesign/myfilter",
+ query_params: {
+ modulus: 2,
+ special: "7"
+ }
+ }
+ }
+ );
+
+ T(repResult.ok === true);
+
+ for (j = 0; j < newDocs.length; j++) {
+ doc = newDocs[j];
+ copy = targetDb.open(doc._id);
+
+ if (doc.integer && (doc.integer % 2 === 0)) {
+
+ T(copy !== null);
+ for (var p in doc) {
+ T(copy[p] === doc[p]);
+ }
+ } else {
+ T(copy === null);
+ }
+ }
+
+ // last doc has even integer field, so last replicated seq is 36
+ T(repResult.source_last_seq === 36);
+ T(repResult.history instanceof Array);
+ T(repResult.history.length === 2);
+ T(repResult.history[0].start_last_seq === 30);
+ T(repResult.history[0].end_last_seq === 36);
+ T(repResult.history[0].recorded_seq === 36);
+ T(repResult.history[0].missing_checked === 3);
+ T(repResult.history[0].missing_found === 3);
+ T(repResult.history[0].docs_read === 3);
+ T(repResult.history[0].docs_written === 3);
+ T(repResult.history[0].doc_write_failures === 0);
}