Skip to content

Commit

Permalink
Merge pull request #52 from esl/disco-test-unexpected
Browse files Browse the repository at this point in the history
Improve coverage for disco
  • Loading branch information
chrzaszcz committed Mar 7, 2024
2 parents aac8ba7 + da0eb2e commit 637a784
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/cets_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,10 @@ cases() ->
unknown_message_is_ignored_in_ack_process,
unknown_cast_message_is_ignored_in_ack_process,
unknown_call_returns_error_from_ack_process,
unknown_message_is_ignored_in_disco_process,
code_change_returns_ok,
code_change_returns_ok_for_ack,
code_change_returns_ok_for_disco,
run_spawn_forwards_errors,
run_tracked_failed,
run_tracked_logged,
Expand Down Expand Up @@ -2341,6 +2343,11 @@ unknown_message_is_ignored_in_ack_process(Config) ->
AckPid ! oops,
still_works(Pid).

unknown_message_is_ignored_in_disco_process(_Config) ->
Pid = start_simple_disco(),
Pid ! oops,
#{} = sys:get_state(Pid).

unknown_cast_message_is_ignored_in_ack_process(Config) ->
{ok, Pid} = start_local(make_name(Config)),
#{ack_pid := AckPid} = cets:info(Pid),
Expand All @@ -2366,6 +2373,12 @@ code_change_returns_ok_for_ack(Config) ->
ok = sys:change_code(AckPid, cets_ack, v2, []),
sys:resume(AckPid).

code_change_returns_ok_for_disco(_Config) ->
Pid = start_simple_disco(),
sys:suspend(Pid),
ok = sys:change_code(Pid, cets_ack, v2, []),
sys:resume(Pid).

run_spawn_forwards_errors(_Config) ->
?assertException(
error,
Expand Down Expand Up @@ -2960,6 +2973,15 @@ start_disco(Node, Opts) ->
schedule_cleanup(Pid),
Pid.

start_simple_disco() ->
F = fun(State) ->
{{ok, []}, State}
end,
{ok, Pid} = cets_discovery:start_link(#{
backend_module => cets_discovery_fun, get_nodes_fn => F
}),
Pid.

wait_for_name_to_be_free(Node, Name) ->
%% Wait for the old process to be killed by the cleaner in schedule_cleanup.
%% Cleaner is fast, but not instant.
Expand Down

0 comments on commit 637a784

Please sign in to comment.