couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kxe...@apache.org
Subject [09/12] couchdb commit: updated refs/heads/2876-js-tests to def9465
Date Thu, 12 Nov 2015 21:23:47 GMT
Initial solutions for cluster testing


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

Branch: refs/heads/2876-js-tests
Commit: d8408834b726174c4127614ee32ef86551bfa8b4
Parents: 01913cf
Author: sebastianro <sebastianro@apache.org>
Authored: Thu Nov 5 23:04:42 2015 +0100
Committer: sebastianro <sebastianro@apache.org>
Committed: Thu Nov 12 21:56:05 2015 +0100

----------------------------------------------------------------------
 rel/overlay/etc/default.ini                     |  3 ++
 test/javascript/replicator_db_inc.js            |  7 +--
 .../tests/replicator_db_bad_rep_id.js           | 50 +++++++++++++++-----
 3 files changed, 45 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/d8408834/rel/overlay/etc/default.ini
----------------------------------------------------------------------
diff --git a/rel/overlay/etc/default.ini b/rel/overlay/etc/default.ini
index bcababc..8faa1b9 100644
--- a/rel/overlay/etc/default.ini
+++ b/rel/overlay/etc/default.ini
@@ -299,6 +299,9 @@ verify_ssl_certificates = false
 ;ssl_trusted_certificates_file = /etc/ssl/certs/ca-certificates.crt
 ; Maximum peer certificate depth (must be set even if certificate validation is off).
 ssl_certificate_max_depth = 3
+; improve testing
+start_delay=0
+start_splay=1
 
 [compaction_daemon]
 ; The delay, in seconds, between each check for which database and view indexes

http://git-wip-us.apache.org/repos/asf/couchdb/blob/d8408834/test/javascript/replicator_db_inc.js
----------------------------------------------------------------------
diff --git a/test/javascript/replicator_db_inc.js b/test/javascript/replicator_db_inc.js
index 23f8587..46dcdd7 100644
--- a/test/javascript/replicator_db_inc.js
+++ b/test/javascript/replicator_db_inc.js
@@ -32,7 +32,7 @@ replicator_db.docs1 = [
   }
 ];
 
-replicator_db.waitForRep = function waitForSeq(repDb, repDoc, state) {
+replicator_db.waitForRep = function waitForSeq(repDb, repDoc, state, errorState) {
   var newRep,
       t0 = new Date(),
       t1,
@@ -41,7 +41,8 @@ replicator_db.waitForRep = function waitForSeq(repDb, repDoc, state) {
   do {
     newRep = repDb.open(repDoc._id);
     t1 = new Date();
-  } while (((t1 - t0) <= ms) && newRep._replication_state !== state);
+  } while (((t1 - t0) <= ms) && newRep._replication_state !== state &&
(!errorState || newRep._replication_state !== errorState));
+  return newRep ? newRep._replication_state : null;
 }
 
 replicator_db.waitForSeq = function waitForSeq(sourceDb, targetDb) {
@@ -93,4 +94,4 @@ replicator_db.populate_db = function populate_db(db, docs) {
     delete d._rev;
     T(db.save(d).ok);
   }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/couchdb/blob/d8408834/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 8f57eb0..0c064c3 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');
+  //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;
@@ -33,9 +35,9 @@ couchTests.replicator_db_bad_rep_id = function(debug) {
       target: 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 +45,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 +56,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 +65,39 @@ couchTests.replicator_db_bad_rep_id = function(debug) {
     {
       section: "replicator",
       key: "db",
-      value: repDb.name
+      value: null //repDb.name
     }
-  ];
+  ];*/
 
-  repDb.deleteDb();
-  run_on_modified_server(server_config, rep_doc_with_bad_rep_id);
+  //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);
+    }
+  }
+
+  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