diff options
| author | Michael Klishin <michael@clojurewerkz.org> | 2016-09-19 13:35:52 +0300 |
|---|---|---|
| committer | Michael Klishin <michael@clojurewerkz.org> | 2016-09-19 13:35:52 +0300 |
| commit | 94507bbe557ac83c27e52c147aac3c1a89724fee (patch) | |
| tree | f2294e2e110f40c7df16dc0306c70f435f6b998a /test | |
| parent | 0904ddd5968e8a9a9f962c018f6a2af4c105274f (diff) | |
| download | rabbitmq-server-git-94507bbe557ac83c27e52c147aac3c1a89724fee.tar.gz | |
More tests
Diffstat (limited to 'test')
| -rw-r--r-- | test/per_vhost_queue_limit_SUITE.erl | 109 |
1 files changed, 77 insertions, 32 deletions
diff --git a/test/per_vhost_queue_limit_SUITE.erl b/test/per_vhost_queue_limit_SUITE.erl index e7edbe2b32..825904b779 100644 --- a/test/per_vhost_queue_limit_SUITE.erl +++ b/test/per_vhost_queue_limit_SUITE.erl @@ -38,7 +38,9 @@ groups() -> single_node_single_vhost_queue_count, single_node_multiple_vhosts_queue_count, single_node_single_vhost_limit, - single_node_single_vhost_zero_limit + single_node_single_vhost_zero_limit, + single_node_single_vhost_limit_with_durable_named_queue, + single_node_single_vhost_zero_limit_with_durable_named_queue ]}, {cluster_size_2, [], [ most_basic_cluster_queue_count @@ -207,37 +209,46 @@ single_node_single_vhost_limit(Config) -> single_node_single_vhost_limit_with(Config, 5), single_node_single_vhost_limit_with(Config, 10). single_node_single_vhost_zero_limit(Config) -> + single_node_single_vhost_zero_limit_with(Config, #'queue.declare'{queue = <<"">>, + exclusive = true}). + +single_node_single_vhost_limit_with_durable_named_queue(Config) -> VHost = <<"queue-limits">>, set_up_vhost(Config, VHost), ?assertEqual(0, count_queues_in(Config, VHost)), - Conn1 = open_unmanaged_connection(Config, 0, VHost), - {ok, Ch1} = amqp_connection:open_channel(Conn1), - - set_vhost_queue_limit(Config, VHost, 0), - - try - amqp_channel:call(Ch1, #'queue.declare'{queue = <<"">>, - exclusive = true}), - ok - catch _:{{shutdown, {server_initiated_close, 406, _}}, _} -> - %% expected - ok - end, - - Conn2 = open_unmanaged_connection(Config, 0, VHost), - {ok, Ch2} = amqp_connection:open_channel(Conn2), + set_vhost_queue_limit(Config, VHost, 3), + Conn = open_unmanaged_connection(Config, 0, VHost), + {ok, Ch} = amqp_connection:open_channel(Conn), - %% lift the limit - set_vhost_queue_limit(Config, VHost, -1), - lists:foreach(fun (_) -> - #'queue.declare_ok'{queue = _} = - amqp_channel:call(Ch2, #'queue.declare'{queue = <<"">>, - exclusive = true}) - end, lists:seq(1, 100)), + set_vhost_queue_limit(Config, VHost, 3), + #'queue.declare_ok'{queue = _} = + amqp_channel:call(Ch, #'queue.declare'{queue = <<"Q1">>, + exclusive = false, + durable = true}), + #'queue.declare_ok'{queue = _} = + amqp_channel:call(Ch, #'queue.declare'{queue = <<"Q2">>, + exclusive = false, + durable = true}), + #'queue.declare_ok'{queue = _} = + amqp_channel:call(Ch, #'queue.declare'{queue = <<"Q3">>, + exclusive = false, + durable = true}), + + expect_shutdown_due_to_precondition_failed( + fun () -> + amqp_channel:call(Ch, #'queue.declare'{queue = <<"Q3">>, + exclusive = false, + durable = true}) + end), rabbit_ct_broker_helpers:delete_vhost(Config, VHost). +single_node_single_vhost_zero_limit_with_durable_named_queue(Config) -> + single_node_single_vhost_zero_limit_with(Config, #'queue.declare'{queue = <<"Q4">>, + exclusive = false, + durable = true}). + single_node_single_vhost_limit_with(Config, WatermarkLimit) -> VHost = <<"queue-limits">>, set_up_vhost(Config, VHost), @@ -254,14 +265,39 @@ single_node_single_vhost_limit_with(Config, WatermarkLimit) -> exclusive = true}) end, lists:seq(1, WatermarkLimit)), - try - amqp_channel:call(Ch, #'queue.declare'{queue = <<"">>, - exclusive = true}), - ok - catch _:{{shutdown, {server_initiated_close, 406, _}}, _} -> - %% expected - ok - end, + expect_shutdown_due_to_precondition_failed( + fun () -> + amqp_channel:call(Ch, #'queue.declare'{queue = <<"">>, + exclusive = true}) + end), + + rabbit_ct_broker_helpers:delete_vhost(Config, VHost). + +single_node_single_vhost_zero_limit_with(Config, QueueDeclare) -> + VHost = <<"queue-limits">>, + set_up_vhost(Config, VHost), + ?assertEqual(0, count_queues_in(Config, VHost)), + + Conn1 = open_unmanaged_connection(Config, 0, VHost), + {ok, Ch1} = amqp_connection:open_channel(Conn1), + + set_vhost_queue_limit(Config, VHost, 0), + + expect_shutdown_due_to_precondition_failed( + fun () -> + amqp_channel:call(Ch1, QueueDeclare) + end), + + Conn2 = open_unmanaged_connection(Config, 0, VHost), + {ok, Ch2} = amqp_connection:open_channel(Conn2), + + %% lift the limit + set_vhost_queue_limit(Config, VHost, -1), + lists:foreach(fun (_) -> + #'queue.declare_ok'{queue = _} = + amqp_channel:call(Ch2, #'queue.declare'{queue = <<"">>, + exclusive = true}) + end, lists:seq(1, 100)), rabbit_ct_broker_helpers:delete_vhost(Config, VHost). @@ -319,3 +355,12 @@ delete_durable_queues(Ch, N) -> durable_queue_name(N) when is_integer(N) -> iolist_to_binary(io_lib:format("queue-limits-durable-~p", [N])). + +expect_shutdown_due_to_precondition_failed(Thunk) -> + try + Thunk(), + ok + catch _:{{shutdown, {server_initiated_close, 406, _}}, _} -> + %% expected + ok + end. |
