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 1ac8271
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion test/cets_test_peer.erl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ start(Names, Config) ->

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

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

slow_task(What, F) ->
Self = self(),
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 1ac8271

Please sign in to comment.