Skip to content

Commit a3e6909

Browse files
author
Gabriele Santomaggio
committed
Add unit test for AAAA record.
1 parent 61414f9 commit a3e6909

File tree

1 file changed

+25
-9
lines changed

1 file changed

+25
-9
lines changed

test/peer_discovery_dns_SUITE.erl

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ groups() ->
3333
hostname_discovery_with_long_node_names,
3434
hostname_discovery_with_short_node_names,
3535
node_discovery_with_long_node_names,
36-
node_discovery_with_short_node_names
36+
node_discovery_with_short_node_names,
37+
test_aaaa_record_hostname_discovery
3738
]}
3839
].
3940

@@ -54,7 +55,9 @@ suite() ->
5455
%% * One does not resolve to a [typically] non-reachable IP
5556
%% * One does not support reverse lookup queries
5657

57-
-define(DISCOVERY_ENDPOINT, "peer_discovery.tests.rabbitmq.net").
58+
-define(DISCOVERY_ENDPOINT_RECORD_A, "peer_discovery.tests.rabbitmq.net").
59+
60+
-define(DISCOVERY_ENDPOINT_RECORD_AAAA, "www.v6.facebook.com").
5861

5962
init_per_suite(Config) ->
6063
rabbit_ct_helpers:log_environment(),
@@ -63,17 +66,26 @@ init_per_suite(Config) ->
6366
end_per_suite(Config) ->
6467
rabbit_ct_helpers:run_teardown_steps(Config).
6568

69+
70+
init_per_testcase(test_aaaa_record, Config) ->
71+
case inet_res:lookup(?DISCOVERY_ENDPOINT_RECORD_AAAA, in, aaaa) of
72+
[] ->
73+
{skip, "pre-configured AAAA record does not resolve, skipping"};
74+
[_ | _] ->
75+
Config
76+
end;
77+
6678
init_per_testcase(_Testcase, Config) ->
67-
%% TODO: support IPv6-only environments
68-
case inet_res:lookup(?DISCOVERY_ENDPOINT, in, a) of
79+
case inet_res:lookup(?DISCOVERY_ENDPOINT_RECORD_A, in, a) of
6980
[] ->
7081
{skip, "pre-configured *.rabbitmq.net record does not resolve, skipping"};
7182
[_ | _] ->
7283
Config
7384
end.
7485

86+
7587
end_per_testcase(_Testcase, Config) ->
76-
case inet_res:lookup(?DISCOVERY_ENDPOINT, in, a) of
88+
case inet_res:lookup(?DISCOVERY_ENDPOINT_RECORD_A, in, a) of
7789
[] ->
7890
{skip, "pre-configured *.rabbitmq.net record does not resolve, skipping"};
7991
[_ | _] ->
@@ -85,18 +97,22 @@ end_per_testcase(_Testcase, Config) ->
8597
%% Test cases
8698
%% -------------------------------------------------------------------
8799

100+
test_aaaa_record_hostname_discovery(_) ->
101+
Result = rabbit_peer_discovery_dns:discover_hostnames(?DISCOVERY_ENDPOINT_RECORD_AAAA, true),
102+
?assert(string:str(lists:flatten(Result), "facebook.com") > 0).
103+
88104
hostname_discovery_with_long_node_names(_) ->
89-
Result = rabbit_peer_discovery_dns:discover_hostnames(?DISCOVERY_ENDPOINT, true),
105+
Result = rabbit_peer_discovery_dns:discover_hostnames(?DISCOVERY_ENDPOINT_RECORD_A, true),
90106
?assert(lists:member("www.rabbitmq.com", Result)).
91107

92108
hostname_discovery_with_short_node_names(_) ->
93-
Result = rabbit_peer_discovery_dns:discover_hostnames(?DISCOVERY_ENDPOINT, false),
109+
Result = rabbit_peer_discovery_dns:discover_hostnames(?DISCOVERY_ENDPOINT_RECORD_A, false),
94110
?assert(lists:member("www", Result)).
95111

96112
node_discovery_with_long_node_names(_) ->
97-
Result = rabbit_peer_discovery_dns:discover_nodes(?DISCOVERY_ENDPOINT, true),
113+
Result = rabbit_peer_discovery_dns:discover_nodes(?DISCOVERY_ENDPOINT_RECORD_A, true),
98114
?assert(lists:member('[email protected]', Result)).
99115

100116
node_discovery_with_short_node_names(_) ->
101-
Result = rabbit_peer_discovery_dns:discover_nodes(?DISCOVERY_ENDPOINT, false),
117+
Result = rabbit_peer_discovery_dns:discover_nodes(?DISCOVERY_ENDPOINT_RECORD_A, false),
102118
?assert(lists:member(ct_rabbit@www, Result)).

0 commit comments

Comments
 (0)