diff options
author | Filipe David Borba Manana <fdmanana@apache.org> | 2011-04-18 10:44:33 +0000 |
---|---|---|
committer | Filipe David Borba Manana <fdmanana@apache.org> | 2011-04-18 10:44:33 +0000 |
commit | 928e6e1522fadb08cb38329143ad84bf548c5172 (patch) | |
tree | 204167e4f256aba2f44800b1ce93b8fe95e04d19 | |
parent | 1e7bdb1d04b074d69753f4beab8c667e3cb11852 (diff) |
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
-rw-r--r-- | share/www/script/test/replicator_db.js | 23 |
1 files changed, 20 insertions, 3 deletions
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); |