Skip to content

Commit 7d9ff2d

Browse files
committed
rabbitmq_ct_broker_helpers: Use node 2 as the cluster seed node
[Why] When running mixed-version tests, nodes 1/3/5/... are using the primary umbrella, so usually the newest version. Nodes 2/4/6/... are using the secondary umbrella, thus the old version. When clustering, we used to use node 1 (running a new version) as the seed node, meaning other nodes would join it. This complicates things with feature flags because we have to make sure that we start node 1 with new stable feature flags disabled to allow old nodes to join. This is also a problem with Khepri machine versions because the cluster would start with the latest version, which old nodes might not have. [How] This patch changes the logic to use a node running the secondary umbrella as the seed node instead. If there is no node running it, we pick the first node as before.
1 parent a8c8cf2 commit 7d9ff2d

File tree

2 files changed

+44
-13
lines changed

2 files changed

+44
-13
lines changed

deps/rabbit/test/feature_flags_SUITE.erl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -891,7 +891,7 @@ clustering_ok_with_ff_enabled_on_some_nodes(Config) ->
891891
ok
892892
end,
893893

894-
?assertEqual(Config, rabbit_ct_broker_helpers:cluster_nodes(Config)),
894+
?assertEqual(Config, rabbit_ct_broker_helpers:cluster_nodes(Config, 0)),
895895

896896
log_feature_flags_of_all_nodes(Config),
897897
case FFSubsysOk of
@@ -987,7 +987,7 @@ clustering_denied_with_new_ff_enabled(Config) ->
987987
false -> ok
988988
end,
989989

990-
?assertMatch({skip, _}, rabbit_ct_broker_helpers:cluster_nodes(Config)),
990+
?assertMatch({skip, _}, rabbit_ct_broker_helpers:cluster_nodes(Config, 0)),
991991

992992
log_feature_flags_of_all_nodes(Config),
993993
case FFSubsysOk of
@@ -1049,7 +1049,7 @@ clustering_ok_with_new_ff_enabled_from_plugin_on_some_nodes(Config) ->
10491049
false -> ok
10501050
end,
10511051

1052-
?assertEqual(Config, rabbit_ct_broker_helpers:cluster_nodes(Config)),
1052+
?assertEqual(Config, rabbit_ct_broker_helpers:cluster_nodes(Config, 0)),
10531053

10541054
log_feature_flags_of_all_nodes(Config),
10551055
case FFSubsysOk of

deps/rabbitmq_ct_helpers/src/rabbit_ct_broker_helpers.erl

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
stop_rabbitmq_nodes/1,
2424
stop_rabbitmq_nodes_on_vms/1,
2525
rewrite_node_config_file/2,
26-
cluster_nodes/1, cluster_nodes/2,
26+
cluster_nodes/1, cluster_nodes/2, cluster_nodes/3,
2727

2828
setup_meck/1,
2929
setup_meck/2,
@@ -826,7 +826,9 @@ do_start_rabbitmq_node(Config, NodeConfig, I) ->
826826
{ok, _} ->
827827
NodeConfig1 = rabbit_ct_helpers:set_config(
828828
NodeConfig,
829-
[{effective_srcdir, SrcDir},
829+
[{use_secondary_umbrella,
830+
UseSecondaryUmbrella},
831+
{effective_srcdir, SrcDir},
830832
{make_vars_for_node_startup, MakeVars}]),
831833
query_node(Config, NodeConfig1);
832834
_ ->
@@ -936,23 +938,52 @@ maybe_cluster_nodes(Config) ->
936938
end.
937939

938940
cluster_nodes(Config) ->
939-
[NodeConfig1 | NodeConfigs] = get_node_configs(Config),
940-
cluster_nodes1(Config, NodeConfig1, NodeConfigs).
941+
Nodenames = get_node_configs(Config, nodename),
942+
cluster_nodes(Config, Nodenames).
943+
944+
cluster_nodes(Config, Nodes) when is_list(Nodes) ->
945+
NodeConfigs = [get_node_config(Config, Node) || Node <- Nodes],
946+
Search = lists:search(
947+
fun(NodeConfig) ->
948+
rabbit_ct_helpers:get_config(
949+
NodeConfig, use_secondary_umbrella, false)
950+
end, NodeConfigs),
951+
case Search of
952+
{value, SecNodeConfig} ->
953+
NodeConfigs1 = NodeConfigs -- [SecNodeConfig],
954+
Nodename = ?config(nodename, SecNodeConfig),
955+
ct:pal(
956+
"Using secondary-umbrella-based node ~s as the cluster seed "
957+
"node",
958+
[Nodename]),
959+
cluster_nodes1(Config, SecNodeConfig, NodeConfigs1);
960+
false ->
961+
[NodeConfig | NodeConfigs1] = NodeConfigs,
962+
Nodename = ?config(nodename, NodeConfig),
963+
ct:pal(
964+
"Using node ~s as the cluster seed node",
965+
[Nodename]),
966+
cluster_nodes1(Config, NodeConfig, NodeConfigs1)
967+
end;
968+
cluster_nodes(Config, SeedNode) ->
969+
Nodenames = get_node_configs(Config, nodename),
970+
cluster_nodes(Config, SeedNode, Nodenames).
941971

942-
cluster_nodes(Config, Nodes) ->
943-
[NodeConfig1 | NodeConfigs] = [
944-
get_node_config(Config, Node) || Node <- Nodes],
945-
cluster_nodes1(Config, NodeConfig1, NodeConfigs).
972+
cluster_nodes(Config, SeedNode, Nodes) ->
973+
SeedNodeConfig = get_node_config(Config, SeedNode),
974+
NodeConfigs = [get_node_config(Config, Node) || Node <- Nodes],
975+
NodeConfigs1 = NodeConfigs -- [SeedNodeConfig],
976+
cluster_nodes1(Config, SeedNodeConfig, NodeConfigs1).
946977

947978
cluster_nodes1(Config, NodeConfig1, [NodeConfig2 | Rest]) ->
948-
case cluster_nodes(Config, NodeConfig2, NodeConfig1) of
979+
case do_cluster_nodes(Config, NodeConfig2, NodeConfig1) of
949980
ok -> cluster_nodes1(Config, NodeConfig1, Rest);
950981
Error -> Error
951982
end;
952983
cluster_nodes1(Config, _, []) ->
953984
Config.
954985

955-
cluster_nodes(Config, NodeConfig1, NodeConfig2) ->
986+
do_cluster_nodes(Config, NodeConfig1, NodeConfig2) ->
956987
Nodename1 = ?config(nodename, NodeConfig1),
957988
Nodename2 = ?config(nodename, NodeConfig2),
958989
Cmds = [

0 commit comments

Comments
 (0)