Skip to content

Commit

Permalink
Wait for registered name is unregistered to avoid race with next start
Browse files Browse the repository at this point in the history
  • Loading branch information
shino committed Sep 10, 2015
1 parent 273e353 commit 6f1e402
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions test/riak_cs_gc_manager_eqc.erl
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ prop_set_interval() ->
equals(Interval, State2#gc_manager_state.interval)}
])
after
ok = gen_fsm:sync_send_all_state_event(Pid, stop)
stop_and_hold_until_unregistered(Pid, riak_cs_gc_manager)
end
end).

Expand All @@ -124,7 +124,7 @@ prop_manual_commands() ->
end,
equals(ok, Res)))
after
ok = gen_fsm:sync_send_all_state_event(Pid, stop)
stop_and_hold_until_unregistered(Pid, riak_cs_gc_manager)
end
end).

Expand Down Expand Up @@ -197,4 +197,18 @@ expected_result(_From, idle, cancel_batch) ->
%% weight(feeding_workers, waiting_for_workers, _) -> 3;
%% weight(_, _, _) -> 1.

stop_and_hold_until_unregistered(Pid, RegName) ->
ok = gen_fsm:sync_send_all_state_event(Pid, stop),
hold_until_unregisterd(RegName, 50).

hold_until_unregisterd(_RegName, 0) ->
{error, not_unregistered_so_long_time};
hold_until_unregisterd(RegName, N) ->
case whereis(RegName) of
undefined -> ok;
_ ->
timer:sleep(1),
hold_until_unregisterd(RegName, N - 1)
end.

-endif.

0 comments on commit 6f1e402

Please sign in to comment.