Fix race #3
This commit is contained in:
parent
9d177c6b54
commit
1c8e436a64
2 changed files with 19 additions and 7 deletions
|
@ -45,12 +45,11 @@
|
|||
%% List twiddling
|
||||
permutations/1, perms/1,
|
||||
combinations/1, ordered_combinations/1,
|
||||
mk_order/2
|
||||
mk_order/2,
|
||||
%% Other
|
||||
wait_for_death/2, wait_for_life/2
|
||||
]).
|
||||
|
||||
%% TODO: Leave this in place?
|
||||
-compile(export_all).
|
||||
|
||||
-include("machi.hrl").
|
||||
-include("machi_projection.hrl").
|
||||
-include_lib("kernel/include/file.hrl").
|
||||
|
@ -316,11 +315,22 @@ wait_for_death(Pid, Iters) when is_pid(Pid) ->
|
|||
case erlang:is_process_alive(Pid) of
|
||||
false ->
|
||||
ok;
|
||||
true ->
|
||||
true ->
|
||||
timer:sleep(1),
|
||||
wait_for_death(Pid, Iters-1)
|
||||
end.
|
||||
|
||||
wait_for_life(Reg, 0) ->
|
||||
exit({not_alive_yet, Reg});
|
||||
wait_for_life(Reg, Iters) when is_atom(Reg) ->
|
||||
case erlang:whereis(Reg) of
|
||||
Pid when is_pid(Pid) ->
|
||||
{ok, Pid};
|
||||
_ ->
|
||||
timer:sleep(1),
|
||||
wait_for_life(Reg, Iters-1)
|
||||
end.
|
||||
|
||||
%%%%%%%%%%%%%%%%%
|
||||
|
||||
%% @doc Create a TCP connection to a remote Machi server.
|
||||
|
|
|
@ -32,6 +32,7 @@ smoke_test_() -> {timeout, 1*60, fun() -> smoke_test2() end}.
|
|||
|
||||
setup_smoke_test(Host, PortBase, Os, Witness_list) ->
|
||||
os:cmd("rm -rf ./data.a ./data.b ./data.c"),
|
||||
{ok, _} = machi_util:wait_for_life(machi_flu_sup, 100),
|
||||
|
||||
F = fun(X) -> case lists:member(X, Witness_list) of
|
||||
true ->
|
||||
|
@ -185,9 +186,10 @@ smoke_test2() ->
|
|||
|
||||
ok
|
||||
after
|
||||
exit(SupPid, normal),
|
||||
machi_util:wait_for_death(SupPid, 100),
|
||||
error_logger:tty(true),
|
||||
catch application:stop(machi),
|
||||
exit(SupPid, normal)
|
||||
catch application:stop(machi)
|
||||
end.
|
||||
|
||||
witness_smoke_test_() -> {timeout, 1*60, fun() -> witness_smoke_test2() end}.
|
||||
|
|
Loading…
Reference in a new issue