@@ -36,15 +36,17 @@ all() ->
36
36
37
37
groups () ->
38
38
Signals = [sighup ,
39
- sigterm ,
40
- sigtstp ],
39
+ sigtstp ,
40
+ sigterm ],
41
41
Tests = [list_to_existing_atom (rabbit_misc :format (" send_~ts " , [Signal ]))
42
42
|| Signal <- Signals ],
43
43
[
44
44
{signal_sent_to_pid_in_pidfile , [], Tests },
45
45
{signal_sent_to_pid_from_os_getpid , [], Tests }
46
46
].
47
47
48
+ -define (SLEEP , 5000 ).
49
+
48
50
% % -------------------------------------------------------------------
49
51
% % Testsuite setup/teardown.
50
52
% % -------------------------------------------------------------------
@@ -61,31 +63,32 @@ init_per_suite(Config) ->
61
63
end_per_suite (Config ) ->
62
64
rabbit_ct_helpers :run_teardown_steps (Config ).
63
65
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 ) ->
72
67
ClusterSize = 1 ,
73
- TestNumber = rabbit_ct_helpers :testcase_number (Config , ? MODULE , Testcase ),
68
+ % TestNumber = rabbit_ct_helpers:testcase_number(Config, ?MODULE, Testcase),
74
69
Config1 = rabbit_ct_helpers :set_config (
75
70
Config ,
76
71
[
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 }}
79
74
]),
80
75
rabbit_ct_helpers :run_steps (Config1 ,
81
76
rabbit_ct_broker_helpers :setup_steps () ++
82
77
rabbit_ct_client_helpers :setup_steps ()).
83
78
84
- end_per_testcase ( Testcase , Config ) ->
79
+ end_per_group ( _ , Config ) ->
85
80
Config1 = rabbit_ct_helpers :run_steps (Config ,
86
81
rabbit_ct_client_helpers :teardown_steps () ++
87
82
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 .
89
92
90
93
% % -------------------------------------------------------------------
91
94
% % Testcases.
@@ -97,7 +100,7 @@ send_sighup(Config) ->
97
100
% % A SIGHUP signal should be ignored and the node should still be
98
101
% % running.
99
102
send_signal (Pid , " HUP" ),
100
- timer :sleep (10000 ),
103
+ timer :sleep (? SLEEP ),
101
104
A = rabbit_ct_broker_helpers :get_node_config (Config , 0 , nodename ),
102
105
? assert (rabbit_ct_broker_helpers :rpc (Config , A , rabbit , is_running , [])),
103
106
? assert (filelib :is_regular (PidFile )).
@@ -108,18 +111,26 @@ send_sigterm(Config) ->
108
111
% % After sending a SIGTERM to the process, we expect the node to
109
112
% % exit.
110
113
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 ),
112
118
113
119
% % 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
+
115
126
116
127
send_sigtstp (Config ) ->
117
128
{PidFile , Pid } = get_pidfile_and_pid (Config ),
118
129
119
130
% % A SIGHUP signal should be ignored and the node should still be
120
131
% % running.
121
132
send_signal (Pid , " TSTP" ),
122
- timer :sleep (10000 ),
133
+ timer :sleep (? SLEEP ),
123
134
A = rabbit_ct_broker_helpers :get_node_config (Config , 0 , nodename ),
124
135
? assert (rabbit_ct_broker_helpers :rpc (Config , A , rabbit , is_running , [])),
125
136
? assert (filelib :is_regular (PidFile )).
@@ -149,12 +160,3 @@ send_signal(Pid, Signal) ->
149
160
" -" ++ Signal ,
150
161
Pid ],
151
162
? 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