Repository: couchdb-fabric
Updated Branches:
  refs/heads/master 475b90ccd -> 2eb1e132e


Use meck:wait to fix race condition

fabric:update_docs is running in the context of a `read_repair` which is an
independent process started using `erlang:spawn/1`. This leads to a race
when we try to use `meck:history(fabric)`. Use of `meck:wait` ensures that
we call `meck:history` after `fabric:update_docs` has been called.


Project: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/commit/19e9959a
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/tree/19e9959a
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fabric/diff/19e9959a

Branch: refs/heads/master
Commit: 19e9959aab87c8050d280f5d255d58cf1a995614
Parents: 475b90c
Author: ILYA Khlopotov <iil...@ca.ibm.com>
Authored: Tue May 24 15:52:25 2016 -0700
Committer: ILYA Khlopotov <iil...@ca.ibm.com>
Committed: Tue May 24 15:52:25 2016 -0700

----------------------------------------------------------------------
 src/fabric_doc_open_revs.erl | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-fabric/blob/19e9959a/src/fabric_doc_open_revs.erl
----------------------------------------------------------------------
diff --git a/src/fabric_doc_open_revs.erl b/src/fabric_doc_open_revs.erl
index 4f0bf89..3534830 100644
--- a/src/fabric_doc_open_revs.erl
+++ b/src/fabric_doc_open_revs.erl
@@ -330,7 +330,9 @@ check_finish_quorum_newer() ->
         S0 = state0(all, false),
         {ok, S1} = handle_message({ok, [foo1(), bar1()]}, w1, S0),
         Expect = {stop, [bar1(), foo2()]},
+        ok = meck:reset(fabric),
         ?assertEqual(Expect, handle_message({ok, [foo2(), bar1()]}, w2, S1)),
+        ok = meck:wait(fabric, update_docs, '_', 5000),
         ?assertMatch(
             [{_, {fabric, update_docs, [_, _, _]}, _}],
             meck:history(fabric)

Reply via email to