Skip to content

Commit b1adabe

Browse files
committed
wip
1 parent 1d049ae commit b1adabe

File tree

1 file changed

+27
-69
lines changed

1 file changed

+27
-69
lines changed

deps/rabbitmq_ct_helpers/src/rabbit_ct_broker_helpers.erl

Lines changed: 27 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -646,29 +646,29 @@ write_config_file(Config, NodeConfig, _I) ->
646646

647647
-define(REQUIRED_FEATURE_FLAGS, [
648648
%% Required in 3.11:
649-
"virtual_host_metadata,"
650-
"quorum_queue,"
651-
"implicit_default_bindings,"
652-
"maintenance_mode_status,"
653-
"user_limits,"
649+
virtual_host_metadata,
650+
quorum_queue,
651+
implicit_default_bindings,
652+
maintenance_mode_status,
653+
user_limits,
654654
%% Required in 3.12:
655-
"stream_queue,"
656-
"classic_queue_type_delivery_support,"
657-
"tracking_records_in_ets,"
658-
"stream_single_active_consumer,"
659-
"listener_records_in_ets,"
660-
"feature_flags_v2,"
661-
"direct_exchange_routing_v2,"
662-
"classic_mirrored_queue_version," %% @todo Missing in FF docs!!
655+
stream_queue,
656+
classic_queue_type_delivery_support,
657+
tracking_records_in_ets,
658+
stream_single_active_consumer,
659+
listener_records_in_ets,
660+
feature_flags_v2,
661+
direct_exchange_routing_v2,
662+
classic_mirrored_queue_version, %% @todo Missing in FF docs!!
663663
%% Required in 3.12 in rabbitmq_management_agent:
664-
% "drop_unroutable_metric,"
665-
% "empty_basic_get_metric,"
664+
% drop_unroutable_metric,
665+
% empty_basic_get_metric,
666666
%% Required in 4.0:
667-
"stream_sac_coordinator_unblock_group,"
668-
"restart_streams,"
669-
"stream_update_config_command,"
670-
"stream_filtering,"
671-
"message_containers" %% @todo Update FF docs!! It *is* required.
667+
stream_sac_coordinator_unblock_group,
668+
restart_streams,
669+
stream_update_config_command,
670+
stream_filtering,
671+
message_containers %% @todo Update FF docs!! It *is* required.
672672
]).
673673

674674
do_start_rabbitmq_node(Config, NodeConfig, I) ->
@@ -795,13 +795,17 @@ do_start_rabbitmq_node(Config, NodeConfig, I) ->
795795
{_, undefined, SrcPlugin} -> SrcPlugin;
796796
{_, SecondaryEnabledPlugins0, _} -> SecondaryEnabledPlugins0
797797
end,
798+
RequiredFeatureFlags = string:join(
799+
[atom_to_list(F) ||
800+
F <- ?REQUIRED_FEATURE_FLAGS],
801+
","),
798802
[{"DIST_DIR=~ts/plugins", [SecondaryDist]},
799803
{"CLI_SCRIPTS_DIR=~ts/sbin", [SecondaryDist]},
800804
{"CLI_ESCRIPTS_DIR=~ts/escript", [SecondaryDist]},
801805
{"RABBITMQ_SCRIPTS_DIR=~ts/sbin", [SecondaryDist]},
802806
{"RABBITMQ_SERVER=~ts/sbin/rabbitmq-server", [SecondaryDist]},
803807
{"RABBITMQ_ENABLED_PLUGINS=~ts", [SecondaryEnabledPlugins]},
804-
{"RABBITMQ_FEATURE_FLAGS=~ts", [?REQUIRED_FEATURE_FLAGS]}
808+
{"RABBITMQ_FEATURE_FLAGS=~ts", [RequiredFeatureFlags]}
805809
| ExtraArgs4];
806810
false ->
807811
ExtraArgs4
@@ -901,18 +905,9 @@ query_node(Config, NodeConfig) ->
901905

