Skip to content

Commit

Permalink
test: fix flaky test
Browse files Browse the repository at this point in the history
  • Loading branch information
zmstone committed Dec 14, 2023
1 parent aa499dc commit 5230a53
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions test/ehttpc_sup_tests.erl
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,18 @@ t_shutdown() ->
Worker ! {suspend, timer:seconds(60)},
%% zombie worker should not block pool stop
ok = ehttpc_sup:stop_pool(Pool),
receive
{'DOWN', _, process, SupPid, killed} ->
ok;
Other2 ->
error({"unexpected_message", Other2})
after 6000 ->
error("failed_to_stop_pool_supervisor")
end,
receive
{'DOWN', _, process, Worker, killed} ->
ok;
Other ->
error({"unexpected_message", Other})
after 1000 ->
error("failed_to_stop_worker_from_sup_shutdown")
end
ok = wait_for_down([SupPid, Worker])
after
exit(SupPid, kill),
exit(Worker, kill)
end.

wait_for_down([]) ->
ok;
wait_for_down(Pids) ->
receive
{'DOWN', _, process, Pid, killed} ->
wait_for_down(Pids -- [Pid])
after 10_000 ->
error(timeout)
end.

0 comments on commit 5230a53

Please sign in to comment.