You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ja...@apache.org on 2016/04/25 13:53:34 UTC

[6/9] couchdb commit: updated refs/heads/test4th to 01edf89

Make sure we have random DB names all around including replication test and stabilize show_documents


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

Branch: refs/heads/test4th
Commit: a87ac58e7103d59075dbcc4475baffe54b49abe5
Parents: 6c4f3d9
Author: sebastianro <se...@apache.org>
Authored: Thu Apr 21 16:21:47 2016 +0200
Committer: sebastianro <se...@apache.org>
Committed: Sat Apr 23 19:23:43 2016 +0200

----------------------------------------------------------------------
 test/javascript/tests/bulk_docs.js           |   5 +-
 test/javascript/tests/design_docs.js         |   3 +
 test/javascript/tests/etags_views.js         |   4 +-
 test/javascript/tests/reader_acl.js          |  12 +-
 test/javascript/tests/recreate_doc.js        |   3 +
 test/javascript/tests/replication.js         | 260 ++++++++++++----------
 test/javascript/tests/security_validation.js |   5 +-
 test/javascript/tests/show_documents.js      |  10 +-
 test/javascript/tests/view_offsets.js        |   9 +-
 test/javascript/tests/view_sandboxing.js     |   3 +
 10 files changed, 178 insertions(+), 136 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/a87ac58e/test/javascript/tests/bulk_docs.js
