Skip to content

Commit 7cd91a8

Browse files
committed
Do not skip test
On `main` branch and v3.12.6 feature flag delete_ra_cluster_mqtt_node is supported. Instead of skipping the entire test if that feature flag is not enabled, enable the feature flag and run the test. More generally: "Instead of verifying if a feature flag is enabled or not, it's best to enable it and react from the return value (success or failure). Mixed version testing always turn off all feature flags by default. So in the future, even though all nodes supports the mentionned feature flag, the testcase will still be skipped." [JSP]
1 parent c8b9048 commit 7cd91a8

File tree

1 file changed

+34
-46
lines changed

1 file changed

+34
-46
lines changed

deps/rabbitmq_mqtt/test/shared_SUITE.erl

Lines changed: 34 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,11 @@ cluster_size_3_tests() ->
143143
flow_stream,
144144
rabbit_mqtt_qos0_queue,
145145
cli_list_queues,
146-
maintenance,
147146
delete_create_queue,
148147
session_reconnect,
149148
session_takeover,
150-
duplicate_client_id
149+
duplicate_client_id,
150+
maintenance
151151
].
152152

153153
mnesia_store_tests() ->
@@ -1276,38 +1276,34 @@ cli_list_queues(Config) ->
12761276
ok = emqtt:disconnect(C).
12771277

12781278
maintenance(Config) ->
1279-
case is_feature_flag_enabled(Config, delete_ra_cluster_mqtt_node) of
1280-
false ->
1281-
%% When either file rabbit_mqtt_collector changes or different OTP versions
1282-
%% are used for compilation, the rabbit_mqtt_collector module version will
1283-
%% change and cause a bad fun error when executing ra:leader_query/2 remotely.
1284-
{skip, "Anonymous fun as used in ra:leader_query/2 errors when executing "
1285-
"remotely with a different module version"};
1286-
true ->
1287-
C0 = connect(<<"client-0">>, Config, 0, []),
1288-
C1a = connect(<<"client-1a">>, Config, 1, []),
1289-
C1b = connect(<<"client-1b">>, Config, 1, []),
1290-
ClientsNode1 = [C1a, C1b],
1279+
%% When either file rabbit_mqtt_collector changes or different OTP versions
1280+
%% are used for compilation, the rabbit_mqtt_collector module version will
1281+
%% change and cause a bad fun error when executing ra:leader_query/2 remotely.
1282+
ok = rabbit_ct_broker_helpers:enable_feature_flag(Config, delete_ra_cluster_mqtt_node),
12911283

1292-
timer:sleep(500),
1284+
C0 = connect(<<"client-0">>, Config, 0, []),
1285+
C1a = connect(<<"client-1a">>, Config, 1, []),
1286+
C1b = connect(<<"client-1b">>, Config, 1, []),
1287+
ClientsNode1 = [C1a, C1b],
12931288

1294-
ok = drain_node(Config, 2),
1295-
ok = revive_node(Config, 2),
1296-
timer:sleep(500),
1297-
[?assert(erlang:is_process_alive(C)) || C <- [C0, C1a, C1b]],
1289+
timer:sleep(500),
12981290

1299-
process_flag(trap_exit, true),
1300-
ok = drain_node(Config, 1),
1301-
[await_exit(Pid) || Pid <- ClientsNode1],
1302-
[assert_v5_disconnect_reason_code(Config, ?RC_SERVER_SHUTTING_DOWN) || _ <- ClientsNode1],
1303-
ok = revive_node(Config, 1),
1304-
?assert(erlang:is_process_alive(C0)),
1305-
1306-
ok = drain_node(Config, 0),
1307-
await_exit(C0),
1308-
assert_v5_disconnect_reason_code(Config, ?RC_SERVER_SHUTTING_DOWN),
1309-
ok = revive_node(Config, 0)
1310-
end.
1291+
ok = drain_node(Config, 2),
1292+
ok = revive_node(Config, 2),
1293+
timer:sleep(500),
1294+
[?assert(erlang:is_process_alive(C)) || C <- [C0, C1a, C1b]],
1295+
1296+
process_flag(trap_exit, true),
1297+
ok = drain_node(Config, 1),
1298+
[await_exit(Pid) || Pid <- ClientsNode1],
1299+
[assert_v5_disconnect_reason_code(Config, ?RC_SERVER_SHUTTING_DOWN) || _ <- ClientsNode1],
1300+
ok = revive_node(Config, 1),
1301+
?assert(erlang:is_process_alive(C0)),
1302+
1303+
ok = drain_node(Config, 0),
1304+
await_exit(C0),
1305+
assert_v5_disconnect_reason_code(Config, ?RC_SERVER_SHUTTING_DOWN),
1306+
ok = revive_node(Config, 0).
13111307

13121308
keepalive(Config) ->
13131309
KeepaliveSecs = 1,
@@ -1374,21 +1370,18 @@ keepalive_turned_off(Config) ->
13741370
ok = emqtt:disconnect(C).
13751371

13761372
duplicate_client_id(Config) ->
1373+
%% When either file rabbit_mqtt_collector changes or different OTP versions
1374+
%% are used for compilation, the rabbit_mqtt_collector module version will
1375+
%% change and cause a bad fun error when executing ra:leader_query/2 remotely.
1376+
ok = rabbit_ct_broker_helpers:enable_feature_flag(Config, delete_ra_cluster_mqtt_node),
1377+
13771378
[Server1, Server2, _] = rabbit_ct_broker_helpers:get_node_configs(Config, nodename),
13781379
%% Test session takeover by both new and old node in mixed version clusters.
13791380
ClientId1 = <<"c1">>,
13801381
ClientId2 = <<"c2">>,
13811382
C1a = connect(ClientId1, Config, Server2, []),
13821383
C2a = connect(ClientId2, Config, Server1, []),
1383-
case is_feature_flag_enabled(Config, delete_ra_cluster_mqtt_node) of
1384-
true ->
1385-
eventually(?_assertEqual(2, length(all_connection_pids(Config))));
1386-
false ->
1387-
%% When different OTP versions are used for compilation, the
1388-
%% rabbit_mqtt_collector module version will change and cause
1389-
%% a bad fun error when executing ra:leader_query/2 remotely.
1390-
timer:sleep(200)
1391-
end,
1384+
eventually(?_assertEqual(2, length(all_connection_pids(Config)))),
13921385
process_flag(trap_exit, true),
13931386
C1b = connect(ClientId1, Config, Server1, []),
13941387
C2b = connect(ClientId2, Config, Server2, []),
@@ -1397,12 +1390,7 @@ duplicate_client_id(Config) ->
13971390
await_exit(C1a),
13981391
await_exit(C2a),
13991392
timer:sleep(200),
1400-
case is_feature_flag_enabled(Config, delete_ra_cluster_mqtt_node) of
1401-
true ->
1402-
?assertEqual(2, length(all_connection_pids(Config)));
1403-
false ->
1404-
ok
1405-
end,
1393+
?assertEqual(2, length(all_connection_pids(Config))),
14061394
ok = emqtt:disconnect(C1b),
14071395
ok = emqtt:disconnect(C2b),
14081396
eventually(?_assertEqual(0, length(all_connection_pids(Config)))).

0 commit comments

Comments
 (0)