couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fdman...@apache.org
Subject svn commit: r1076569 - /couchdb/trunk/share/www/script/test/replicator_db.js
Date Thu, 03 Mar 2011 09:46:33 GMT
Author: fdmanana
Date: Thu Mar  3 09:46:32 2011
New Revision: 1076569

URL: http://svn.apache.org/viewvc?rev=1076569&view=rev
Log:
Added replicator database compaction test

A test to confirm that ongoing replications are not
stopped when/after the replicator database is compacted.


Modified:
    couchdb/trunk/share/www/script/test/replicator_db.js

Modified: couchdb/trunk/share/www/script/test/replicator_db.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/replicator_db.js?rev=1076569&r1=1076568&r2=1076569&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/test/replicator_db.js (original)
+++ couchdb/trunk/share/www/script/test/replicator_db.js Thu Mar  3 09:46:32 2011
@@ -834,6 +834,69 @@ couchTests.replicator_db = function(debu
   }
 
 
+  function compact_rep_db() {
+    var dbA_copy = new CouchDB("test_suite_rep_db_a_copy");
+    var dbB_copy = new CouchDB("test_suite_rep_db_b_copy");
+    var repDoc1, repDoc2;
+    var xhr, i, doc, copy, new_doc;
+    var docs = makeDocs(1, 50);
+
+    populate_db(dbA, docs);
+    populate_db(dbB, docs);
+    populate_db(dbA_copy, []);
+    populate_db(dbB_copy, []);
+
+    repDoc1 = {
+      _id: "rep1",
+      source: CouchDB.protocol + host + "/" + dbA.name,
+      target: dbA_copy.name,
+      continuous: true
+    };
+    repDoc2 = {
+      _id: "rep2",
+      source: CouchDB.protocol + host + "/" + dbB.name,
+      target: dbB_copy.name,
+      continuous: true
+    };
+
+    TEquals(true, repDb.save(repDoc1).ok);
+    TEquals(true, repDb.save(repDoc2).ok);
+
+    TEquals(true, repDb.compact().ok);
+    TEquals(202, repDb.last_req.status);
+
+    waitForSeq(dbA, dbA_copy);
+    waitForSeq(dbB, dbB_copy);
+
+    while (repDb.info().compact_running) {};
+
+    for (i = 0; i < docs.length; i++) {
+      copy = dbA_copy.open(docs[i]._id);
+      T(copy !== null);
+      copy = dbB_copy.open(docs[i]._id);
+      T(copy !== null);
+    }
+
+    new_doc = {
+      _id: "foo666",
+      value: 666
+    };
+
+    TEquals(true, dbA.save(new_doc).ok);
+    TEquals(true, dbB.save(new_doc).ok);
+
+    waitForSeq(dbA, dbA_copy);
+    waitForSeq(dbB, dbB_copy);
+
+    copy = dbA.open(new_doc._id);
+    T(copy !== null);
+    TEquals(666, copy.value);
+    copy = dbB.open(new_doc._id);
+    T(copy !== null);
+    TEquals(666, copy.value);
+  }
+
+
   function error_state_replication() {
     populate_db(dbA, docs1);
 
@@ -916,6 +979,10 @@ couchTests.replicator_db = function(debu
   restartServer();
   run_on_modified_server(server_config, swap_rep_db);
 
+  repDb.deleteDb();
+  restartServer();
+  run_on_modified_server(server_config, compact_rep_db);
+
 /*
  * Disabled, since error state would be set on the document only after
  * the exponential backoff retry done by the replicator database listener



Mime
View raw message