Skip to content

Commit a3dd386

Browse files
committed
Skip peer discovery clustering tests if multiple Khepri machine versions
... are being used at the same time. [Why] Depending on which node clusters with which, a node running an older version of the Khepri Ra machine may not be able to apply Ra commands and could be stuck. There is no real solution and this clearly an unsupported scenario. An old node won't always be able to join a newer cluster. [How] In the testsuites, we skip clustering tests if we detect that multiple Khepri Ra machine versions are being used. (cherry picked from commit 1f1a135)
1 parent beab2cd commit a3dd386

File tree

3 files changed

+53
-8
lines changed

3 files changed

+53
-8
lines changed

deps/rabbitmq_ct_helpers/src/rabbit_ct_broker_helpers.erl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,8 @@
173173
user/1,
174174

175175
configured_metadata_store/1,
176-
await_metadata_store_consistent/2
176+
await_metadata_store_consistent/2,
177+
do_nodes_run_same_ra_machine_version/2
177178
]).
178179

179180
%% Internal functions exported to be used by rpc:call/4.
@@ -1102,6 +1103,12 @@ ra_last_applied(ServerId) ->
11021103
#{last_applied := LastApplied} = ra:key_metrics(ServerId),
11031104
LastApplied.
11041105

1106+
do_nodes_run_same_ra_machine_version(Config, RaMachineMod) ->
1107+
[MacVer1 | MacVerN] = MacVers = rpc_all(Config, RaMachineMod, version, []),
1108+
ct:pal("Ra machine versions of ~s: ~0p", [RaMachineMod, MacVers]),
1109+
is_integer(MacVer1) andalso
1110+
lists:all(fun(MacVer) -> MacVer =:= MacVer1 end, MacVerN).
1111+
11051112
rewrite_node_config_file(Config, Node) ->
11061113
NodeConfig = get_node_config(Config, Node),
11071114
I = if

deps/rabbitmq_peer_discovery_consul/test/system_SUITE.erl

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,27 @@ init_per_testcase(Testcase, Config)
8383
case Config3 of
8484
_ when is_list(Config3) ->
8585
try
86-
_ = rabbit_ct_broker_helpers:rpc_all(
87-
Config3, rabbit_peer_discovery_backend, api_version, []),
88-
Config3
86+
SameMacVer = (
87+
rabbit_ct_broker_helpers:
88+
do_nodes_run_same_ra_machine_version(
89+
Config3, khepri_machine)),
90+
case SameMacVer of
91+
true ->
92+
_ = rabbit_ct_broker_helpers:rpc_all(
93+
Config3,
94+
rabbit_peer_discovery_backend, api_version, []),
95+
Config3;
96+
false ->
97+
Config5 = rabbit_ct_helpers:run_steps(
98+
Config3,
99+
rabbit_ct_client_helpers:teardown_steps()
100+
++
101+
rabbit_ct_broker_helpers:teardown_steps()),
102+
rabbit_ct_helpers:testcase_finished(Config5, Testcase),
103+
{skip,
104+
"Nodes are using different Khepri Ra machine "
105+
"versions; clustering will likely fail"}
106+
end
89107
catch
90108
error:{exception, undef,
91109
[{rabbit_peer_discovery_backend, api_version, _, _}

deps/rabbitmq_peer_discovery_etcd/test/system_SUITE.erl

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,27 @@ init_per_testcase(Testcase, Config)
9292
case Config3 of
9393
_ when is_list(Config3) ->
9494
try
95-
_ = rabbit_ct_broker_helpers:rpc_all(
96-
Config3, rabbit_peer_discovery_backend, api_version, []),
97-
Config3
95+
SameMacVer = (
96+
rabbit_ct_broker_helpers:
97+
do_nodes_run_same_ra_machine_version(
98+
Config3, khepri_machine)),
99+
case SameMacVer of
100+
true ->
101+
_ = rabbit_ct_broker_helpers:rpc_all(
102+
Config3,
103+
rabbit_peer_discovery_backend, api_version, []),
104+
Config3;
105+
false ->
106+
Config5 = rabbit_ct_helpers:run_steps(
107+
Config3,
108+
rabbit_ct_client_helpers:teardown_steps()
109+
++
110+
rabbit_ct_broker_helpers:teardown_steps()),
111+
rabbit_ct_helpers:testcase_finished(Config5, Testcase),
112+
{skip,
113+
"Nodes are using different Khepri Ra machine "
114+
"versions; clustering will likely fail"}
115+
end
98116
catch
99117
error:{exception, undef,
100118
[{rabbit_peer_discovery_backend, api_version, _, _}
@@ -239,7 +257,9 @@ wait_for_etcd(EtcdEndpoints) ->
239257
Timeout = 60000,
240258
rabbit_ct_helpers:await_condition(
241259
fun() ->
242-
case eetcd:open(test, EtcdEndpoints) of
260+
Ret = eetcd:open(test, EtcdEndpoints),
261+
ct:pal("Ret = ~p", [Ret]),
262+
case Ret of
243263
{ok, _Pid} -> true;
244264
_ -> false
245265
end

0 commit comments

Comments
 (0)