Skip to content

Commit

Permalink
Use cets_test_peer:start/2 everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
arcusfelis committed Mar 12, 2024
1 parent 9b9d107 commit 934df20
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 24 deletions.
9 changes: 2 additions & 7 deletions test/cets_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -235,16 +235,11 @@ cets_seq_no_log_cases() ->

init_per_suite(Config) ->
cets_test_setup:init_cleanup_table(),
Names = [ct2, ct3, ct4, ct5, ct6, ct7],
{Nodes, Peers} = lists:unzip([cets_test_peer:start_node(N) || N <- Names]),
[
{nodes, maps:from_list(lists:zip(Names, Nodes))},
{peers, maps:from_list(lists:zip(Names, Peers))}
| Config
].
cets_test_peer:start([ct2, ct3, ct4, ct5, ct6, ct7], Config).

end_per_suite(Config) ->
cets_test_setup:remove_cleanup_table(),
cets_test_peer:stop(Config),
Config.

init_per_group(Group, Config) when Group == cets_seq_no_log; Group == cets_no_log ->
Expand Down
21 changes: 8 additions & 13 deletions test/cets_dist_blocker_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,10 @@ unknown_cases() ->
].

init_per_suite(Config) ->
Names = [peer_ct2],
{Nodes, Peers} = lists:unzip([cets_test_peer:start_node(N) || N <- Names]),
[
{nodes, maps:from_list(lists:zip(Names, Nodes))},
{peers, maps:from_list(lists:zip(Names, Peers))}
| Config
].
cets_test_peer:start([ct2], Config).

end_per_suite(Config) ->
cets_test_peer:stop(Config),
Config.

init_per_group(_Group, Config) ->
Expand All @@ -64,7 +59,7 @@ end_per_testcase(_, _Config) ->
%% Test blocking functionality

waits_for_cleaning(Config) ->
#{peer_ct2 := Node2} = proplists:get_value(nodes, Config),
#{ct2 := Node2} = proplists:get_value(nodes, Config),
{ok, Blocker} = cets_dist_blocker:start_link(),
cets_dist_blocker:add_cleaner(self()),
connect_and_disconnect(Node2),
Expand All @@ -75,7 +70,7 @@ waits_for_cleaning(Config) ->
gen_server:stop(Blocker).

unblocks_if_cleaner_goes_down(Config) ->
#{peer_ct2 := Node2} = proplists:get_value(nodes, Config),
#{ct2 := Node2} = proplists:get_value(nodes, Config),
{ok, Blocker} = cets_dist_blocker:start_link(),
Cleaner = spawn_cleaner(),
connect_and_disconnect(Node2),
Expand All @@ -86,7 +81,7 @@ unblocks_if_cleaner_goes_down(Config) ->
gen_server:stop(Blocker).

unblocks_if_cleaner_goes_down_and_second_cleaner_says_done(Config) ->
#{peer_ct2 := Node2} = proplists:get_value(nodes, Config),
#{ct2 := Node2} = proplists:get_value(nodes, Config),
{ok, Blocker} = cets_dist_blocker:start_link(),
%% Two cleaners
cets_dist_blocker:add_cleaner(self()),
Expand All @@ -101,7 +96,7 @@ unblocks_if_cleaner_goes_down_and_second_cleaner_says_done(Config) ->
gen_server:stop(Blocker).

unblocks_if_cleaner_says_done_and_second_cleaner_goes_down(Config) ->
#{peer_ct2 := Node2} = proplists:get_value(nodes, Config),
#{ct2 := Node2} = proplists:get_value(nodes, Config),
{ok, Blocker} = cets_dist_blocker:start_link(),
%% Two cleaners
cets_dist_blocker:add_cleaner(self()),
Expand All @@ -117,7 +112,7 @@ unblocks_if_cleaner_says_done_and_second_cleaner_goes_down(Config) ->
gen_server:stop(Blocker).

blocks_if_cleaner_says_done_and_second_cleaner_does_not_ack(Config) ->
#{peer_ct2 := Node2} = proplists:get_value(nodes, Config),
#{ct2 := Node2} = proplists:get_value(nodes, Config),
{ok, Blocker} = cets_dist_blocker:start_link(),
%% Two cleaners
cets_dist_blocker:add_cleaner(self()),
Expand All @@ -131,7 +126,7 @@ blocks_if_cleaner_says_done_and_second_cleaner_does_not_ack(Config) ->
gen_server:stop(Blocker).

skip_blocking_if_no_cleaners(Config) ->
#{peer_ct2 := Node2} = proplists:get_value(nodes, Config),
#{ct2 := Node2} = proplists:get_value(nodes, Config),
{ok, Blocker} = cets_dist_blocker:start_link(),
pong = net_adm:ping(Node2),
true = erlang:disconnect_node(Node2),
Expand Down
7 changes: 3 additions & 4 deletions test/cets_test_peer.erl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
-export([
start/2,
stop/1,
start_node/1,
node_to_peer/1
]).

Expand All @@ -18,7 +17,7 @@
-include_lib("common_test/include/ct.hrl").

start(Names, Config) ->
{Nodes, Peers} = lists:unzip([cets_test_peer:start_node(name(N)) || N <- Names]),
{Nodes, Peers} = lists:unzip([start_node(N) || N <- Names]),
[
{nodes, maps:from_list(lists:zip(Names, Nodes))},
{peers, maps:from_list(lists:zip(Names, Peers))}
Expand All @@ -33,9 +32,9 @@ stop(Config) ->
name(Node) ->
list_to_atom(peer:random_name(atom_to_list(Node))).

start_node(Sname) ->
start_node(Id) ->
{ok, Peer, Node} = ?CT_PEER(#{
name => Sname, connection => standard_io, args => extra_args(Sname)
name => name(Id), connection => standard_io, args => extra_args(Id)
}),
%% Register so we can find Peer process later in code
register(node_to_peer_name(Node), Peer),
Expand Down

0 comments on commit 934df20

Please sign in to comment.