Skip to content

Commit 8dd9fa3

Browse files
etcd peer discovery: only enable etcd auth where it makes a difference #15192 #15191
1 parent b27de42 commit 8dd9fa3

1 file changed

Lines changed: 32 additions & 10 deletions

File tree

deps/rabbitmq_peer_discovery_etcd/test/system_SUITE.erl

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,13 @@
3333

3434
all() ->
3535
[
36-
{group, v3_client},
37-
{group, clustering}
36+
%% Run clustering tests first (without auth) to ensure backwards
37+
%% compatibility with mixed cluster mode where older nodes don't
38+
%% have the deobfuscate/1 fix.
39+
{group, clustering},
40+
%% Then run v3_client tests which enable auth and verify the fix.
41+
%% Once auth is enabled on etcd, it stays enabled.
42+
{group, v3_client}
3843
].
3944

4045
groups() ->
@@ -58,11 +63,24 @@ init_per_suite(Config) ->
5863
end_per_suite(Config) ->
5964
rabbit_ct_helpers:run_teardown_steps(Config, [fun stop_etcd/1]).
6065

66+
init_per_group(v3_client, Config) ->
67+
%% Enable etcd authentication for v3_client tests only.
68+
%% These tests run the client directly (no RabbitMQ nodes), so they
69+
%% can test with authentication enabled. This verifies the fix for
70+
%% the double-wrapping bug in deobfuscate/1.
71+
enable_etcd_auth(Config),
72+
Config;
6173
init_per_group(clustering, Config) ->
74+
%% Don't use authentication for clustering tests. In mixed cluster mode,
75+
%% older nodes may not have the fix for the double-wrapping bug and would
76+
%% fail to authenticate. The clustering tests verify that peer discovery
77+
%% works correctly; authentication is tested by the v3_client group.
6278
Config1 = rabbit_ct_helpers:set_config(
6379
Config,
6480
[{rmq_nodes_count, 3},
65-
{rmq_nodes_clustered, false}]),
81+
{rmq_nodes_clustered, false},
82+
{etcd_username, undefined},
83+
{etcd_password, undefined}]),
6684
rabbit_ct_helpers:merge_app_env(
6785
Config1, {rabbit, [{forced_feature_flags_on_init, []}]});
6886
init_per_group(_Group, Config) ->
@@ -238,7 +256,6 @@ start_etcd(Config) ->
238256
logger:set_primary_config(level, critical),
239257
try
240258
wait_for_etcd(EtcdEndpoints),
241-
enable_etcd_auth(Config1),
242259
Config1
243260
catch
244261
exit:{test_case_failed, _} ->
@@ -445,17 +462,22 @@ configure_peer_discovery(Config) ->
445462
Endpoints = ?config(etcd_endpoints, Config),
446463
Username = ?config(etcd_username, Config),
447464
Password = ?config(etcd_password, Config),
465+
EtcdConfig0 = [{endpoints, Endpoints},
466+
{etcd_prefix, "rabbitmq"},
467+
{cluster_name, atom_to_list(?FUNCTION_NAME)}],
468+
%% Only include credentials when they're defined (not for clustering tests
469+
%% in mixed cluster mode where older nodes don't have the deobfuscate fix)
470+
EtcdConfig = case Username of
471+
undefined -> EtcdConfig0;
472+
_ -> EtcdConfig0 ++ [{etcd_username, Username},
473+
{etcd_password, Password}]
474+
end,
448475
Config1 = rabbit_ct_helpers:merge_app_env(
449476
Config,
450477
{rabbit,
451478
[{cluster_formation,
452479
[{peer_discovery_backend, rabbit_peer_discovery_etcd},
453-
{peer_discovery_etcd,
454-
[{endpoints, Endpoints},
455-
{etcd_prefix, "rabbitmq"},
456-
{cluster_name, atom_to_list(?FUNCTION_NAME)},
457-
{etcd_username, Username},
458-
{etcd_password, Password}]}]}]}),
480+
{peer_discovery_etcd, EtcdConfig}]}]}),
459481
lists:foreach(
460482
fun(Node) ->
461483
?assertEqual(

0 commit comments

Comments
 (0)