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.
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/caba8931 Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/caba8931 Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/caba8931 Branch: refs/heads/1963-eunit-bigcouch Commit: caba893128849cf3f497bc19d5abb2b4b2fd9880 Parents: 73ca1f9 Author: Paul J. Davis <[email protected]> Authored: Tue Aug 12 14:09:26 2014 -0500 Committer: Paul J. Davis <[email protected]> Committed: Tue Aug 12 14:09:26 2014 -0500 ---------------------------------------------------------------------- share/www/script/test/replicator_db_identical_continuous.js | 7 +++++++ 1 file changed, 7 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb/blob/caba8931/share/www/script/test/replicator_db_identical_continuous.js ---------------------------------------------------------------------- diff --git a/share/www/script/test/replicator_db_identical_continuous.js b/share/www/script/test/replicator_db_identical_continuous.js index 5e7f151..240c531 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");
