Skip to content

Commit

Permalink
Merge pull request #595 from basho/bugfix/jrw/bg-mgr-eqc-fixes
Browse files Browse the repository at this point in the history
plug bg_manager_eqc into eunit and address potential race

Reviewed-by: reiddraper
  • Loading branch information
borshop committed May 30, 2014
2 parents 8723bb0 + 960b83c commit 409f86e
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion test/bg_manager_eqc.erl
Expand Up @@ -26,6 +26,8 @@
-include_lib("eqc/include/eqc.hrl").
-include_lib("eqc/include/eqc_statem.hrl").
-include_lib("eunit/include/eunit.hrl").
-define(QC_OUT(P),
eqc:on_output(fun(Str, Args) -> io:format(user, Str, Args) end, P)).

-compile(export_all).

Expand Down Expand Up @@ -54,6 +56,13 @@
tokens :: [{bg_eqc_type(), non_neg_integer()}]
}).

bgmgr_test_() ->
{timeout, 60,
fun() ->
?assert(eqc:quickcheck(?QC_OUT(eqc:testing_time(30, prop_bgmgr()))))
end
}.

run_eqc() ->
run_eqc(100).

Expand Down Expand Up @@ -274,7 +283,15 @@ stop_process_pre(S, [Pid]) ->
%% @doc stop_process command
stop_process(Pid) ->
Pid ! die,
wait_for_pid(Pid).
Res = wait_for_pid(Pid),
%% while not part of the test, this provides extra insurance that the
%% background manager receives the monitor message for the failed pid
%% (waiting for the test process to receive its monitor message is not
%% enough). This relies on local erlang message semantics a bit and may
%% not be bullet proof. The catch handles the case where the bg manager
%% has been crashed by the test.
catch riak_core_bg_manager:enabled(),
Res.

%% @doc state transition for stop_process command
stop_process_next(S=#state{procs=Procs}, _Value, [Pid]) ->
Expand Down

0 comments on commit 409f86e

Please sign in to comment.