Skip to content

Commit

Permalink
Kill lingering supervisors
Browse files Browse the repository at this point in the history
If an earlier test fails, `teardown` may not be invoked properly and
later tests will fail during `setup`. Terminate lingering supervisors.
  • Loading branch information
macintux committed Mar 9, 2017
1 parent 399027f commit 2f90ff1
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/riak_core_info_service.erl
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,16 @@ sup_wrapper() ->

%% Launching and terminating the supervisor is an async operation with
%% all the non-determinism that that implies. So, we wait.
sup_wait(Name, Fun) ->
sup_wait(Name, kill, Fun) ->
%% in case an earlier test failure left a supervisor running
case whereis(Name) of
undefined ->
ok;
Pid ->
exit(Pid, kill)
end,
sup_wait(Name, undefined, Fun);
sup_wait(Name, undefined, Fun) ->
sup_wait(Name, Fun, Fun(whereis(Name)), 5).

sup_wait(_Name, _Fun, ok, _Count) ->
Expand Down Expand Up @@ -194,9 +203,9 @@ setup() ->
end,
flush_messages(),

sup_wait(riak_core_info_service_sup, WaitTerminated),
sup_wait(riak_core_info_service_sup, kill, WaitTerminated),
Pid = spawn(fun sup_wrapper/0),
sup_wait(riak_core_info_service_sup, WaitStarted),
sup_wait(riak_core_info_service_sup, undefined, WaitStarted),

Pid.

Expand Down

0 comments on commit 2f90ff1

Please sign in to comment.