Skip to content

Commit 0d78796

Browse files
dumbbellmergify[bot]
authored andcommitted
v5_SUITE: Close all connections in end_per_testcase/2
[Why] Many tests do not clean up their connections if they encounter a failure. This affects subsequent testcases negatively. (cherry picked from commit 97da746) (cherry picked from commit 5c0d16e)
1 parent 8cd7f66 commit 0d78796

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

deps/rabbitmq_mqtt/test/v5_SUITE.erl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,10 +206,27 @@ end_per_testcase(T, Config) ->
206206
end_per_testcase0(T, Config).
207207

208208
end_per_testcase0(Testcase, Config) ->
209+
%% Terminate all connections and wait for sessions to terminate before
210+
%% starting the next test case.
211+
_ = rabbit_ct_broker_helpers:rpc(
212+
Config, 0,
213+
rabbit_networking, close_all_connections, [<<"test finished">>]),
214+
_ = rabbit_ct_broker_helpers:rpc_all(
215+
Config,
216+
rabbit_mqtt, close_local_client_connections, [normal]),
217+
eventually(?_assertEqual(
218+
[],
219+
rpc(Config, rabbit_mqtt, local_connection_pids, []))),
209220
%% Assert that every testcase cleaned up their MQTT sessions.
221+
rabbit_ct_broker_helpers:rpc(Config, 0, ?MODULE, delete_queues, []),
210222
eventually(?_assertEqual([], rpc(Config, rabbit_amqqueue, list, []))),
211223
rabbit_ct_helpers:testcase_finished(Config, Testcase).
212224

225+
delete_queues() ->
226+
_ = [catch rabbit_amqqueue:delete(Q, false, false, <<"test finished">>)
227+
|| Q <- rabbit_amqqueue:list()],
228+
ok.
229+
213230
%% -------------------------------------------------------------------
214231
%% Testsuite cases
215232
%% -------------------------------------------------------------------

0 commit comments

Comments
 (0)