----------------------------------------------------------------------
diff --git a/test/javascript/tests/bulk_docs.js b/test/javascript/tests/bulk_docs.js
index 7fc93fd..b9e9716 100644
--- a/test/javascript/tests/bulk_docs.js
+++ b/test/javascript/tests/bulk_docs.js
@@ -11,7 +11,7 @@
 // the License.
 
 couchTests.bulk_docs = function(debug) {
-  var db_name = get_random_db_name()
+  var db_name = get_random_db_name();
   var db = new CouchDB(db_name, {"X-Couch-Full-Commit":"false"});
   db.createDb();
   if (debug) debugger;
@@ -112,6 +112,9 @@ couchTests.bulk_docs = function(debug) {
 
   // jira-911
   db.deleteDb();
+  // avoid Heisenbugs w/ files remaining - create a new name
+  db_name = get_random_db_name();
+  db = new CouchDB(db_name, {"X-Couch-Full-Commit":"false"});
   db.createDb();
   docs = [];
   docs.push({"_id":"0", "a" : 0});

http://git-wip-us.apache.org/repos/asf/couchdb/blob/a87ac58e/test/javascript/tests/design_docs.js
----------------------------------------------------------------------
diff --git a/test/javascript/tests/design_docs.js b/test/javascript/tests/design_docs.js
index 6c46437..ab62f3f 100644
--- a/test/javascript/tests/design_docs.js
+++ b/test/javascript/tests/design_docs.js
@@ -428,6 +428,9 @@ couchTests.design_docs = function(debug) {
   // field with the boolean value true, its validate_doc_update functions
   // should no longer have effect.
   db.deleteDb();
+  // avoid Heisenbugs w/ files remaining - create a new name
+  db_name = get_random_db_name();
+  db = new CouchDB(db_name, {"X-Couch-Full-Commit":"false"});
   db.createDb();
   var ddoc = {
     _id: "_design/test",

http://git-wip-us.apache.org/repos/asf/couchdb/blob/a87ac58e/test/javascript/tests/etags_views.js
----------------------------------------------------------------------
diff --git a/test/javascript/tests/etags_views.js b/test/javascript/tests/etags_views.js
index bed98ed..6c110f8 100644
--- a/test/javascript/tests/etags_views.js
+++ b/test/javascript/tests/etags_views.js
@@ -204,12 +204,12 @@ couchTests.etags_views = function(debug) {
   
   // A new database should have unique _all_docs etags. 
   db.deleteDb(); 
-  db.createDb(); 
+  db.createDb(); // TODO: when re-activating try having a new DB name
   db.save({a: 1}); 
   xhr = CouchDB.request("GET", "/" + db_name + "/_all_docs"); 
   var etag = xhr.getResponseHeader("etag"); 
   db.deleteDb(); 
-  db.createDb(); 
+  db.createDb(); // TODO: when re-activating try having a new DB name
   db.save({a: 2}); 
   xhr = CouchDB.request("GET", "/" + db_name + "/_all_docs"); 
   var new_etag = xhr.getResponseHeader("etag");

http://git-wip-us.apache.org/repos/asf/couchdb/blob/a87ac58e/test/javascript/tests/reader_acl.js
----------------------------------------------------------------------
diff --git a/test/javascript/tests/reader_acl.js b/test/javascript/tests/reader_acl.js
index a76f280..876446e 100644
--- a/test/javascript/tests/reader_acl.js
+++ b/test/javascript/tests/reader_acl.js
@@ -113,10 +113,10 @@ couchTests.reader_acl = function(debug) {
       // server _admin can always read
       T(secretDb.open("baz").foo == "bar");
 
-      // and run temp views
-      TEquals(secretDb.query(function(doc) {
+      // and run temp views - they don't exist any more, so leave out
+      /*TEquals(secretDb.query(function(doc) {
         emit(null, null)
-      }).total_rows, 1);
+      }).total_rows, 1);*/
 
       T(secretDb.save({
         "_id" : "_design/foo",
@@ -134,15 +134,15 @@ couchTests.reader_acl = function(debug) {
       // members can query stored views
       T(secretDb.view("foo/bar").total_rows == 1);
       
-      // members can't do temp views
-      try {
+      // members can't do temp views - they don't exist any more, so leave out
+      /*try {
         var results = secretDb.query(function(doc) {
           emit(null, null);
         });
         T(false && "temp view should be admin only");
       } catch (e) {
         T(true && "temp view is admin only");
-      }
+      }*/
       
       CouchDB.logout();
 

http://git-wip-us.apache.org/repos/asf/couchdb/blob/a87ac58e/test/javascript/tests/recreate_doc.js
----------------------------------------------------------------------
diff --git a/test/javascript/tests/recreate_doc.js b/test/javascript/tests/recreate_doc.js
index ea7916f..154a6e4 100644
--- a/test/javascript/tests/recreate_doc.js
+++ b/test/javascript/tests/recreate_doc.js
@@ -79,6 +79,9 @@ couchTests.recreate_doc = function(debug) {
   }
 
   db.deleteDb();
+  // avoid Heisenbugs - have a new name
+  db_name = get_random_db_name();
+  db = new CouchDB(db_name, {"X-Couch-Full-Commit":"false"}, {"w": 3});
   db.createDb();
 
   // Helper function to create a doc with multiple revisions

http://git-wip-us.apache.org/repos/asf/couchdb/blob/a87ac58e/test/javascript/tests/replication.js
----------------------------------------------------------------------
diff --git a/test/javascript/tests/replication.js b/test/javascript/tests/replication.js
index 1a26889..b758b4f 100644
--- a/test/javascript/tests/replication.js
+++ b/test/javascript/tests/replication.js
@@ -15,25 +15,27 @@ couchTests.replication = function(debug) {
   if (debug) debugger;
 
   var host = CouchDB.host;
-  var sourceDb = new CouchDB("test_suite_db_a",{"X-Couch-Full-Commit":"false"});
-  var targetDb = new CouchDB("test_suite_db_b",{"X-Couch-Full-Commit":"false"});
+  // as we change names during execution, do NOT use test_suite_db or a 
+  // pre-computed value like ''+sourceDb.name (compute only on use)
+  var sourceDb;
+  var targetDb;
 
-  var dbPairs = [
+  var dbPairsPrefixes = [
     {
-      source: sourceDb.name,
-      target: targetDb.name
+      source: "",
+      target: ""
     },
     {
-      source: CouchDB.protocol + host + "/" + sourceDb.name,
-      target: targetDb.name
+      source: CouchDB.protocol + host + "/",
+      target: ""
     },
     {
-      source: sourceDb.name,
-      target: CouchDB.protocol + host + "/" + targetDb.name
+      source: "",
+      target: CouchDB.protocol + host + "/"
     },
     {
-      source: CouchDB.protocol + host + "/" + sourceDb.name,
-      target: CouchDB.protocol + host + "/" + targetDb.name
+      source: CouchDB.protocol + host + "/",
+      target: CouchDB.protocol + host + "/"
     }
   ];
 
@@ -124,17 +126,36 @@ couchTests.replication = function(debug) {
   }
 
 
-  function populateDb(db, docs, dontRecreateDb) {
-    if (dontRecreateDb !== true) {
-      db.deleteDb();
-      db.createDb();
+  function populateSourceDb(docs, dontRecreateDb) {
+    if(dontRecreateDb !== true) {
+      if(sourceDb) {
+        sourceDb.deleteDb();
+      }
+      sourceDb = new CouchDB(get_random_db_name() + "_src",{"X-Couch-Full-Commit":"false"});
+      sourceDb.createDb(); 
+    }
+    for (var i = 0; i < docs.length; i++) {
+      var doc = docs[i];
+      delete doc._rev;
+    }
+    if (docs.length > 0) {
+      sourceDb.bulkSave(docs);
+    }
+  }
+  function populateTargetDb(docs, dontRecreateDb) {
+    if(dontRecreateDb !== true) {
+      if(targetDb) {
+        targetDb.deleteDb();
+      }
+      targetDb = new CouchDB(get_random_db_name() + "_tgt",{"X-Couch-Full-Commit":"false"});
+      targetDb.createDb();
     }
     for (var i = 0; i < docs.length; i++) {
       var doc = docs[i];
       delete doc._rev;
     }
     if (docs.length > 0) {
-      db.bulkSave(docs);
+      targetDb.bulkSave(docs);
     }
   }
 
@@ -221,16 +242,16 @@ couchTests.replication = function(debug) {
     value: "ddoc"
   });
 
-  for (i = 0; i < dbPairs.length; i++) {
-    populateDb(sourceDb, docs);
-    populateDb(targetDb, []);
+  for (i = 0; i < dbPairsPrefixes.length; i++) {
+    populateSourceDb(docs);
+    populateTargetDb([]);
 
     // add some attachments
     for (j = 10; j < 15; j++) {
       addAtt(sourceDb, docs[j], "readme.txt", att1_data, "text/plain");
     }
 
-    repResult = CouchDB.replicate(dbPairs[i].source, dbPairs[i].target);
+    repResult = CouchDB.replicate(dbPairsPrefixes[i].source+sourceDb.name, dbPairsPrefixes[i].target+targetDb.name);
     TEquals(true, repResult.ok);
 
     sourceInfo = sourceDb.info();
@@ -293,7 +314,7 @@ couchTests.replication = function(debug) {
       addAtt(sourceDb, docs[j], "data.dat", att2_data, "application/binary");
     }
 
-    repResult = CouchDB.replicate(dbPairs[i].source, dbPairs[i].target);
+    repResult = CouchDB.replicate(dbPairsPrefixes[i].source+sourceDb.name, dbPairsPrefixes[i].target+targetDb.name);
     TEquals(true, repResult.ok);
 
     sourceInfo = sourceDb.info();
@@ -360,7 +381,7 @@ couchTests.replication = function(debug) {
     doc = sourceDb.open(docs[1]._id);
     TEquals(true, sourceDb.deleteDoc(doc).ok);
 
-    repResult = CouchDB.replicate(dbPairs[i].source, dbPairs[i].target);
+    repResult = CouchDB.replicate(dbPairsPrefixes[i].source+sourceDb.name, dbPairsPrefixes[i].target+targetDb.name);
     TEquals(true, repResult.ok);
 
     sourceInfo = sourceDb.info();
@@ -403,7 +424,7 @@ couchTests.replication = function(debug) {
     copy.value = "black";
     TEquals(true, targetDb.save(copy).ok);
 
-    repResult = CouchDB.replicate(dbPairs[i].source, dbPairs[i].target);
+    repResult = CouchDB.replicate(dbPairsPrefixes[i].source+sourceDb.name, dbPairsPrefixes[i].target+targetDb.name);
     TEquals(true, repResult.ok);
 
     sourceInfo = sourceDb.info();
@@ -434,7 +455,7 @@ couchTests.replication = function(debug) {
     doc.value = "yellow";
     TEquals(true, sourceDb.save(doc).ok);
 
-    repResult = CouchDB.replicate(dbPairs[i].source, dbPairs[i].target);
+    repResult = CouchDB.replicate(dbPairsPrefixes[i].source+sourceDb.name, dbPairsPrefixes[i].target+targetDb.name);
     TEquals(true, repResult.ok);
 
     sourceInfo = sourceDb.info();
@@ -468,7 +489,7 @@ couchTests.replication = function(debug) {
     doc.value = "rainbow";
     TEquals(true, sourceDb.save(doc).ok);
 
-    repResult = CouchDB.replicate(dbPairs[i].source, dbPairs[i].target);
+    repResult = CouchDB.replicate(dbPairsPrefixes[i].source+sourceDb.name, dbPairsPrefixes[i].target+targetDb.name);
     TEquals(true, repResult.ok);
 
     sourceInfo = sourceDb.info();
@@ -500,7 +521,7 @@ couchTests.replication = function(debug) {
     TEquals(true, sourceDb.save({_id: "foo3", value: 333}).ok);
     TEquals(true, targetDb.save({_id: "foo3", value: 333}).ok);
 
-    repResult = CouchDB.replicate(dbPairs[i].source, dbPairs[i].target);
+    repResult = CouchDB.replicate(dbPairsPrefixes[i].source+sourceDb.name, dbPairsPrefixes[i].target+targetDb.name);
     TEquals(true, repResult.ok);
 
     sourceInfo = sourceDb.info();
@@ -520,7 +541,7 @@ couchTests.replication = function(debug) {
     TEquals(true, sourceDb.save({_id: "foo5", value: 555}).ok);
     TEquals(true, targetDb.save({_id: "foo5", value: 555}).ok);
 
-    repResult = CouchDB.replicate(dbPairs[i].source, dbPairs[i].target);
+    repResult = CouchDB.replicate(dbPairsPrefixes[i].source+sourceDb.name, dbPairsPrefixes[i].target+targetDb.name);
     TEquals(true, repResult.ok);
 
     sourceInfo = sourceDb.info();
@@ -535,7 +556,7 @@ couchTests.replication = function(debug) {
     TEquals(0, repResult.history[0].docs_written);
     TEquals(0, repResult.history[0].doc_write_failures);
 
-    repResult = CouchDB.replicate(dbPairs[i].source, dbPairs[i].target);
+    repResult = CouchDB.replicate(dbPairsPrefixes[i].source+sourceDb.name, dbPairsPrefixes[i].target+targetDb.name);
     TEquals(true, repResult.ok);
     TEquals(true, repResult.no_changes);
     sourceInfo = sourceDb.info();
@@ -571,9 +592,9 @@ couchTests.replication = function(debug) {
   // test since_seq parameter
   docs = makeDocs(1, 6);
 
-  for (i = 0; i < dbPairs.length; i++) {
-    populateDb(sourceDb, docs);
-    populateDb(targetDb, []);
+  for (i = 0; i < dbPairsPrefixes.length; i++) {
+    populateSourceDb(docs);
+    populateTargetDb([]);
     // sequences are no longer simple numbers - so pull #3 from a feed
     var since_seq = sourceDb.changes().results[2].seq;
 
@@ -590,8 +611,8 @@ couchTests.replication = function(debug) {
     // effect.
     try {
       CouchDB.replicate(
-        dbPairs[i].source,
-        dbPairs[i].target,
+        dbPairsPrefixes[i].source+sourceDb.name,
+        dbPairsPrefixes[i].target+targetDb.name,
         {body: {cancel: true}}
       );
     } catch (x) {
@@ -599,8 +620,8 @@ couchTests.replication = function(debug) {
       TEquals("not_found", x.error);
     }
     repResult = CouchDB.replicate(
-      dbPairs[i].source,
-      dbPairs[i].target,
+      dbPairsPrefixes[i].source+sourceDb.name,
+      dbPairsPrefixes[i].target+targetDb.name,
       {body: {since_seq: since_seq}}
     );
     // Same reason as before. But here we don't want since_seq to affect
@@ -608,8 +629,8 @@ couchTests.replication = function(debug) {
     // supervisor (since_seq is not used to calculate the replication ID).
     try {
       CouchDB.replicate(
-        dbPairs[i].source,
-        dbPairs[i].target,
+        dbPairsPrefixes[i].source+sourceDb.name,
+        dbPairsPrefixes[i].target+targetDb.name,
         {body: {cancel: true}}
       );
     } catch (x) {
@@ -655,13 +676,13 @@ couchTests.replication = function(debug) {
     }).toString()
   };
 
-  for (i = 0; i < dbPairs.length; i++) {
-    populateDb(sourceDb, docs);
-    populateDb(targetDb, [ddoc]);
+  for (i = 0; i < dbPairsPrefixes.length; i++) {
+    populateSourceDb(docs);
+    populateTargetDb([ddoc]);
 
     repResult = CouchDB.replicate(
-      dbPairs[i].source,
-      dbPairs[i].target
+      dbPairsPrefixes[i].source+sourceDb.name,
+      dbPairsPrefixes[i].target+targetDb.name
     );
     TEquals(true, repResult.ok);
     TEquals(7, repResult.history[0].missing_checked);
@@ -687,13 +708,13 @@ couchTests.replication = function(debug) {
   // test create_target option
   docs = makeDocs(1, 2);
 
-  for (i = 0; i < dbPairs.length; i++) {
-    populateDb(sourceDb, docs);
+  for (i = 0; i < dbPairsPrefixes.length; i++) {
+    populateSourceDb(docs);
     targetDb.deleteDb();
 
     repResult = CouchDB.replicate(
-      dbPairs[i].source,
-      dbPairs[i].target,
+      dbPairsPrefixes[i].source+sourceDb.name,
+      dbPairsPrefixes[i].target+targetDb.name,
       {body: {create_target: true}}
     );
     TEquals(true, repResult.ok);
@@ -720,13 +741,13 @@ couchTests.replication = function(debug) {
     }
   });
 
-  for (i = 0; i < dbPairs.length; i++) {
-    populateDb(sourceDb, docs);
-    populateDb(targetDb, []);
+  for (i = 0; i < dbPairsPrefixes.length; i++) {
+    populateSourceDb(docs);
+    populateTargetDb([]);
 
     repResult = CouchDB.replicate(
-      dbPairs[i].source,
-      dbPairs[i].target,
+      dbPairsPrefixes[i].source+sourceDb.name,
+      dbPairsPrefixes[i].target+targetDb.name,
       {
         body: {
           filter: "mydesign/myfilter",
@@ -787,11 +808,11 @@ couchTests.replication = function(debug) {
 
     // add new docs to source and resume the same replication
     var newDocs = makeDocs(50, 56);
-    populateDb(sourceDb, newDocs, true);
+    populateSourceDb(newDocs, true);
 
     repResult = CouchDB.replicate(
-      dbPairs[i].source,
-      dbPairs[i].target,
+      dbPairsPrefixes[i].source+sourceDb.name,
+      dbPairsPrefixes[i].target+targetDb.name,
       {
         body: {
           filter: "mydesign/myfilter",
@@ -848,9 +869,9 @@ couchTests.replication = function(debug) {
     return true;
   }).toString();
 
-  for (i = 0; i < dbPairs.length; i++) {
-    populateDb(targetDb, []);
-    populateDb(sourceDb, []);
+  for (i = 0; i < dbPairsPrefixes.length; i++) {
+    populateTargetDb([]);
+    populateSourceDb([]);
 
     TEquals(true, sourceDb.save({_id: "foo1", value: 1}).ok);
     TEquals(true, sourceDb.save({_id: "foo2", value: 2}).ok);
@@ -868,8 +889,8 @@ couchTests.replication = function(debug) {
     TEquals(true, sourceDb.save(ddoc).ok);
 
     repResult = CouchDB.replicate(
-      dbPairs[i].source,
-      dbPairs[i].target,
+      dbPairsPrefixes[i].source+sourceDb.name,
+      dbPairsPrefixes[i].target+targetDb.name,
       {
         body: {
           filter: "mydesign/myfilter",
@@ -907,8 +928,8 @@ couchTests.replication = function(debug) {
     TEquals(true, sourceDb.save(ddoc).ok);
 
     repResult = CouchDB.replicate(
-      dbPairs[i].source,
-      dbPairs[i].target,
+      dbPairsPrefixes[i].source+sourceDb.name,
+      dbPairsPrefixes[i].target+targetDb.name,
       {
         body: {
           filter: "mydesign/myfilter",
@@ -966,7 +987,7 @@ couchTests.replication = function(debug) {
   var id, num_inexistent_docs, after_num_inexistent_docs;
   var total, after_total;
 
-  for (i = 0; i < dbPairs.length; i++) {
+  for (i = 0; i < dbPairsPrefixes.length; i++) {
 
     for (j = 0; j < target_doc_ids.length; j++) {
       doc_ids = target_doc_ids[j].initial;
@@ -979,12 +1000,12 @@ couchTests.replication = function(debug) {
         }
       }
 
-      populateDb(sourceDb, docs);
-      populateDb(targetDb, []);
+      populateSourceDb(docs);
+      populateTargetDb([]);
 
       repResult = CouchDB.replicate(
-        dbPairs[i].source,
-        dbPairs[i].target,
+        dbPairsPrefixes[i].source+sourceDb.name,
+        dbPairsPrefixes[i].target+targetDb.name,
         {
           body: {
             doc_ids: doc_ids
@@ -1048,8 +1069,8 @@ couchTests.replication = function(debug) {
       }
 
       repResult = CouchDB.replicate(
-        dbPairs[i].source,
-        dbPairs[i].target,
+        dbPairsPrefixes[i].source+sourceDb.name,
+        dbPairsPrefixes[i].target+targetDb.name,
         {
           body: {
             doc_ids: after_doc_ids
@@ -1113,8 +1134,8 @@ couchTests.replication = function(debug) {
       addAtt(sourceDb, doc, "data.dat", att2_data, "application/binary");
 
       repResult = CouchDB.replicate(
-        dbPairs[i].source,
-        dbPairs[i].target,
+        dbPairsPrefixes[i].source+sourceDb.name,
+        dbPairsPrefixes[i].target+targetDb.name,
         {
           body: {
             doc_ids: [id]
@@ -1170,8 +1191,8 @@ couchTests.replication = function(debug) {
       TEquals(true, targetDb.save(copy).ok);
 
       repResult = CouchDB.replicate(
-        dbPairs[i].source,
-        dbPairs[i].target,
+        dbPairsPrefixes[i].source+sourceDb.name,
+        dbPairsPrefixes[i].target+targetDb.name,
         {
           body: {
             doc_ids: [id]
@@ -1203,9 +1224,9 @@ couchTests.replication = function(debug) {
     }
   });
 
-  for (i = 0; i < dbPairs.length; i++) {
-    populateDb(sourceDb, docs);
-    populateDb(targetDb, []);
+  for (i = 0; i < dbPairsPrefixes.length; i++) {
+    populateSourceDb(docs);
+    populateTargetDb([]);
 
     // add some attachments
     for (j = 10; j < 15; j++) {
@@ -1213,8 +1234,8 @@ couchTests.replication = function(debug) {
     }
 
     repResult = CouchDB.replicate(
-      dbPairs[i].source,
-      dbPairs[i].target,
+      dbPairsPrefixes[i].source+sourceDb.name,
+      dbPairsPrefixes[i].target+targetDb.name,
       {
         body: {
           continuous: true
@@ -1344,7 +1365,7 @@ couchTests.replication = function(debug) {
 
     // add more docs to source
     var newDocs = makeDocs(25, 35);
-    populateDb(sourceDb, newDocs, true);
+    populateSourceDb(newDocs, true);
 
     waitForSeq(sourceDb, targetDb, rep_id);
 
@@ -1383,8 +1404,8 @@ couchTests.replication = function(debug) {
 
     // cancel the replication
     repResult = CouchDB.replicate(
-      dbPairs[i].source,
-      dbPairs[i].target,
+      dbPairsPrefixes[i].source+sourceDb.name,
+      dbPairsPrefixes[i].target+targetDb.name,
       {
         body: {
           continuous: true,
@@ -1418,8 +1439,8 @@ couchTests.replication = function(debug) {
       myfilter: (function(doc, req) { return true; }).toString()
     }
   });
-  populateDb(sourceDb, docs);
-  populateDb(targetDb, []);
+  populateSourceDb(docs);
+  populateTargetDb([]);
 
   repResult = CouchDB.replicate(
     CouchDB.protocol + host + "/" + sourceDb.name,
@@ -1473,9 +1494,9 @@ couchTests.replication = function(debug) {
   var compressionLevel = oldSettings.level;
   var compressibleTypes = oldSettings.types;
 
-  for (i = 0; i < dbPairs.length; i++) {
-    populateDb(sourceDb, [doc]);
-    populateDb(targetDb, []);
+  for (i = 0; i < dbPairsPrefixes.length; i++) {
+    populateSourceDb([doc]);
+    populateTargetDb([]);
 
     // enable compression of text types
     enableAttCompression("8", "text/*");
@@ -1494,7 +1515,7 @@ couchTests.replication = function(debug) {
     // disable compression and replicate
     disableAttCompression();
 
-    repResult = CouchDB.replicate(dbPairs[i].source, dbPairs[i].target);
+    repResult = CouchDB.replicate(dbPairsPrefixes[i].source+sourceDb.name, dbPairsPrefixes[i].target+targetDb.name);
     TEquals(true, repResult.ok);
     TEquals(true, repResult.history instanceof Array);
     TEquals(1, repResult.history.length);
@@ -1545,29 +1566,29 @@ couchTests.replication = function(debug) {
     language: "javascript"
   });
 
-  dbPairs = [
+  dbPairsPrefixes = [
     {
-      source: sourceDb.name,
-      target: targetDb.name
+      source: "",
+      target: ""
     },
     {
-      source: CouchDB.protocol + host + "/" + sourceDb.name,
-      target: targetDb.name
+      source: CouchDB.protocol + host + "/",
+      target: ""
     },
     {
-      source: sourceDb.name,
-      target: CouchDB.protocol + "joe:erly@" + host + "/" + targetDb.name
+      source: "",
+      target: CouchDB.protocol + "joe:erly@" + host + "/"
     },
     {
-      source: CouchDB.protocol + host + "/" + sourceDb.name,
-      target: CouchDB.protocol + "joe:erly@" + host + "/" + targetDb.name
+      source: CouchDB.protocol + host + "/",
+      target: CouchDB.protocol + "joe:erly@" + host + "/"
     }
   ];
 
-  for (i = 0; i < dbPairs.length; i++) {
+  for (i = 0; i < dbPairsPrefixes.length; i++) {
     //usersDb.deleteDb();
-    populateDb(sourceDb, docs);
-    populateDb(targetDb, []);
+    populateSourceDb(docs);
+    populateTargetDb([]);
 
     TEquals(true, targetDb.setSecObj({
       admins: {
@@ -1588,7 +1609,7 @@ couchTests.replication = function(debug) {
       TEquals(true, CouchDB.login("joe", "erly").ok);
       TEquals('joe', CouchDB.session().userCtx.name);
 
-      repResult = CouchDB.replicate(dbPairs[i].source, dbPairs[i].target);
+      repResult = CouchDB.replicate(dbPairsPrefixes[i].source+sourceDb.name, dbPairsPrefixes[i].target+targetDb.name);
 
       TEquals(true, CouchDB.logout().ok);
 
@@ -1612,29 +1633,29 @@ couchTests.replication = function(debug) {
   }
 
   // case 2) user triggering the replication is not a reader (nor admin) of the source DB
-  dbPairs = [
+  dbPairsPrefixes = [
     {
-      source: sourceDb.name,
-      target: targetDb.name
+      source: "",
+      target: ""
     },
     {
-      source: CouchDB.protocol + "joe:erly@" + host + "/" + sourceDb.name,
-      target: targetDb.name
+      source: CouchDB.protocol + "joe:erly@" + host + "/",
+      target: ""
     },
     {
-      source: sourceDb.name,
-      target: CouchDB.protocol + host + "/" + targetDb.name
+      source: "",
+      target: CouchDB.protocol + host + "/"
     },
     {
-      source: CouchDB.protocol + "joe:erly@" + host + "/" + sourceDb.name,
-      target: CouchDB.protocol + host + "/" + targetDb.name
+      source: CouchDB.protocol + "joe:erly@" + host + "/",
+      target: CouchDB.protocol + host + "/"
     }
   ];
 
-  for (i = 0; i < dbPairs.length; i++) {
+  for (i = 0; i < dbPairsPrefixes.length; i++) {
     //usersDb.deleteDb();
-    populateDb(sourceDb, docs);
-    populateDb(targetDb, []);
+    populateSourceDb(docs);
+    populateTargetDb([]);
 
     TEquals(true, sourceDb.setSecObj({
       admins: {
@@ -1666,7 +1687,7 @@ couchTests.replication = function(debug) {
       TEquals('joe', CouchDB.session().userCtx.name);
 
       try {
-        CouchDB.replicate(dbPairs[i].source, dbPairs[i].target);
+        CouchDB.replicate(dbPairsPrefixes[i].source+sourceDb.name, dbPairsPrefixes[i].target+targetDb.name);
         T(false, "should have raised an exception");
       } catch (x) {
         // TODO: small thing: DB exists but is no more found - at least we have an exception, so it's rather minor
@@ -1690,10 +1711,8 @@ couchTests.replication = function(debug) {
   sourceDb = new CouchDB("test_suite_db_a");
   targetDb = new CouchDB("test_suite_db_b");
 
-  sourceDb.deleteDb();
-  sourceDb.createDb();
-  targetDb.deleteDb();
-  targetDb.createDb();
+  populateSourceDb([]);
+  populateTargetDb([]);
 
   doc = {
     _id: "doc1"
@@ -1770,8 +1789,8 @@ couchTests.replication = function(debug) {
   // like  {"replication_id": Id, "cancel": true}. The replication ID
   // can be obtained from a continuous replication request response
   // (_local_id field), from _active_tasks or from the log
-  populateDb(sourceDb, makeDocs(1, 6));
-  populateDb(targetDb, []);
+  populateSourceDb(makeDocs(1, 6));
+  populateTargetDb([]);
 
   repResult = CouchDB.replicate(
     CouchDB.protocol + host + "/" + sourceDb.name,
@@ -1826,8 +1845,8 @@ couchTests.replication = function(debug) {
   ];*/
 
   //run_on_modified_server(server_config, function() {
-    populateDb(sourceDb, makeDocs(1, 6));
-    populateDb(targetDb, []);
+    populateSourceDb(makeDocs(1, 6));
+    populateTargetDb([]);
     var prevUserDoc = defaultUsersDb.open(userDoc._id);
     if(prevUserDoc) {
       userDoc._rev = prevUserDoc._rev;
@@ -1871,5 +1890,6 @@ couchTests.replication = function(debug) {
   //usersDb.deleteDb();
   sourceDb.deleteDb();
   targetDb.deleteDb();
+  // (not sure what this is - cleanup after 'file not found tests' poss. - not harmful anyway) 
   (new CouchDB("test_suite_db")).deleteDb();
 };

http://git-wip-us.apache.org/repos/asf/couchdb/blob/a87ac58e/test/javascript/tests/security_validation.js
----------------------------------------------------------------------
diff --git a/test/javascript/tests/security_validation.js b/test/javascript/tests/security_validation.js
index 5c50ff5..0bd9097 100644
--- a/test/javascript/tests/security_validation.js
+++ b/test/javascript/tests/security_validation.js
@@ -257,9 +257,10 @@ couchTests.security_validation = function(debug) {
       var A = CouchDB.protocol + CouchDB.host + "/" + db_name + "_a";
       var B = CouchDB.protocol + CouchDB.host + "/" + db_name + "_b";
 
-      adminDbA.deleteDb();
+      // (the databases never exist b4 - and we made sure they're deleted below)
+      //adminDbA.deleteDb();
       adminDbA.createDb();
-      adminDbB.deleteDb();
+      //adminDbB.deleteDb();
       adminDbB.createDb();
 
       // save and replicate a documents that will and will not pass our design

http://git-wip-us.apache.org/repos/asf/couchdb/blob/a87ac58e/test/javascript/tests/show_documents.js
----------------------------------------------------------------------
diff --git a/test/javascript/tests/show_documents.js b/test/javascript/tests/show_documents.js
index 82d66ae..ca75637 100644
--- a/test/javascript/tests/show_documents.js
+++ b/test/javascript/tests/show_documents.js
@@ -395,9 +395,13 @@ couchTests.show_documents = function(debug) {
   // (we don't need no modified server!)
   T(db.setDbProperty("_security", {foo: true}).ok);
   T(db.save({_id:"testdoc",foo:1}).ok);
-  xhr = CouchDB.request("GET", "/" + db_name + "/_design/template/_show/secObj");
-  var resp = JSON.parse(xhr.responseText);
-  T(resp.foo == true);
+  // nasty source of Heisenbugs - it replicates after a short time, so give it some tries
+  // (needs PR #400 and #401 to be merged)
+  retry_part(function(){
+    xhr = CouchDB.request("GET", "/" + db_name + "/_design/template/_show/secObj");
+    var resp = JSON.parse(xhr.responseText);
+    T(resp.foo == true);
+  }, 10);
 
   // cleanup
   db.deleteDb();

http://git-wip-us.apache.org/repos/asf/couchdb/blob/a87ac58e/test/javascript/tests/view_offsets.js
----------------------------------------------------------------------
diff --git a/test/javascript/tests/view_offsets.js b/test/javascript/tests/view_offsets.js
index 5b286c4..8b39cc2 100644
--- a/test/javascript/tests/view_offsets.js
+++ b/test/javascript/tests/view_offsets.js
@@ -60,8 +60,10 @@ couchTests.view_offsets = function(debug) {
   ].forEach(function(row){ check(row[0], row[1]);});
 
   var runTest = function () {
-    var db = new CouchDB("test_suite_db", {"X-Couch-Full-Commit":"false"});
-    db.deleteDb();
+    var db_name = get_random_db_name();
+    var db = new CouchDB(db_name, {"X-Couch-Full-Commit":"false"});
+    // (the DB will never exist per se)
+    //db.deleteDb();
     db.createDb();
 
     var designDoc = {
@@ -99,6 +101,9 @@ couchTests.view_offsets = function(debug) {
         endkey: ["b", 7]
     });
 
+    // delete (temp) DB now
+    db.deleteDb();
+
     return res1.offset == 4 && res2.offset == docs.length && res3.offset == 8;
 
   };

http://git-wip-us.apache.org/repos/asf/couchdb/blob/a87ac58e/test/javascript/tests/view_sandboxing.js
----------------------------------------------------------------------
diff --git a/test/javascript/tests/view_sandboxing.js b/test/javascript/tests/view_sandboxing.js
index 2676e7f..c70eecc 100644
--- a/test/javascript/tests/view_sandboxing.js
+++ b/test/javascript/tests/view_sandboxing.js
@@ -99,6 +99,9 @@ couchTests.view_sandboxing = function(debug) {
   };
 
   db.deleteDb();
+  // avoid Heisenbugs when files are not cleared entirely
+  db_name = get_random_db_name();
+  db = new CouchDB(db_name, {"X-Couch-Full-Commit":"false"});
   db.createDb();
   T(db.save(ddoc).ok);
   T(db.save(doc1).ok);