Skip to content

Commit 69d407e

Browse files
committed
Simplify test cases
1. Only run the CLI tests on a single node cluster. The shared_SUITE is already very big. Testing the same CLI commands against node-0 on a 3-node cluster brings no benefit. 2. Move the two new CLI test cases in front of management_plugin_connection because they are similar in that all three tests close the MQTT connection. 3. There is no need to query the HTTP API for the two new CLI test cases. 4. There is no need to set keepalive in the two new CLI test cases.
1 parent ea6ef17 commit 69d407e

File tree

1 file changed

+22
-40
lines changed

1 file changed

+22
-40
lines changed

deps/rabbitmq_mqtt/test/shared_SUITE.erl

Lines changed: 22 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ cluster_size_1_tests() ->
9191
,block_only_publisher
9292
,many_qos1_messages
9393
,session_expiry
94+
,cli_close_all_connections
95+
,cli_close_all_user_connections
9496
,management_plugin_connection
9597
,management_plugin_enable
9698
,disconnect
@@ -129,8 +131,6 @@ cluster_size_1_tests() ->
129131
,retained_message_conversion
130132
,bind_exchange_to_exchange
131133
,bind_exchange_to_exchange_single_message
132-
,cli_close_all_connections
133-
,cli_close_all_user_connections
134134
].
135135

136136
cluster_size_3_tests() ->
@@ -143,8 +143,6 @@ cluster_size_3_tests() ->
143143
rabbit_mqtt_qos0_queue,
144144
rabbit_mqtt_qos0_queue_kill_node,
145145
cli_list_queues,
146-
cli_close_all_connections,
147-
cli_close_all_user_connections,
148146
delete_create_queue,
149147
session_reconnect,
150148
session_takeover,
@@ -211,9 +209,7 @@ end_per_group(_, Config) ->
211209

212210
init_per_testcase(T, Config)
213211
when T =:= management_plugin_connection;
214-
T =:= management_plugin_enable;
215-
T =:= cli_close_all_user_connections;
216-
T =:= cli_close_all_connections ->
212+
T =:= management_plugin_enable ->
217213
inets:start(),
218214
init_per_testcase0(T, Config);
219215
init_per_testcase(Testcase, Config) ->
@@ -226,9 +222,7 @@ init_per_testcase0(Testcase, Config) ->
226222

227223
end_per_testcase(T, Config)
228224
when T =:= management_plugin_connection;
229-
T =:= management_plugin_enable;
230-
T =:= cli_close_all_user_connections;
231-
T =:= cli_close_all_connections ->
225+
T =:= management_plugin_enable ->
232226
ok = inets:stop(),
233227
end_per_testcase0(T, Config);
234228
end_per_testcase(Testcase, Config) ->
@@ -1173,6 +1167,24 @@ rabbit_mqtt_qos0_queue_kill_node(Config) ->
11731167
ok = rabbit_ct_broker_helpers:start_node(Config, 1),
11741168
?assertEqual([], rpc(Config, rabbit_db_binding, get_all, [])).
11751169

1170+
cli_close_all_connections(Config) ->
1171+
ClientId = atom_to_binary(?FUNCTION_NAME),
1172+
C = connect(ClientId, Config),
1173+
process_flag(trap_exit, true),
1174+
{ok, String} = rabbit_ct_broker_helpers:rabbitmqctl(
1175+
Config, 0, ["close_all_connections", "bye"]),
1176+
?assertEqual(match, re:run(String, "Closing .* reason: bye", [{capture, none}])),
1177+
ok = await_exit(C).
1178+
1179+
cli_close_all_user_connections(Config) ->
1180+
ClientId = atom_to_binary(?FUNCTION_NAME),
1181+
C = connect(ClientId, Config),
1182+
process_flag(trap_exit, true),
1183+
{ok, String} = rabbit_ct_broker_helpers:rabbitmqctl(
1184+
Config, 0, ["close_all_user_connections","guest", "bye"]),
1185+
?assertEqual(match, re:run(String, "Closing .* reason: bye", [{capture, none}])),
1186+
ok = await_exit(C).
1187+
11761188
%% Test that MQTT connection can be listed and closed via the rabbitmq_management plugin.
11771189
management_plugin_connection(Config) ->
11781190
KeepaliveSecs = 99,
@@ -1216,36 +1228,6 @@ management_plugin_enable(Config) ->
12161228

12171229
ok = emqtt:disconnect(C).
12181230

1219-
cli_close_all_connections(Config) ->
1220-
KeepaliveSecs = 99,
1221-
ClientId = atom_to_binary(?FUNCTION_NAME),
1222-
1223-
_ = connect(ClientId, Config, [{keepalive, KeepaliveSecs}]),
1224-
eventually(?_assertEqual(1, length(http_get(Config, "/connections"))), 1000, 10),
1225-
1226-
process_flag(trap_exit, true),
1227-
{ok, String} = rabbit_ct_broker_helpers:rabbitmqctl(Config, 0, ["close_all_connections", "bye"]),
1228-
?assertEqual(match, re:run(String, "Closing .* reason: bye", [{capture, none}])),
1229-
1230-
process_flag(trap_exit, false),
1231-
eventually(?_assertEqual([], http_get(Config, "/connections")),
1232-
1000, 10).
1233-
1234-
cli_close_all_user_connections(Config) ->
1235-
KeepaliveSecs = 99,
1236-
ClientId = atom_to_binary(?FUNCTION_NAME),
1237-
1238-
_ = connect(ClientId, Config, [{keepalive, KeepaliveSecs}]),
1239-
eventually(?_assertEqual(1, length(http_get(Config, "/connections"))), 1000, 10),
1240-
1241-
process_flag(trap_exit, true),
1242-
{ok, String} = rabbit_ct_broker_helpers:rabbitmqctl(Config, 0, ["close_all_user_connections","guest", "bye"]),
1243-
?assertEqual(match, re:run(String, "Closing .* reason: bye", [{capture, none}])),
1244-
1245-
process_flag(trap_exit, false),
1246-
eventually(?_assertEqual([], http_get(Config, "/connections")),
1247-
1000, 10).
1248-
12491231
%% Test that queues of type rabbit_mqtt_qos0_queue can be listed via rabbitmqctl.
12501232
cli_list_queues(Config) ->
12511233
C = connect(?FUNCTION_NAME, Config),

0 commit comments

Comments
 (0)