Return-Path: Delivered-To: apmail-couchdb-commits-archive@www.apache.org Received: (qmail 5977 invoked from network); 11 Jul 2010 17:45:22 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 11 Jul 2010 17:45:22 -0000 Received: (qmail 36583 invoked by uid 500); 11 Jul 2010 17:45:22 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 36478 invoked by uid 500); 11 Jul 2010 17:45:21 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 36471 invoked by uid 99); 11 Jul 2010 17:45:21 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 11 Jul 2010 17:45:21 +0000 X-ASF-Spam-Status: No, hits=-1996.4 required=10.0 tests=ALL_TRUSTED,FS_REPLICA X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 11 Jul 2010 17:45:18 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id BE6B22388A02; Sun, 11 Jul 2010 17:43:55 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r963116 - /couchdb/branches/new_replicator/share/www/script/test/new_replication.js Date: Sun, 11 Jul 2010 17:43:55 -0000 To: commits@couchdb.apache.org From: fdmanana@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100711174355.BE6B22388A02@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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); }