diff options
| author | Daniil Fedotov <dfedotov@pivotal.io> | 2016-11-23 16:17:21 +0000 |
|---|---|---|
| committer | Daniil Fedotov <dfedotov@pivotal.io> | 2016-11-23 16:17:21 +0000 |
| commit | 3542d80dfc102170c591639361d41288a853e3c7 (patch) | |
| tree | 7bc03fa60098d0380edf5d95a41d44b41eded8cb /test | |
| parent | c135b70c4690ddf3fdbafb9e0a8191cb2312eaae (diff) | |
| parent | 90d640207e1f6d8d0956019fd799412677e8a965 (diff) | |
| download | rabbitmq-server-git-3542d80dfc102170c591639361d41288a853e3c7.tar.gz | |
Merge branch 'master' into rabbitmq-server-567
Diffstat (limited to 'test')
| -rw-r--r-- | test/config_schema_SUITE_data/snippets.config | 45 | ||||
| -rw-r--r-- | test/peer_discovery_dns_SUITE.erl | 102 | ||||
| -rw-r--r-- | test/unit_SUITE.erl | 46 |
3 files changed, 140 insertions, 53 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). diff --git a/test/unit_SUITE.erl b/test/unit_SUITE.erl index 3f91cc9801..8ac3d41afe 100644 --- a/test/unit_SUITE.erl +++ b/test/unit_SUITE.erl @@ -42,8 +42,6 @@ groups() -> ]}, content_framing, content_transcoding, - encrypt_decrypt, - encrypt_decrypt_term, decrypt_config, rabbitmqctl_encode, pg_local, @@ -261,50 +259,6 @@ prepend_check(HeaderKey, HeaderTable, Headers) -> rabbit_misc:table_lookup(Invalid, HeaderKey), Headers1. -encrypt_decrypt(_Config) -> - %% Take all available block ciphers. - Hashes = rabbit_pbe:supported_hashes(), - Ciphers = rabbit_pbe:supported_ciphers(), - %% For each cipher, try to encrypt and decrypt data sizes from 0 to 64 bytes - %% with a random passphrase. - _ = [begin - PassPhrase = crypto:strong_rand_bytes(16), - Iterations = rand:uniform(100), - Data = crypto:strong_rand_bytes(64), - [begin - Expected = binary:part(Data, 0, Len), - Enc = rabbit_pbe:encrypt(C, H, Iterations, PassPhrase, Expected), - Expected = iolist_to_binary(rabbit_pbe:decrypt(C, H, Iterations, PassPhrase, Enc)) - end || Len <- lists:seq(0, byte_size(Data))] - end || H <- Hashes, C <- Ciphers], - ok. - -encrypt_decrypt_term(_Config) -> - %% Take all available block ciphers. - Hashes = rabbit_pbe:supported_hashes(), - Ciphers = rabbit_pbe:supported_ciphers(), - %% Different Erlang terms to try encrypting. - DataSet = [ - 10000, - [5672], - [{"127.0.0.1", 5672}, - {"::1", 5672}], - [{connection, info}, {channel, info}], - [{cacertfile, "/path/to/testca/cacert.pem"}, - {certfile, "/path/to/server/cert.pem"}, - {keyfile, "/path/to/server/key.pem"}, - {verify, verify_peer}, - {fail_if_no_peer_cert, false}], - [<<".*">>, <<".*">>, <<".*">>] - ], - _ = [begin - PassPhrase = crypto:strong_rand_bytes(16), - Iterations = rand:uniform(100), - Enc = rabbit_pbe:encrypt_term(C, H, Iterations, PassPhrase, Data), - Data = rabbit_pbe:decrypt_term(C, H, Iterations, PassPhrase, Enc) - end || H <- Hashes, C <- Ciphers, Data <- DataSet], - ok. - decrypt_config(_Config) -> %% Take all available block ciphers. Hashes = rabbit_pbe:supported_hashes(), |
