summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul J. Davis <paul.joseph.davis@gmail.com>2014-08-12 14:09:26 -0500
committerPaul J. Davis <paul.joseph.davis@gmail.com>2014-08-12 14:09:26 -0500
commitcaba893128849cf3f497bc19d5abb2b4b2fd9880 (patch)
treef4ea7ab80a81d9547c2d14ff90311b263fddb7d4
parent73ca1f9c575b65ac5b805605dbae08b49ace7a46 (diff)
downloadcouchdb-caba893128849cf3f497bc19d5abb2b4b2fd9880.tar.gz
Fix race condition in a replicator db test
There was a race condition where we could end up grabbing repDoc1 before the replicator manager got around to updating it. Local timespans had this in the 19ms range. Rather than slap a timeout on it I've added a call to a longpoll on the changes feed to wait for the update.
-rw-r--r--share/www/script/test/replicator_db_identical_continuous.js7
1 files changed, 7 insertions, 0 deletions
diff --git a/share/www/script/test/replicator_db_identical_continuous.js b/share/www/script/test/replicator_db_identical_continuous.js
index 5e7f15121..240c531f5 100644
--- a/share/www/script/test/replicator_db_identical_continuous.js
+++ b/share/www/script/test/replicator_db_identical_continuous.js
@@ -54,6 +54,13 @@ couchTests.replicator_db_identical_continuous = function(debug) {
T(copy.value === doc.value);
}
+ // Rather than a timeout we're just waiting to hear the
+ // fourth change to the database. Changes 1 and 2 were
+ // us storing repDoc1 and repDoc2. Changes 3 and 4 are
+ // the replicator manager updating each document. This
+ // just waits until the fourth change before continuing.
+ repDb.changes({"feed":"longpoll", "since":3});
+
repDoc1 = repDb.open("foo_dup_cont_rep_doc_1");
T(repDoc1 !== null);
T(repDoc1._replication_state === "triggered");