Skip to content

Commit

Permalink
Monitorr stopping peers
Browse files Browse the repository at this point in the history
  • Loading branch information
arcusfelis committed May 13, 2024
1 parent 07839a6 commit 0d98f74
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion test/cets_test_peer.erl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,14 @@ start(Names, Config) ->

stop(Config) ->
Peers = proplists:get_value(peers, Config),
[peer:stop(Peer) || Peer <- maps:values(Peers)],
[
slow_task(
"peer:stop:self",
self(),
fun() -> slow_task("peer:stop", Peer, fun() -> peer:stop(Peer) end) end
)
|| Peer <- maps:values(Peers)
],
ok.

name(Node) ->
Expand Down Expand Up @@ -98,3 +105,18 @@ disconnect_node_by_name(Config, Id) ->
lists:member(Node, nodes())
end,
cets_test_wait:wait_until(F, false).

slow_task(What, Self, F) ->
Pid = spawn_link(fun() -> monitor_loop(What, Self) end),
Res = F(),
Pid ! stop,
Res.

monitor_loop(What, Pid) ->
receive
stop ->
ok
after 1000 ->
ct:pal("monitor_loop ~p ~p", [What, erlang:process_info(Pid, current_stacktrace)]),
monitor_loop(What, Pid)
end.

0 comments on commit 0d98f74

Please sign in to comment.