couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject [05/50] couchdb commit: updated refs/heads/master to e8e03b6
Date Wed, 16 Dec 2015 21:15:06 GMT
JS test: update replicator_db_bad_rep_id.js for 2.0


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

Branch: refs/heads/master
Commit: 2ea17e47ce7ede2976c6c03deb8f32b59130405b
Parents: 8576a1d
Author: Jan Lehnardt <jan@apache.org>
Authored: Wed Dec 16 20:49:31 2015 +0100
Committer: Jan Lehnardt <jan@apache.org>
Committed: Wed Dec 16 20:49:31 2015 +0100

----------------------------------------------------------------------
 .../tests/replicator_db_bad_rep_id.js           | 55 +++++++++++++++-----
 1 file changed, 41 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/2ea17e47/test/javascript/tests/replicator_db_bad_rep_id.js
----------------------------------------------------------------------
diff --git a/test/javascript/tests/replicator_db_bad_rep_id.js b/test/javascript/tests/replicator_db_bad_rep_id.js
index 285b863..529bbaa 100644
--- a/test/javascript/tests/replicator_db_bad_rep_id.js
+++ b/test/javascript/tests/replicator_db_bad_rep_id.js
@@ -11,14 +11,16 @@
 // the License.
 
 couchTests.replicator_db_bad_rep_id = function(debug) {
-
+  //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;
@@ -29,13 +31,14 @@ couchTests.replicator_db_bad_rep_id = function(debug) {
 
     var repDoc = {
       _id: "foo_rep",
-      source: dbA.name,
-      target: dbB.name,
+// TODO: fix DB name issue and remove absolute URL again
+      source: 'http://localhost:15984/'+dbA.name,
+      target: 'http://localhost:15984/'+dbB.name,
       replication_id: "1234abc"
     };
-    T(repDb.save(repDoc).ok);
+    T(replDb.save(repDoc).ok);
 
-    waitForRep(repDb, repDoc, "completed");
+    T(waitForRep(replDb, repDoc, "completed", "error") == "completed");
     for (var i = 0; i < docs1.length; i++) {
       var doc = docs1[i];
       var copy = dbB.open(doc._id);
@@ -43,7 +46,7 @@ couchTests.replicator_db_bad_rep_id = function(debug) {
       T(copy.value === doc.value);
     }
 
-    var repDoc1 = repDb.open(repDoc._id);
+    var repDoc1 = replDb.open(repDoc._id);
     T(repDoc1 !== null);
     T(repDoc1.source === repDoc.source);
     T(repDoc1.target === repDoc.target);
@@ -54,7 +57,7 @@ couchTests.replicator_db_bad_rep_id = function(debug) {
     T(repDoc1._replication_id !== "1234abc");
   }
 
-  var server_config = [
+  /*var server_config = [
     {
       section: "couch_httpd_auth",
       key: "iterations",
@@ -63,15 +66,39 @@ couchTests.replicator_db_bad_rep_id = function(debug) {
     {
       section: "replicator",
       key: "db",
-      value: repDb.name
+      value: null //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_rep");
+    if(replDoc!=null) {
+      if(show) {
+        //console.log(JSON.stringify(replDoc));
+      }
+      replDb.deleteDoc(replDoc);
     }
-  ];
+  }
 
-  repDb.deleteDb();
-  run_on_modified_server(server_config, rep_doc_with_bad_rep_id);
+  handleReplDoc();
+  try {
+    rep_doc_with_bad_rep_id();
+  } finally {
+    // cleanup or log
+    try {
+      handleReplDoc(true);
+    } catch (e2) {
+      console.log("Error during cleanup " + e2);
+    }
+  }
+  //run_on_modified_server(server_config, rep_doc_with_bad_rep_id);
 
   // cleanup
-  repDb.deleteDb();
+  //repDb.deleteDb();
   dbA.deleteDb();
   dbB.deleteDb();
-}
\ No newline at end of file
+}


Mime
View raw message