couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fdman...@apache.org
Subject svn commit: r1091372 - /couchdb/trunk/share/www/script/test/replicator_db.js
Date Tue, 12 Apr 2011 11:08:24 GMT
Author: fdmanana
Date: Tue Apr 12 11:08:24 2011
New Revision: 1091372

URL: http://svn.apache.org/viewvc?rev=1091372&view=rev
Log:
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/trunk/share/www/script/test/replicator_db.js

Modified: couchdb/trunk/share/www/script/test/replicator_db.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/replicator_db.js?rev=1091372&r1=1091371&r2=1091372&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/test/replicator_db.js (original)
+++ couchdb/trunk/share/www/script/test/replicator_db.js Tue Apr 12 11:08:24 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