couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fdman...@apache.org
Subject svn commit: r1094480 - /couchdb/branches/1.1.x/share/www/script/test/replicator_db.js
Date Mon, 18 Apr 2011 10:44:33 GMT
Author: fdmanana
Date: Mon Apr 18 10:44:33 2011
New Revision: 1094480

URL: http://svn.apache.org/viewvc?rev=1094480&view=rev
Log:
Merged revision 1091372 from trunk

    Fixing replicator_db.js test failures due to timing issues
    
    Failures in this test shouldn't happen so frequently on slower
    machines anymore.


Modified:
    couchdb/branches/1.1.x/share/www/script/test/replicator_db.js

Modified: couchdb/branches/1.1.x/share/www/script/test/replicator_db.js
URL: http://svn.apache.org/viewvc/couchdb/branches/1.1.x/share/www/script/test/replicator_db.js?rev=1094480&r1=1094479&r2=1094480&view=diff
==============================================================================
--- couchdb/branches/1.1.x/share/www/script/test/replicator_db.js (original)
+++ couchdb/branches/1.1.x/share/www/script/test/replicator_db.js Mon Apr 18 10:44:33 2011
@@ -40,7 +40,7 @@ couchTests.replicator_db = function(debu
     var newRep,
         t0 = new Date(),
         t1,
-        ms = 1000;
+        ms = 3000;
 
     do {
       newRep = repDb.open(repDoc._id);
@@ -53,7 +53,7 @@ couchTests.replicator_db = function(debu
         sourceSeq = sourceDb.info().update_seq,
         t0 = new Date(),
         t1,
-        ms = 1000;
+        ms = 3000;
 
     do {
       targetSeq = targetDb.info().update_seq;
@@ -61,6 +61,23 @@ couchTests.replicator_db = function(debu
     } while (((t1 - t0) <= ms) && targetSeq < sourceSeq);
   }
 
+  function waitForDocPos(db, docId, pos) {
+    var doc, curPos, t0, t1,
+        maxWait = 3000;
+
+    doc = db.open(docId);
+    curPos = Number(doc._rev.split("-", 1));
+    t0 = t1 = new Date();
+
+    while ((curPos < pos) && ((t1 - t0) <= maxWait)) {
+       doc = db.open(docId);
+       curPos = Number(doc._rev.split("-", 1));
+       t1 = new Date();
+    }
+
+    return doc;
+  }
+
   function wait(ms) {
     var t0 = new Date(), t1;
     do {
@@ -628,7 +645,7 @@ couchTests.replicator_db = function(debu
     T(copy !== null);
     T(copy.value === 1001);
 
-    repDoc = repDb.open("foo_cont_rep_survives_doc");
+    repDoc = waitForDocPos(repDb, "foo_cont_rep_survives_doc", 3);
     T(repDoc !== null);
     T(repDoc.continuous === true);
 



Mime
View raw message