diff options
| author | Luke Bakken <lbakken@pivotal.io> | 2017-06-20 15:01:58 -0700 |
|---|---|---|
| committer | Luke Bakken <lbakken@pivotal.io> | 2017-06-20 15:01:58 -0700 |
| commit | 59ce657abcdbbed66799f466792657709baae37d (patch) | |
| tree | a98982fb337c24aef536955fb31f3afa1a41a524 /test | |
| parent | dd18cf3540bc4e87b4a5d586a6c88a4bf8b88874 (diff) | |
| parent | 72415b1c9446db5ad38b7d70a45fec6942682ec0 (diff) | |
| download | rabbitmq-server-git-59ce657abcdbbed66799f466792657709baae37d.tar.gz | |
Merge branch 'master' into rabbitmq-server-1246-master
Diffstat (limited to 'test')
| -rw-r--r-- | test/config_schema_SUITE_data/rabbit.snippets | 12 | ||||
| -rw-r--r-- | test/partitions_SUITE.erl | 38 | ||||
| -rw-r--r-- | test/term_to_binary_compat_prop_SUITE.erl | 59 | ||||
| -rw-r--r-- | test/topic_permission_SUITE.erl | 32 |
4 files changed, 128 insertions, 13 deletions
diff --git a/test/config_schema_SUITE_data/rabbit.snippets b/test/config_schema_SUITE_data/rabbit.snippets index 69e926100e..03a687db66 100644 --- a/test/config_schema_SUITE_data/rabbit.snippets +++ b/test/config_schema_SUITE_data/rabbit.snippets @@ -131,6 +131,18 @@ tcp_listen_options.exit_on_close = false", [{vm_memory_high_watermark_paging_ratio,0.75}, {vm_memory_high_watermark,0.4}]}], []}, + {memory_monitor_interval, "memory_monitor_interval = 5000", + [{rabbit, + [{memory_monitor_interval, 5000}]}], + []}, + {vm_memory_calculation_strategy, "vm_memory_calculation_strategy = rss", + [{rabbit, + [{vm_memory_calculation_strategy, rss}]}], + []}, + {vm_memory_calculation_strategy, "vm_memory_calculation_strategy = erlang", + [{rabbit, + [{vm_memory_calculation_strategy, erlang}]}], + []}, {listeners_tcp_ip, "listeners.tcp.1 = 192.168.1.99:5672", [{rabbit,[{tcp_listeners,[{"192.168.1.99",5672}]}]}], 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 index d09b23c9ea..6c8a92a29f 100644 --- a/test/term_to_binary_compat_prop_SUITE.erl +++ b/test/term_to_binary_compat_prop_SUITE.erl @@ -24,13 +24,11 @@ -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. + [ + pre_3_6_11_works, + term_to_binary_latin_atom, + queue_name_to_binary + ]. erts_gt_8() -> Vsn = erlang:system_info(version), @@ -47,16 +45,51 @@ end_per_suite(Config) -> init_per_testcase(Testcase, Config) -> rabbit_ct_helpers:testcase_started(Config, Testcase). +%% If this test fails - the erlang version is not supported in +%% RabbitMQ-3.6.10 and earlier. +pre_3_6_11_works(Config) -> + Fun = fun () -> prop_pre_3_6_11_works(Config) end, + rabbit_ct_proper_helpers:run_proper(Fun, [], 50000). + +prop_pre_3_6_11_works(_Config) -> + ?FORALL(Term, any(), + begin + Current = term_to_binary(Term), + Compat = term_to_binary_compat:term_to_binary_1(Term), + Current =:= Compat + end). + +term_to_binary_latin_atom(Config) -> + Fun = fun () -> prop_term_to_binary_latin_atom(Config) end, + rabbit_ct_proper_helpers:run_proper(Fun, [], 10000). + +prop_term_to_binary_latin_atom(_Config) -> + ?FORALL(LatinString, list(integer(0, 255)), + begin + Length = length(LatinString), + Atom = list_to_atom(LatinString), + Binary = list_to_binary(LatinString), + <<131,100, Length:16, Binary/binary>> =:= term_to_binary_compat:term_to_binary_1(Atom) + end). + 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()}, + ?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 + VHostBSize = byte_size(VHost), + NameBSize = byte_size(QName), + Expected = + <<131, %% Binary format "version" + 104, 4, %% 4-element tuple + 100, 0, 8, "resource", %% `resource` atom + 109, VHostBSize:32, VHost/binary, %% Vhost binary + 100, 0, 5, "queue", %% `queue` atom + 109, NameBSize:32, QName/binary>>, %% Name binary + Resource = rabbit_misc:r(VHost, queue, QName), + Current = term_to_binary_compat:term_to_binary_1(Resource), + Current =:= Expected + end). diff --git a/test/topic_permission_SUITE.erl b/test/topic_permission_SUITE.erl index 7b9d9f7701..c656746432 100644 --- a/test/topic_permission_SUITE.erl +++ b/test/topic_permission_SUITE.erl @@ -218,4 +218,36 @@ topic_permission_checks1(_Config) -> Perm, Context ) || Perm <- Permissions], + + %% expand variables + rabbit_auth_backend_internal:set_topic_permissions( + <<"guest">>, <<"other-vhost">>, <<"amq.topic">>, + "services.{vhost}.accounts.{username}.notifications", + "services.{vhost}.accounts.{username}.notifications", <<"acting-user">> + ), + %% routing key OK + [true = rabbit_auth_backend_internal:check_topic_access( + User, + Topic#resource{virtual_host = <<"other-vhost">>}, + Perm, + #{routing_key => <<"services.other-vhost.accounts.guest.notifications">>, + variable_map => #{ + <<"username">> => <<"guest">>, + <<"vhost">> => <<"other-vhost">> + } + } + ) || Perm <- Permissions], + %% routing key KO + [false = rabbit_auth_backend_internal:check_topic_access( + User, + Topic#resource{virtual_host = <<"other-vhost">>}, + Perm, + #{routing_key => <<"services.default.accounts.dummy.notifications">>, + variable_map => #{ + <<"username">> => <<"guest">>, + <<"vhost">> => <<"other-vhost">> + } + } + ) || Perm <- Permissions], + ok. |
