diff options
| author | Arnaud Cogoluègnes <acogoluegnes@gmail.com> | 2017-06-14 10:18:52 +0200 |
|---|---|---|
| committer | Arnaud Cogoluègnes <acogoluegnes@gmail.com> | 2017-06-14 10:18:52 +0200 |
| commit | 32b9c88d1eba112d721c720dd1c80c981b1e5972 (patch) | |
| tree | ef3b9902e6b4dd0a0e617c3a6675add178c85439 /test | |
| parent | b077d47e7596973b9b8ec01d48233f42a0eb097e (diff) | |
| parent | 41a396e26e3d5fea88ee3e9e375a2ef791bf1b21 (diff) | |
| download | rabbitmq-server-git-32b9c88d1eba112d721c720dd1c80c981b1e5972.tar.gz | |
Merge branch 'master' into rabbitmq-server-1229
Diffstat (limited to 'test')
| -rw-r--r-- | test/backing_queue_SUITE.erl | 2 | ||||
| -rw-r--r-- | test/cluster_SUITE.erl | 2 | ||||
| -rw-r--r-- | test/cluster_formation_locking_SUITE.erl | 80 | ||||
| -rw-r--r-- | test/clustering_management_SUITE.erl | 8 | ||||
| -rw-r--r-- | test/partitions_SUITE.erl | 38 | ||||
| -rw-r--r-- | test/term_to_binary_compat_prop_SUITE.erl | 62 | ||||
| -rw-r--r-- | test/unit_SUITE.erl | 6 | ||||
| -rw-r--r-- | test/unit_inbroker_parallel_SUITE.erl | 2 |
8 files changed, 190 insertions, 10 deletions
diff --git a/test/backing_queue_SUITE.erl b/test/backing_queue_SUITE.erl index 3ff215f497..60f86e0542 100644 --- a/test/backing_queue_SUITE.erl +++ b/test/backing_queue_SUITE.erl @@ -1256,7 +1256,7 @@ make_publish_delivered(IsPersistent, PayloadFun, PropFun, N) -> PropFun(N, #message_properties{size = 10})}. queue_name(Config, Name) -> - Name1 = rabbit_ct_helpers:config_to_testcase_name(Config, Name), + Name1 = iolist_to_binary(rabbit_ct_helpers:config_to_testcase_name(Config, Name)), queue_name(Name1). queue_name(Name) -> diff --git a/test/cluster_SUITE.erl b/test/cluster_SUITE.erl index bc442ecba7..3dba65ae1f 100644 --- a/test/cluster_SUITE.erl +++ b/test/cluster_SUITE.erl @@ -355,7 +355,7 @@ test_spawn_remote() -> end. queue_name(Config, Name) -> - Name1 = rabbit_ct_helpers:config_to_testcase_name(Config, Name), + Name1 = iolist_to_binary(rabbit_ct_helpers:config_to_testcase_name(Config, Name)), queue_name(Name1). queue_name(Name) -> diff --git a/test/cluster_formation_locking_SUITE.erl b/test/cluster_formation_locking_SUITE.erl new file mode 100644 index 0000000000..25b2df308c --- /dev/null +++ b/test/cluster_formation_locking_SUITE.erl @@ -0,0 +1,80 @@ +%% 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) 2007-2017 Pivotal Software, Inc. All rights reserved. +%% +-module(cluster_formation_locking_SUITE). + +-include_lib("common_test/include/ct.hrl"). +-include_lib("eunit/include/eunit.hrl"). + +-compile(export_all). + +all() -> + [ + {group, non_parallel_tests} + ]. + +groups() -> + [ + {non_parallel_tests, [], [ + init_with_lock_exits_after_errors, + init_with_lock_ignore_after_errors, + init_with_lock_not_supported, + init_with_lock_supported + ]} + ]. + +init_per_testcase(Testcase, Config) when Testcase == init_with_lock_exits_after_errors; + Testcase == init_with_lock_not_supported; + Testcase == init_with_lock_supported -> + application:set_env(rabbit, cluster_formation, + [{peer_discover_backend, peer_discover_classic_config}, + {lock_acquisition_failure_mode, fail}]), + ok = meck:new(rabbit_peer_discovery_classic_config, [passthrough]), + Config; +init_per_testcase(init_with_lock_ignore_after_errors, Config) -> + application:set_env(rabbit, cluster_formation, + [{peer_discover_backend, peer_discover_classic_config}, + {lock_acquisition_failure_mode, ignore}]), + ok = meck:new(rabbit_peer_discovery_classic_config, [passthrough]), + Config. + +end_per_testcase(_, _) -> + meck:unload(), + application:unset_env(rabbit, cluster_formation). + +init_with_lock_exits_after_errors(_Config) -> + meck:expect(rabbit_peer_discovery_classic_config, lock, fun(_) -> {error, "test error"} end), + ?assertExit(cannot_acquire_startup_lock, rabbit_mnesia:init_with_lock(2, 10, fun() -> ok end)), + ?assert(meck:validate(rabbit_peer_discovery_classic_config)), + passed. + +init_with_lock_ignore_after_errors(_Config) -> + meck:expect(rabbit_peer_discovery_classic_config, lock, fun(_) -> {error, "test error"} end), + ?assertEqual(ok, rabbit_mnesia:init_with_lock(2, 10, fun() -> ok end)), + ?assert(meck:validate(rabbit_peer_discovery_classic_config)), + passed. + +init_with_lock_not_supported(_Config) -> + meck:expect(rabbit_peer_discovery_classic_config, lock, fun(_) -> not_supported end), + ?assertEqual(ok, rabbit_mnesia:init_with_lock(2, 10, fun() -> ok end)), + ?assert(meck:validate(rabbit_peer_discovery_classic_config)), + passed. + +init_with_lock_supported(_Config) -> + meck:expect(rabbit_peer_discovery_classic_config, lock, fun(_) -> {ok, data} end), + meck:expect(rabbit_peer_discovery_classic_config, unlock, fun(data) -> ok end), + ?assertEqual(ok, rabbit_mnesia:init_with_lock(2, 10, fun() -> ok end)), + ?assert(meck:validate(rabbit_peer_discovery_classic_config)), + passed. diff --git a/test/clustering_management_SUITE.erl b/test/clustering_management_SUITE.erl index b0a93ad208..51c0928ba5 100644 --- a/test/clustering_management_SUITE.erl +++ b/test/clustering_management_SUITE.erl @@ -135,7 +135,8 @@ join_and_part_cluster(Config) -> %% Allow clustering with already clustered node ok = stop_app(Rabbit), - {ok, already_member} = join_cluster(Rabbit, Hare), + {ok, <<"The node is already a member of this cluster">>} = + join_cluster(Rabbit, Hare), ok = start_app(Rabbit), stop_reset_start(Rabbit), @@ -388,10 +389,9 @@ force_boot(Config) -> change_cluster_node_type(Config) -> [Rabbit, Hare, _Bunny] = cluster_members(Config), - %% Trying to change the ram node when not clustered should always fail + %% Trying to change the node to the ram type when not clustered should always fail ok = stop_app(Rabbit), assert_failure(fun () -> change_cluster_node_type(Rabbit, ram) end), - assert_failure(fun () -> change_cluster_node_type(Rabbit, disc) end), ok = start_app(Rabbit), ok = stop_app(Rabbit), @@ -643,7 +643,7 @@ wait_for_pid_file_to_contain_running_process_pid(PidFile, Attempts, Timeout) -> Pid = pid_from_file(PidFile), case rabbit_misc:is_os_process_alive(Pid) of true -> ok; - false -> + false -> ct:sleep(Timeout), wait_for_pid_file_to_contain_running_process_pid(PidFile, Attempts - 1, Timeout) end. diff --git a/test/partitions_SUITE.erl b/test/partitions_SUITE.erl index 8c8a772987..b09d05b550 100644 --- a/test/partitions_SUITE.erl +++ b/test/partitions_SUITE.erl @@ -335,16 +335,26 @@ autoheal_unexpected_finish(Config) -> partial_false_positive(Config) -> [A, B, C] = rabbit_ct_broker_helpers:get_node_configs(Config, nodename), + suspend_node_monitor(Config, C), block([{A, B}]), timer:sleep(1000), block([{A, C}]), timer:sleep(?DELAY), + resume_node_monitor(Config, C), + timer:sleep(?DELAY), unblock([{A, B}, {A, C}]), timer:sleep(?DELAY), %% When B times out A's connection, it will check with C. C will %% not have timed out A yet, but already it can't talk to it. We %% need to not consider this a partial partition; B and C should %% still talk to each other. + %% + %% Because there is a chance that C can still talk to A when B + %% requests to check for a partial partition, we suspend C's + %% rabbit_node_monitor at the beginning and resume it after the + %% link between A and C is blocked. This way, when B asks C about + %% A, we make sure that the A<->C link is blocked before C's + %% rabbit_node_monitor processes B's request. [B, C] = partitions(A), [A] = partitions(B), [A] = partitions(C), @@ -369,7 +379,19 @@ partial_to_full(Config) -> partial_pause_minority(Config) -> [A, B, C] = rabbit_ct_broker_helpers:get_node_configs(Config, nodename), set_mode(Config, pause_minority), + %% We suspend rabbit_node_monitor on C while we block the link + %% between A and B. This should make sure C's rabbit_node_monitor + %% processes both partial partition checks from A and B at about + %% the same time, and thus increase the chance both A and B decides + %% there is a partial partition. + %% + %% Without this, one node may see the partial partition and stop, + %% before the other node sees it. In this case, the other node + %% doesn't stop and this testcase fails. + suspend_node_monitor(Config, C), block([{A, B}]), + timer:sleep(?DELAY), + resume_node_monitor(Config, C), [await_running(N, false) || N <- [A, B]], await_running(C, true), unblock([{A, B}]), @@ -394,6 +416,22 @@ set_mode(Config, Mode) -> set_mode(Config, Nodes, Mode) -> rabbit_ct_broker_helpers:set_partition_handling_mode(Config, Nodes, Mode). +suspend_node_monitor(Config, Node) -> + rabbit_ct_broker_helpers:rpc( + Config, Node, ?MODULE, suspend_or_resume_node_monitor, [suspend]). + +resume_node_monitor(Config, Node) -> + rabbit_ct_broker_helpers:rpc( + Config, Node, ?MODULE, suspend_or_resume_node_monitor, [resume]). + +suspend_or_resume_node_monitor(SuspendOrResume) -> + Action = case SuspendOrResume of + suspend -> "Suspending"; + resume -> "Resuming" + end, + rabbit_log:info("(~s) ~s node monitor~n", [?MODULE, Action]), + ok = sys:SuspendOrResume(rabbit_node_monitor). + block_unblock(Pairs) -> block(Pairs), timer:sleep(?DELAY), diff --git a/test/term_to_binary_compat_prop_SUITE.erl b/test/term_to_binary_compat_prop_SUITE.erl new file mode 100644 index 0000000000..d09b23c9ea --- /dev/null +++ b/test/term_to_binary_compat_prop_SUITE.erl @@ -0,0 +1,62 @@ +%% 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) 2017 Pivotal Software, Inc. All rights reserved. +%% + + +-module(term_to_binary_compat_prop_SUITE). + +-compile(export_all). + +-include("rabbit.hrl"). +-include_lib("common_test/include/ct.hrl"). +-include_lib("proper/include/proper.hrl"). + +all() -> + %% The test should run on OTP < 20 (erts < 9) + case erts_gt_8() of + true -> + []; + false -> + [queue_name_to_binary] + end. + +erts_gt_8() -> + Vsn = erlang:system_info(version), + [Maj|_] = string:tokens(Vsn, "."), + list_to_integer(Maj) > 8. + +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) -> + rabbit_ct_helpers:testcase_started(Config, Testcase). + +queue_name_to_binary(Config) -> + Fun = fun () -> prop_queue_name_to_binary(Config) end, + rabbit_ct_proper_helpers:run_proper(Fun, [], 10000). + + +prop_queue_name_to_binary(_Config) -> + ?FORALL({Vhost, QName}, {binary(), binary()}, + begin + Resource = rabbit_misc:r(Vhost, queue, QName), + Legacy = term_to_binary_compat:queue_name_to_binary(Resource), + Current = term_to_binary(Resource), + Current =:= Legacy + end).
\ No newline at end of file diff --git a/test/unit_SUITE.erl b/test/unit_SUITE.erl index f3fec06cb4..3e92158595 100644 --- a/test/unit_SUITE.erl +++ b/test/unit_SUITE.erl @@ -332,7 +332,7 @@ do_decrypt_start_app(Config, Passphrase) -> %% %% We expect a failure *after* the decrypting has been done. try - rabbit:start_apps([rabbit_shovel_test]) + rabbit:start_apps([rabbit_shovel_test], #{rabbit => temporary}) catch _:_ -> ok end, @@ -359,7 +359,7 @@ decrypt_start_app_undefined(Config) -> %% %% We expect a failure during decryption because the passphrase is missing. try - rabbit:start_apps([rabbit_shovel_test]) + rabbit:start_apps([rabbit_shovel_test], #{rabbit => temporary}) catch exit:{bad_configuration, config_entry_decoder} -> ok; _:_ -> exit(unexpected_exception) @@ -379,7 +379,7 @@ decrypt_start_app_wrong_passphrase(Config) -> %% %% We expect a failure during decryption because the passphrase is wrong. try - rabbit:start_apps([rabbit_shovel_test]) + rabbit:start_apps([rabbit_shovel_test], #{rabbit => temporary}) catch exit:{decryption_error,_,_} -> ok; _:_ -> exit(unexpected_exception) diff --git a/test/unit_inbroker_parallel_SUITE.erl b/test/unit_inbroker_parallel_SUITE.erl index f9cfd58eaa..9c274ab525 100644 --- a/test/unit_inbroker_parallel_SUITE.erl +++ b/test/unit_inbroker_parallel_SUITE.erl @@ -146,7 +146,7 @@ on_disk_stop(Pid) -> end. queue_name(Config, Name) -> - Name1 = rabbit_ct_helpers:config_to_testcase_name(Config, Name), + Name1 = iolist_to_binary(rabbit_ct_helpers:config_to_testcase_name(Config, Name)), queue_name(Name1). queue_name(Name) -> |
