summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul J. Davis <paul.joseph.davis@gmail.com>2017-07-25 16:41:59 -0500
committerPaul J. Davis <paul.joseph.davis@gmail.com>2017-07-25 17:38:35 -0500
commit439e642363cbb7bbc299b844df211e849aa667a8 (patch)
treea6c4549845df434208b5b08ebdff588229ad45d1
parentee22d70b5e5e0e26968aa0017b80ade231b6b342 (diff)
downloadcouchdb-439e642363cbb7bbc299b844df211e849aa667a8.tar.gz
Fix regression test for COUCHDB-1283
This makes sure that we correctly synchronize with the process running compaction before we perform our desired assertions. Fixes #701
-rw-r--r--src/couch/test/couchdb_views_tests.erl17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/couch/test/couchdb_views_tests.erl b/src/couch/test/couchdb_views_tests.erl
index 616a3c8a4..65fc2b385 100644
--- a/src/couch/test/couchdb_views_tests.erl
+++ b/src/couch/test/couchdb_views_tests.erl
@@ -354,19 +354,30 @@ couchdb_1283() ->
couch_mrview_index, MDb1#db.name, <<"_design/foo">>),
% Start and pause compacton
+ WaitRef = erlang:make_ref(),
+ meck:expect(couch_mrview_index, compact, fun(Db, State, Opts) ->
+ receive {WaitRef, From, init} -> ok end,
+ From ! {WaitRef, inited},
+ receive {WaitRef, go} -> ok end,
+ meck:passthrough([Db, State, Opts])
+ end),
+
{ok, CPid} = gen_server:call(Pid, compact),
- meck:wait(couch_mrview_index, compact, ['_', '_', '_'], 1000),
- erlang:suspend_process(CPid),
CRef = erlang:monitor(process, CPid),
?assert(is_process_alive(CPid)),
+ % Make sure that our compactor is waiting for us
+ % before we continue our assertions
+ CPid ! {WaitRef, self(), init},
+ receive {WaitRef, inited} -> ok end,
+
% Make sure that a compaction process takes a monitor
% on the database's main_pid
?assertEqual(true, lists:member(CPid, couch_db:monitored_by(MDb1))),
% Finish compaction to and make sure the monitor
% disappears
- erlang:resume_process(CPid),
+ CPid ! {WaitRef, go},
wait_for_process_shutdown(CRef, normal,
{reason, "Failure compacting view group"}),