Skip to content

Commit c36b56b

Browse files
committed
speed up signal_handling_SUITE
1 parent d25017d commit c36b56b

File tree

1 file changed

+30
-28
lines changed

1 file changed

+30
-28
lines changed

deps/rabbit/test/signal_handling_SUITE.erl

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,17 @@ all() ->
3636

3737
groups() ->
3838
Signals = [sighup,
39-
sigterm,
40-
sigtstp],
39+
sigtstp,
40+
sigterm],
4141
Tests = [list_to_existing_atom(rabbit_misc:format("send_~ts", [Signal]))
4242
|| Signal <- Signals],
4343
[
4444
{signal_sent_to_pid_in_pidfile, [], Tests},
4545
{signal_sent_to_pid_from_os_getpid, [], Tests}
4646
].
4747

48+
-define(SLEEP, 5000).
49+
4850
%% -------------------------------------------------------------------
4951
%% Testsuite setup/teardown.
5052
%% -------------------------------------------------------------------
@@ -61,31 +63,32 @@ init_per_suite(Config) ->
6163
end_per_suite(Config) ->
6264
rabbit_ct_helpers:run_teardown_steps(Config).
6365

64-
init_per_group(_, Config) ->
65-
Config.
66-
67-
end_per_group(_, Config) ->
68-
Config.
69-
70-
init_per_testcase(Testcase, Config) ->
71-
rabbit_ct_helpers:testcase_started(Config, Testcase),
66+
init_per_group(Group, Config) ->
7267
ClusterSize = 1,
73-
TestNumber = rabbit_ct_helpers:testcase_number(Config, ?MODULE, Testcase),
68+
% TestNumber = rabbit_ct_helpers:testcase_number(Config, ?MODULE, Testcase),
7469
Config1 = rabbit_ct_helpers:set_config(
7570
Config,
7671
[
77-
{rmq_nodename_suffix, Testcase},
78-
{tcp_ports_base, {skip_n_nodes, TestNumber * ClusterSize}}
72+
{rmq_nodename_suffix, Group},
73+
{tcp_ports_base, {skip_n_nodes, ClusterSize}}
7974
]),
8075
rabbit_ct_helpers:run_steps(Config1,
8176
rabbit_ct_broker_helpers:setup_steps() ++
8277
rabbit_ct_client_helpers:setup_steps()).
8378

84-
end_per_testcase(Testcase, Config) ->
79+
end_per_group(_, Config) ->
8580
Config1 = rabbit_ct_helpers:run_steps(Config,
8681
rabbit_ct_client_helpers:teardown_steps() ++
8782
rabbit_ct_broker_helpers:teardown_steps()),
88-
rabbit_ct_helpers:testcase_finished(Config1, Testcase).
83+
Config1.
84+
85+
init_per_testcase(Testcase, Config) ->
86+
rabbit_ct_helpers:testcase_started(Config, Testcase),
87+
Config.
88+
89+
end_per_testcase(Testcase, Config) ->
90+
rabbit_ct_helpers:testcase_finished(Config, Testcase),
91+
Config.
8992

9093
%% -------------------------------------------------------------------
9194
%% Testcases.
@@ -97,7 +100,7 @@ send_sighup(Config) ->
97100
%% A SIGHUP signal should be ignored and the node should still be
98101
%% running.
99102
send_signal(Pid, "HUP"),
100-
timer:sleep(10000),
103+
timer:sleep(?SLEEP),
101104
A = rabbit_ct_broker_helpers:get_node_config(Config, 0, nodename),
102105
?assert(rabbit_ct_broker_helpers:rpc(Config, A, rabbit, is_running, [])),
103106
?assert(filelib:is_regular(PidFile)).
@@ -108,18 +111,26 @@ send_sigterm(Config) ->
108111
%% After sending a SIGTERM to the process, we expect the node to
109112
%% exit.
110113
send_signal(Pid, "TERM"),
111-
wait_for_node_exit(Pid),
114+
rabbit_ct_helpers:await_condition(
115+
fun () ->
116+
rabbit_misc:is_os_process_alive(Pid) == false
117+
end),
112118

113119
%% After a clean exit, the PID file should be removed.
114-
?assertNot(filelib:is_regular(PidFile)).
120+
?assertNot(filelib:is_regular(PidFile)),
121+
%% restart node
122+
Server = rabbit_ct_broker_helpers:get_node_config(Config, 0, nodename),
123+
ok = rabbit_ct_broker_helpers:start_node(Config, Server),
124+
ok.
125+
115126

116127
send_sigtstp(Config) ->
117128
{PidFile, Pid} = get_pidfile_and_pid(Config),
118129

119130
%% A SIGHUP signal should be ignored and the node should still be
120131
%% running.
121132
send_signal(Pid, "TSTP"),
122-
timer:sleep(10000),
133+
timer:sleep(?SLEEP),
123134
A = rabbit_ct_broker_helpers:get_node_config(Config, 0, nodename),
124135
?assert(rabbit_ct_broker_helpers:rpc(Config, A, rabbit, is_running, [])),
125136
?assert(filelib:is_regular(PidFile)).
@@ -149,12 +160,3 @@ send_signal(Pid, Signal) ->
149160
"-" ++ Signal,
150161
Pid],
151162
?assertMatch({ok, _}, rabbit_ct_helpers:exec(Cmd)).
152-
153-
wait_for_node_exit(Pid) ->
154-
case rabbit_misc:is_os_process_alive(Pid) of
155-
true ->
156-
timer:sleep(1000),
157-
wait_for_node_exit(Pid);
158-
false ->
159-
ok
160-
end.

0 commit comments

Comments
 (0)