Skip to content

Commit 4ac4a64

Browse files
dumbbellansd
authored andcommitted
rabbitmq_ct_helpers: Fix how we set $RABBITMQ_FEATURE_FLAGS in tests
[Why] In order to make `khepri_db` the default in the future, the handling of `$RABBITMQ_FEATURE_FLAGS` had to be adapted to be able to *disable* Khepri instead. Unfortunately I broke the behavior with stable feature flags that are only available in the primary umbrella. In this case, they were automatically enabled and thus, clustering with an old umbrella that did not have these feature flags failed with `incompatible_feature_flags`. [How] The solution is to always use an absolute list of feature flags, not the new relative list.
1 parent e69a4c8 commit 4ac4a64

File tree

1 file changed

+15
-66
lines changed

1 file changed

+15
-66
lines changed

deps/rabbitmq_ct_helpers/src/rabbit_ct_broker_helpers.erl

Lines changed: 15 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -762,17 +762,6 @@ do_start_rabbitmq_node(Config, NodeConfig, I) ->
762762
false -> ExtraArgs3;
763763
_ -> ["NOBUILD=1" | ExtraArgs3]
764764
end,
765-
%% TODO: When we start to do mixed-version testing against 4.1.x as the
766-
%% secondary umbrella, we will need to stop setting
767-
%% `$RABBITMQ_FEATURE_FLAGS'.
768-
MetadataStore = rabbit_ct_helpers:get_config(Config, metadata_store),
769-
SecFeatureFlags0 = case MetadataStore of
770-
mnesia -> ?REQUIRED_FEATURE_FLAGS;
771-
khepri -> [khepri_db | ?REQUIRED_FEATURE_FLAGS]
772-
end,
773-
SecFeatureFlags = string:join(
774-
[atom_to_list(F) || F <- SecFeatureFlags0],
775-
","),
776765
ExtraArgs = case UseSecondaryUmbrella of
777766
true ->
778767
DepsDir = ?config(erlang_mk_depsdir, Config),
@@ -802,8 +791,7 @@ do_start_rabbitmq_node(Config, NodeConfig, I) ->
802791
{"RABBITMQ_SCRIPTS_DIR=~ts", [SecScriptsDir]},
803792
{"RABBITMQ_SERVER=~ts/rabbitmq-server", [SecScriptsDir]},
804793
{"RABBITMQCTL=~ts/rabbitmqctl", [SecScriptsDir]},
805-
{"RABBITMQ_PLUGINS=~ts/rabbitmq-plugins", [SecScriptsDir]},
806-
{"RABBITMQ_FEATURE_FLAGS=~ts", [SecFeatureFlags]}
794+
{"RABBITMQ_PLUGINS=~ts/rabbitmq-plugins", [SecScriptsDir]}
807795
| ExtraArgs4];
808796
false ->
809797
case UseSecondaryDist of
@@ -824,8 +812,7 @@ do_start_rabbitmq_node(Config, NodeConfig, I) ->
824812
{"CLI_ESCRIPTS_DIR=~ts/escript", [SecondaryDist]},
825813
{"RABBITMQ_SCRIPTS_DIR=~ts/sbin", [SecondaryDist]},
826814
{"RABBITMQ_SERVER=~ts/sbin/rabbitmq-server", [SecondaryDist]},
827-
{"RABBITMQ_ENABLED_PLUGINS=~ts", [SecondaryEnabledPlugins]},
828-
{"RABBITMQ_FEATURE_FLAGS=~ts", [SecFeatureFlags]}
815+
{"RABBITMQ_ENABLED_PLUGINS=~ts", [SecondaryEnabledPlugins]}
829816
| ExtraArgs4];
830817
false ->
831818
ExtraArgs4
@@ -1066,60 +1053,22 @@ configured_metadata_store(Config) ->
10661053

10671054
configure_metadata_store(Config) ->
10681055
ct:log("Configuring metadata store..."),
1069-
Value = rabbit_ct_helpers:get_app_env(
1070-
Config, rabbit, forced_feature_flags_on_init, undefined),
10711056
MetadataStore = configured_metadata_store(Config),
10721057
Config1 = rabbit_ct_helpers:set_config(
10731058
Config, {metadata_store, MetadataStore}),
1074-
%% To enabled or disable `khepri_db', we use the relative forced feature
1075-
%% flags mechanism. This allows us to select the state of Khepri without
1076-
%% having to worry about other feature flags.
1077-
%%
1078-
%% However, RabbitMQ 4.0.x and older don't support it. See the
1079-
%% `uses_expected_metadata_store/2' check to see how Khepri is enabled in
1080-
%% this case.
1081-
%%
1082-
%% Note that this setting will be ignored by the secondary umbrella because
1083-
%% we set `$RABBITMQ_FEATURE_FLAGS' explisitly. In this case, we handle the
1084-
%% `khepri_db' feature flag when we compute the value of that variable.
1085-
%%
1086-
%% TODO: When we start to do mixed-version testing against 4.1.x as the
1087-
%% secondary umbrella, we will need to stop setting
1088-
%% `$RABBITMQ_FEATURE_FLAGS'.
1089-
case MetadataStore of
1090-
khepri ->
1091-
ct:log("Enabling Khepri metadata store"),
1092-
case Value of
1093-
undefined ->
1094-
rabbit_ct_helpers:merge_app_env(
1095-
Config1,
1096-
{rabbit,
1097-
[{forced_feature_flags_on_init,
1098-
{rel, [khepri_db], []}}]});
1099-
_ ->
1100-
rabbit_ct_helpers:merge_app_env(
1101-
Config1,
1102-
{rabbit,
1103-
[{forced_feature_flags_on_init,
1104-
[khepri_db | Value]}]})
1105-
end;
1106-
mnesia ->
1107-
ct:log("Enabling Mnesia metadata store"),
1108-
case Value of
1109-
undefined ->
1110-
rabbit_ct_helpers:merge_app_env(
1111-
Config1,
1112-
{rabbit,
1113-
[{forced_feature_flags_on_init,
1114-
{rel, [], [khepri_db]}}]});
1115-
_ ->
1116-
rabbit_ct_helpers:merge_app_env(
1117-
Config1,
1118-
{rabbit,
1119-
[{forced_feature_flags_on_init,
1120-
Value -- [khepri_db]}]})
1121-
end
1122-
end.
1059+
FeatureNames0 = case MetadataStore of
1060+
mnesia ->
1061+
ct:log("Enabling Mnesia metadata store"),
1062+
?REQUIRED_FEATURE_FLAGS;
1063+
khepri ->
1064+
ct:log("Enabling Khepri metadata store"),
1065+
[khepri_db | ?REQUIRED_FEATURE_FLAGS]
1066+
end,
1067+
OtherFeatureNames = rabbit_ct_helpers:get_app_env(
1068+
Config, rabbit, forced_feature_flags_on_init, []),
1069+
FeatureNames1 = lists:usort(FeatureNames0 ++ OtherFeatureNames),
1070+
rabbit_ct_helpers:merge_app_env(
1071+
Config1, {rabbit, [{forced_feature_flags_on_init, FeatureNames1}]}).
11231072

11241073
%% Waits until the metadata store replica on Node is up to date with the leader.
11251074
await_metadata_store_consistent(Config, Node) ->

0 commit comments

Comments
 (0)