Skip to content

Commit c7afc29

Browse files
committed
rabbit_feature_flags: Add testcase after issue #12963
[Why] Up-to RabbitMQ 3.13.x, there was a case where if: 1. you enabled a plugin 2. you enabled its feature flags 3. you disabled the plugin 4. you restarted a node (or upgraded it) ... the node could crash on startup because it had a feature flag marked as enabled that it didn't know about: error:{badmatch,#{feature_flags => ... rabbit_ff_controller:-check_one_way_compatibility/2-fun-0-/3, line 514 lists:all_1/2, line 1520 rabbit_ff_controller:are_compatible/2, line 496 rabbit_ff_controller:check_node_compatibility_task1/4, line 437 rabbit_db_cluster:check_compatibility/1, line 376 This was "fixed" by the new way of keeping the registry in memory (#10988) because it introduces a slight change of behavior. Indeed, the old way walked through the `FeatureFlags` map and looked up the state in the `FeatureStates` map to create the `is_enabled/1` function. The new way just looks up the state in `FeatureStates`. [How] The new testcase succeeds on 4.0.x and `main`, but would fail on 3.13.x with the aforementionne crash.
1 parent 55459bc commit c7afc29

File tree

1 file changed

+51
-2
lines changed

1 file changed

+51
-2
lines changed

deps/rabbit/test/feature_flags_SUITE.erl

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@
4545
clustering_ok_with_new_ff_enabled_from_plugin_on_some_nodes/1,
4646
clustering_ok_with_supported_required_ff/1,
4747
activating_plugin_with_new_ff_disabled/1,
48-
activating_plugin_with_new_ff_enabled/1
48+
activating_plugin_with_new_ff_enabled/1,
49+
restart_node_with_unknown_enabled_feature_flag/1
4950
]).
5051

5152
suite() ->
@@ -95,7 +96,8 @@ groups() ->
9596
{activating_plugin, [],
9697
[
9798
activating_plugin_with_new_ff_disabled,
98-
activating_plugin_with_new_ff_enabled
99+
activating_plugin_with_new_ff_enabled,
100+
restart_node_with_unknown_enabled_feature_flag
99101
]}
100102
],
101103

@@ -1260,6 +1262,53 @@ activating_plugin_with_new_ff_enabled(Config) ->
12601262
end,
12611263
ok.
12621264

1265+
restart_node_with_unknown_enabled_feature_flag(Config) ->
1266+
FFSubsysOk = is_feature_flag_subsystem_available(Config),
1267+
1268+
log_feature_flags_of_all_nodes(Config),
1269+
case FFSubsysOk of
1270+
true ->
1271+
?assertEqual([false, false],
1272+
is_feature_flag_supported(Config, plugin_ff)),
1273+
?assertEqual([false, false],
1274+
is_feature_flag_enabled(Config, plugin_ff));
1275+
false ->
1276+
ok
1277+
end,
1278+
1279+
rabbit_ct_broker_helpers:enable_plugin(Config, 0, "my_plugin"),
1280+
rabbit_ct_broker_helpers:enable_plugin(Config, 1, "my_plugin"),
1281+
rabbit_ct_broker_helpers:disable_plugin(Config, 0, "my_plugin"),
1282+
rabbit_ct_broker_helpers:disable_plugin(Config, 1, "my_plugin"),
1283+
1284+
enable_feature_flag_on(Config, 0, plugin_ff),
1285+
case FFSubsysOk of
1286+
true ->
1287+
enable_feature_flag_on(Config, 0, plugin_ff),
1288+
?assertEqual([true, true],
1289+
is_feature_flag_supported(Config, plugin_ff)),
1290+
?assertEqual([true, true],
1291+
is_feature_flag_enabled(Config, plugin_ff));
1292+
false ->
1293+
ok
1294+
end,
1295+
1296+
rabbit_ct_broker_helpers:restart_node(Config, 0),
1297+
rabbit_ct_broker_helpers:restart_node(Config, 1),
1298+
1299+
log_feature_flags_of_all_nodes(Config),
1300+
case FFSubsysOk of
1301+
true ->
1302+
enable_feature_flag_on(Config, 0, plugin_ff),
1303+
?assertEqual([false, false],
1304+
is_feature_flag_supported(Config, plugin_ff)),
1305+
?assertEqual([false, false],
1306+
is_feature_flag_enabled(Config, plugin_ff));
1307+
false ->
1308+
ok
1309+
end,
1310+
ok.
1311+
12631312
%% -------------------------------------------------------------------
12641313
%% Internal helpers.
12651314
%% -------------------------------------------------------------------

0 commit comments

Comments
 (0)