summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorD Corbacho <diana@rabbitmq.com>2016-11-14 14:36:14 +0000
committerGitHub <noreply@github.com>2016-11-14 14:36:14 +0000
commitc53ac3f20bc0b58b08ccec428902b1d6de4f3e75 (patch)
treeea48ca9f675e1f8c307f2f6dde63652ba0992230 /test
parent6c0fdd3a7f0aa938c2a3606beae8227e0a3d3069 (diff)
parent01f526dd8b43b8f3e85c6b5e808c27078eeb216e (diff)
downloadrabbitmq-server-git-c53ac3f20bc0b58b08ccec428902b1d6de4f3e75.tar.gz
Merge pull request #1008 from rabbitmq/rabbitmq-server-988
DNS peer discovery backend
Diffstat (limited to 'test')
-rw-r--r--test/config_schema_SUITE_data/snippets.config45
-rw-r--r--test/peer_discovery_dns_SUITE.erl102
2 files changed, 140 insertions, 7 deletions
diff --git a/test/config_schema_SUITE_data/snippets.config b/test/config_schema_SUITE_data/snippets.config
index 8c4319fa53..a64b6e06c9 100644
--- a/test/config_schema_SUITE_data/snippets.config
+++ b/test/config_schema_SUITE_data/snippets.config
@@ -94,23 +94,29 @@ default_permissions.write = .*",
{default_permissions, [<<".*">>, <<".*">>, <<".*">>]}]}],[]}
,
{13,
-"autocluster.classic_config.nodes.peer1 = rabbit@hostname1
+"autocluster.peer_discovery_backend = rabbit_peer_discovery_classic_config
+autocluster.classic_config.nodes.peer1 = rabbit@hostname1
autocluster.classic_config.nodes.peer2 = rabbit@hostname2
-autocluster.classic_config.node_type = disc",
+autocluster.node_type = disc",
[{rabbit, [
+ {autocluster, [{peer_discovery_backend, rabbit_peer_discovery_classic_config},
+ {node_type, disc}]},
{cluster_nodes, {[rabbit@hostname2,rabbit@hostname1], disc}}
]}],[]}
,
{13.1,
-"autocluster.classic_config.nodes.peer1 = rabbit@hostname1
+"autocluster.peer_discovery_backend = rabbit_peer_discovery_classic_config
+autocluster.classic_config.nodes.peer1 = rabbit@hostname1
autocluster.classic_config.nodes.peer2 = rabbit@hostname2
-autocluster.classic_config.node_type = disk",
+autocluster.node_type = disk",
[{rabbit, [
+ {autocluster, [{peer_discovery_backend, rabbit_peer_discovery_classic_config},
+ {node_type, disc}]},
{cluster_nodes, {[rabbit@hostname2,rabbit@hostname1], disc}}
]}],[]}
,
{13.2,
-"autocluster.classic_config.node_type = ram",
+"autocluster.node_type = ram",
[],[]}
,
{14,
@@ -713,7 +719,7 @@ web_stomp.ssl.password = changeme",
[{rabbitmq_web_stomp,
[{sockjs_opts, [{sockjs_url, "https://cdn.jsdelivr.net/sockjs/0.3.4/sockjs.min.js"}]}]}],
[rabbitmq_web_stomp]},
-{69,
+{69,
"auth_backends.1 = http
rabbitmq_auth_backend_http.user_path = http://some-server/auth/user
rabbitmq_auth_backend_http.vhost_path = http://some-server/auth/vhost
@@ -741,5 +747,30 @@ tcp_listen_options.linger.timeout = 100",
{74,
"tcp_listen_options.linger.timeout = 100",
[{rabbit, [{tcp_listen_options, [{linger, {false, 100}}]}]}],
-[]}
+[]},
+{75,
+"
+autocluster.peer_discovery_backend = rabbit_peer_discovery_dns
+autocluster.dns.hostname = 192.168.0.2.xip.io
+autocluster.node_type = disc",
+[{rabbit, [
+ {autocluster, [{peer_discovery_dns, [{hostname, <<"192.168.0.2.xip.io">>}]},
+ {peer_discovery_backend, rabbit_peer_discovery_dns},
+ {node_type, disc}]}
+]}],[]}
+,
+{76,
+"autocluster.peer_discovery_backend = rabbit_peer_discovery_classic_config
+autocluster.node_type = disc",
+[{rabbit, [
+ {autocluster, [{peer_discovery_backend, rabbit_peer_discovery_classic_config},
+ {node_type, disc}]}
+]}],[]},
+{76.1,
+"autocluster.peer_discovery_backend = rabbit_peer_discovery_classic_config
+autocluster.node_type = ram",
+[{rabbit, [
+ {autocluster, [{peer_discovery_backend, rabbit_peer_discovery_classic_config},
+ {node_type, ram}]}
+]}],[]}
].
diff --git a/test/peer_discovery_dns_SUITE.erl b/test/peer_discovery_dns_SUITE.erl
new file mode 100644
index 0000000000..da01aeebdd
--- /dev/null
+++ b/test/peer_discovery_dns_SUITE.erl
@@ -0,0 +1,102 @@
+%% The contents of this file are subject to the Mozilla Public License
+%% Version 1.1 (the "License"); you may not use this file except in
+%% compliance with the License. You may obtain a copy of the License at
+%% http://www.mozilla.org/MPL/
+%%
+%% Software distributed under the License is distributed on an "AS IS"
+%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+%% License for the specific language governing rights and limitations
+%% under the License.
+%%
+%% The Original Code is RabbitMQ.
+%%
+%% The Initial Developer of the Original Code is GoPivotal, Inc.
+%% Copyright (c) 2011-2016 Pivotal Software, Inc. All rights reserved.
+%%
+
+-module(peer_discovery_dns_SUITE).
+
+-include_lib("common_test/include/ct.hrl").
+-include_lib("amqp_client/include/amqp_client.hrl").
+-include_lib("eunit/include/eunit.hrl").
+
+-compile(export_all).
+
+all() ->
+ [
+ {group, non_parallel}
+ ].
+
+groups() ->
+ [
+ {non_parallel, [], [
+ hostname_discovery_with_long_node_names,
+ hostname_discovery_with_short_node_names,
+ node_discovery_with_long_node_names,
+ node_discovery_with_short_node_names
+ ]}
+ ].
+
+suite() ->
+ [
+ %% If a test hangs, no need to wait for 30 minutes.
+ {timetrap, {minutes, 1}}
+ ].
+
+
+%% -------------------------------------------------------------------
+%% Testsuite setup/teardown.
+%% -------------------------------------------------------------------
+
+%% peer_discovery.tests.rabbitmq.net used in the tests below
+%% returns three A records two of which fail our resolution process:
+%%
+%% * One does not resolve to a [typically] non-reachable IP
+%% * One does not support reverse lookup queries
+
+-define(DISCOVERY_ENDPOINT, "peer_discovery.tests.rabbitmq.net").
+
+init_per_suite(Config) ->
+ rabbit_ct_helpers:log_environment(),
+ rabbit_ct_helpers:run_setup_steps(Config).
+
+end_per_suite(Config) ->
+ rabbit_ct_helpers:run_teardown_steps(Config).
+
+init_per_testcase(_Testcase, Config) ->
+ %% TODO: support IPv6-only environments
+ case inet_res:lookup(?DISCOVERY_ENDPOINT, in, a) of
+ [] ->
+ {skip, "pre-configured *.rabbitmq.net record does not resolve, skipping"};
+ [_ | _] ->
+ Config
+ end.
+
+end_per_testcase(_Testcase, Config) ->
+ case inet_res:lookup(?DISCOVERY_ENDPOINT, in, a) of
+ [] ->
+ {skip, "pre-configured *.rabbitmq.net record does not resolve, skipping"};
+ [_ | _] ->
+ Config
+ end.
+
+
+%% -------------------------------------------------------------------
+%% Test cases
+%% -------------------------------------------------------------------
+
+hostname_discovery_with_long_node_names(_) ->
+ Result = rabbit_peer_discovery_dns:discover_hostnames(?DISCOVERY_ENDPOINT, true),
+ ?assertEqual(["www.rabbitmq.com"], Result).
+
+hostname_discovery_with_short_node_names(_) ->
+ Result = rabbit_peer_discovery_dns:discover_hostnames(?DISCOVERY_ENDPOINT, false),
+ ?assertEqual(["www"], Result).
+
+node_discovery_with_long_node_names(_) ->
+ Result = rabbit_peer_discovery_dns:discover_nodes(?DISCOVERY_ENDPOINT, true),
+ ?assertEqual(['ct_rabbit@www.rabbitmq.com'], Result).
+
+node_discovery_with_short_node_names(_) ->
+ Result = rabbit_peer_discovery_dns:discover_nodes(?DISCOVERY_ENDPOINT, false),
+ ?assertEqual([ct_rabbit@www], Result).