couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebastia...@apache.org
Subject couchdb commit: updated refs/heads/2876-js-tests to 2607318
Date Tue, 17 Nov 2015 21:49:24 GMT
Repository: couchdb
Updated Branches:
  refs/heads/2876-js-tests c690cfe15 -> 2607318a6


One more replicator DB test


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/2607318a
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/2607318a
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/2607318a

Branch: refs/heads/2876-js-tests
Commit: 2607318a61a2393dce9702fd0e24edc9998fb03e
Parents: c690cfe
Author: sebastianro <sebastianro@apache.org>
Authored: Tue Nov 17 22:48:01 2015 +0100
Committer: sebastianro <sebastianro@apache.org>
Committed: Tue Nov 17 22:48:01 2015 +0100

----------------------------------------------------------------------
 .../javascript/tests/replicator_db_by_doc_id.js | 62 ++++++++++++++------
 1 file changed, 45 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/2607318a/test/javascript/tests/replicator_db_by_doc_id.js
----------------------------------------------------------------------
diff --git a/test/javascript/tests/replicator_db_by_doc_id.js b/test/javascript/tests/replicator_db_by_doc_id.js
index e460ebd..d9de0f1 100644
--- a/test/javascript/tests/replicator_db_by_doc_id.js
+++ b/test/javascript/tests/replicator_db_by_doc_id.js
@@ -11,15 +11,17 @@
 // the License.
 
 couchTests.replicator_db_by_doc_id = function(debug) {
-  return console.log('TODO');
+  //return console.log('TODO');
 
   if (debug) debugger;
 
   var populate_db = replicator_db.populate_db;
   var docs1 = replicator_db.docs1;
+  // TODO: dice DBs (at least target)
   var dbA = replicator_db.dbA;
   var dbB = replicator_db.dbB;
-  var repDb = replicator_db.repDb;
+  //var repDb = replicator_db.repDb;
+  var replDb = new CouchDB("_replicator");
   var wait = replicator_db.wait;
   var waitForRep = replicator_db.waitForRep;
   var waitForSeq = replicator_db.waitForSeq;
@@ -39,12 +41,13 @@ couchTests.replicator_db_by_doc_id = function(debug) {
     var repDoc = {
       _id: "foo_cont_rep_doc",
       source: "http://" + CouchDB.host + "/" + dbA.name,
-      target: dbB.name,
+      // TODO: fix DB name issue and remove absolute URL again
+      target: 'http://localhost:15984/' + dbB.name,
       doc_ids: ["foo666", "foo3", "_design/mydesign", "foo999", "foo1"]
     };
-    T(repDb.save(repDoc).ok);
+    T(replDb.save(repDoc).ok);
 
-    waitForRep(repDb, repDoc, "completed");
+    waitForRep(replDb, repDoc, "completed");
     var copy = dbB.open("foo1");
     T(copy !== null);
     T(copy.value === 11);
@@ -63,21 +66,22 @@ couchTests.replicator_db_by_doc_id = function(debug) {
     T(copy === null);
 
     copy = dbB.open("_design/mydesign");
-    T(copy === null);
+    // TODO: recheck - but I believe this should be in the target! (see also #written below)
+    T(copy !== null);
 
-    repDoc = repDb.open(repDoc._id);
+    repDoc = replDb.open(repDoc._id);
     T(typeof repDoc._replication_stats === "object", "doc has stats");
     var stats = repDoc._replication_stats;
     TEquals(3, stats.revisions_checked, "right # of revisions_checked");
     TEquals(3, stats.missing_revisions_found, "right # of missing_revisions_found");
     TEquals(3, stats.docs_read, "right # of docs_read");
-    TEquals(2, stats.docs_written, "right # of docs_written");
-    TEquals(1, stats.doc_write_failures, "right # of doc_write_failures");
-    TEquals(dbA.info().update_seq, stats.checkpointed_source_seq,
-      "right checkpointed_source_seq");
+    TEquals(3, stats.docs_written, "right # of docs_written");
+    TEquals(0, stats.doc_write_failures, "right # of doc_write_failures");
+    // sequences are no more meaningful in a cluster
+    //TEquals(dbA.info().update_seq, stats.checkpointed_source_seq, "right checkpointed_source_seq");
   }
 
-  var server_config = [
+  /*var server_config = [
     {
       section: "couch_httpd_auth",
       key: "iterations",
@@ -88,13 +92,37 @@ couchTests.replicator_db_by_doc_id = function(debug) {
       key: "db",
       value: repDb.name
     }
-  ];
+  ];*/
+
+  //repDb.deleteDb();
+  // don't run on modified server as it would be strange on cluster
+  // but use "normal" replication DB, create a doc, reliably clear after run
+  // on delete fail, the next tests would all fail
+  function handleReplDoc(show) {
+    var replDoc = replDb.open("foo_cont_rep_doc");
+    if(replDoc!=null) {
+      if(show) {
+        //console.log(JSON.stringify(replDoc));
+      }
+      replDb.deleteDoc(replDoc);
+    }
+  }
 
-  repDb.deleteDb();
-  run_on_modified_server(server_config, by_doc_ids_replication);
+  handleReplDoc();
+  try {
+    by_doc_ids_replication();
+  } finally {
+    // cleanup or log
+    try {
+      handleReplDoc(true);
+    } catch (e2) {
+      console.log("Error during cleanup " + e2);
+    }
+  }
+  //run_on_modified_server(server_config, by_doc_ids_replication);
 
   // cleanup
-  repDb.deleteDb();
+  //repDb.deleteDb();
   dbA.deleteDb();
   dbB.deleteDb();
-}
\ No newline at end of file
+}


Mime
View raw message