From 928e6e1522fadb08cb38329143ad84bf548c5172 Mon Sep 17 00:00:00 2001 From: Filipe David Borba Manana Date: Mon, 18 Apr 2011 10:44:33 +0000 Subject: 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. git-svn-id: https://svn.apache.org/repos/asf/couchdb/branches/1.1.x@1094480 13f79535-47bb-0310-9956-ffa450edef68 --- share/www/script/test/replicator_db.js | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'share/www/script') diff --git a/share/www/script/test/replicator_db.js b/share/www/script/test/replicator_db.js index e8986d6e..3eeefe1a 100644 --- a/share/www/script/test/replicator_db.js +++ b/share/www/script/test/replicator_db.js @@ -40,7 +40,7 @@ couchTests.replicator_db = function(debug) { var newRep, t0 = new Date(), t1, - ms = 1000; + ms = 3000; do { newRep = repDb.open(repDoc._id); @@ -53,7 +53,7 @@ couchTests.replicator_db = function(debug) { 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(debug) { } 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(debug) { 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); -- cgit v1.2.3