902906
uses_expected_metadata_store(Config, NodeConfig) ->
903907
%% We want to verify if the active metadata store matches the expected one.
904-
%%
905-
%% Before that, we may need to enable `khepri_db' on the node because if it
906-
%% doesn't support the relative forced feature flags mechanism, it will
907-
%% ignore the setting from `configure_metadata_store/1'. In this case, we
908-
%% have to enable it at runtime.
909908
Nodename = ?config(nodename, NodeConfig),
910909
ExpectedMetadataStore = rabbit_ct_helpers:get_config(
911910
Config, metadata_store),
912-
case ExpectedMetadataStore of
913-
mnesia -> ok;
914-
khepri -> maybe_enable_khepri_as_expected(Config, Nodename)
915-
end,
916911
IsKhepriEnabled = rpc(Config, Nodename, rabbit_khepri, is_enabled, []),
917912
UsedMetadataStore = case IsKhepriEnabled of
918913
true -> khepri;
@@ -923,43 +918,6 @@ uses_expected_metadata_store(Config, NodeConfig) ->
923918
[Nodename, UsedMetadataStore, ExpectedMetadataStore]),
924919
{ExpectedMetadataStore, UsedMetadataStore}.
925920

926-
maybe_enable_khepri_as_expected(Config, Nodename) ->
927-
%% We detect if the remote node supports the relative forced feature flags
928-
%% mechanism by checking if `rabbit_feature_flags:get_require_level/1' is
929-
%% exported. This is unrelated to the mechanism but it was committed around
930-
%% the same time and was not backported either.
931-
RelativeForcedFeatureFlagsUnsupported = (
932-
rpc(Config, Nodename,
933-
erlang, function_exported,
934-
[rabbit_feature_flags, get_require_level, 1])
935-
),
936-
case RelativeForcedFeatureFlagsUnsupported of
937-
true ->
938-
ok;
939-
false ->
940-
ct:pal(
941-
"Relative forced feature flags unsupported on ~s, "
942-
"enable Khepri now to enable expected metadata store",
943-
[Nodename]),
944-
Ret = enable_feature_flag(Config, [Nodename], khepri_db),
945-
case Ret of
946-
ok ->
947-
ok;
948-
{error, missing_clustered_nodes} ->
949-
ct:pal(
950-
"Tried to enable Khepri on ~s as expected, but node "
951-
"not ready; retrying in 1 second",
952-
[Nodename]),
953-
timer:sleep(1000),
954-
maybe_enable_khepri_as_expected(Config, Nodename);
955-
_ ->
956-
ct:pal(
957-
"Tried to enable Khepri on ~s as expected: ~0p",
958-
[Nodename, Ret]),
959-
ok
960-
end
961-
end.
962-
963921
maybe_cluster_nodes(Config) ->
964922
Clustered0 = rabbit_ct_helpers:get_config(Config, rmq_nodes_clustered),
965923
Clustered = case Clustered0 of
@@ -1109,7 +1067,7 @@ configure_metadata_store(Config) ->
11091067
Config1,
11101068
{rabbit,
11111069
[{forced_feature_flags_on_init,
1112-
{rel, [khepri_db], []}}]});
1070+
[khepri_db | ?REQUIRED_FEATURE_FLAGS]}]});
11131071
_ ->
11141072
rabbit_ct_helpers:merge_app_env(
11151073
Config1,
@@ -1125,7 +1083,7 @@ configure_metadata_store(Config) ->
11251083
Config1,
11261084
{rabbit,
11271085
[{forced_feature_flags_on_init,
1128-
{rel, [], [khepri_db]}}]});
1086+
?REQUIRED_FEATURE_FLAGS}]});
11291087
_ ->
11301088
rabbit_ct_helpers:merge_app_env(
11311089
Config1,

0 commit comments

Comments
 (0)