|
| 1 | +%% The contents of this file are subject to the Mozilla Public License |
| 2 | +%% Version 1.1 (the "License"); you may not use this file except in |
| 3 | +%% compliance with the License. You may obtain a copy of the License |
| 4 | +%% at http://www.mozilla.org/MPL/ |
| 5 | +%% |
| 6 | +%% Software distributed under the License is distributed on an "AS IS" |
| 7 | +%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See |
| 8 | +%% the License for the specific language governing rights and |
| 9 | +%% limitations under the License. |
| 10 | +%% |
| 11 | +%% The Original Code is RabbitMQ. |
| 12 | +%% |
| 13 | +%% The Initial Developer of the Original Code is GoPivotal, Inc. |
| 14 | +%% Copyright (c) 2018 Pivotal Software, Inc. All rights reserved. |
| 15 | +%% |
| 16 | + |
| 17 | +-module(quorum_queue_SUITE). |
| 18 | + |
| 19 | +-include_lib("common_test/include/ct.hrl"). |
| 20 | +-include_lib("amqp_client/include/amqp_client.hrl"). |
| 21 | + |
| 22 | +-compile(export_all). |
| 23 | + |
| 24 | +all() -> |
| 25 | + [ |
| 26 | + {group, non_parallel_tests} |
| 27 | + ]. |
| 28 | + |
| 29 | +groups() -> |
| 30 | + [ |
| 31 | + {non_parallel_tests, [], [ |
| 32 | + declare_args |
| 33 | + ]} |
| 34 | + ]. |
| 35 | + |
| 36 | +%% ------------------------------------------------------------------- |
| 37 | +%% Testsuite setup/teardown. |
| 38 | +%% ------------------------------------------------------------------- |
| 39 | + |
| 40 | +init_per_suite(Config) -> |
| 41 | + rabbit_ct_helpers:log_environment(), |
| 42 | + rabbit_ct_helpers:run_setup_steps(Config). |
| 43 | + |
| 44 | +end_per_suite(Config) -> |
| 45 | + rabbit_ct_helpers:run_teardown_steps(Config). |
| 46 | + |
| 47 | +init_per_group(_, Config) -> |
| 48 | + Config. |
| 49 | + |
| 50 | +end_per_group(_, Config) -> |
| 51 | + Config. |
| 52 | + |
| 53 | +init_per_testcase(Testcase, Config) -> |
| 54 | + rabbit_ct_helpers:testcase_started(Config, Testcase), |
| 55 | + ClusterSize = 1, |
| 56 | + TestNumber = rabbit_ct_helpers:testcase_number(Config, ?MODULE, Testcase), |
| 57 | + Config1 = rabbit_ct_helpers:set_config(Config, [ |
| 58 | + {rmq_nodes_count, ClusterSize}, |
| 59 | + {rmq_nodes_clustered, true}, |
| 60 | + {rmq_nodename_suffix, Testcase}, |
| 61 | + {tcp_ports_base, {skip_n_nodes, TestNumber * ClusterSize}} |
| 62 | + ]), |
| 63 | + rabbit_ct_helpers:run_steps(Config1, |
| 64 | + rabbit_ct_broker_helpers:setup_steps() ++ |
| 65 | + rabbit_ct_client_helpers:setup_steps()). |
| 66 | + |
| 67 | +end_per_testcase(Testcase, Config) -> |
| 68 | + Config1 = rabbit_ct_helpers:run_steps(Config, |
| 69 | + rabbit_ct_client_helpers:teardown_steps() ++ |
| 70 | + rabbit_ct_broker_helpers:teardown_steps()), |
| 71 | + rabbit_ct_helpers:testcase_finished(Config1, Testcase). |
| 72 | + |
| 73 | +%% ------------------------------------------------------------------- |
| 74 | +%% Testcases. |
| 75 | +%% ------------------------------------------------------------------- |
| 76 | + |
| 77 | +declare_args(Config) -> |
| 78 | + A = rabbit_ct_broker_helpers:get_node_config(Config, 0, nodename), |
| 79 | + |
| 80 | + Ch = rabbit_ct_client_helpers:open_channel(Config, A), |
| 81 | + LQ = <<"quorum-q">>, |
| 82 | + declare(Ch, LQ, [{<<"x-queue-type">>, longstr, <<"quorum">>}]), |
| 83 | + assert_queue_type(A, LQ, quorum), |
| 84 | + |
| 85 | + DQ = <<"classic-q">>, |
| 86 | + declare(Ch, DQ, [{<<"x-queue-type">>, longstr, <<"classic">>}]), |
| 87 | + assert_queue_type(A, DQ, classic), |
| 88 | + |
| 89 | + DQ2 = <<"classic-q2">>, |
| 90 | + declare(Ch, DQ2), |
| 91 | + assert_queue_type(A, DQ2, classic). |
| 92 | + |
| 93 | +%%---------------------------------------------------------------------------- |
| 94 | + |
| 95 | +declare(Ch, Q) -> |
| 96 | + declare(Ch, Q, []). |
| 97 | + |
| 98 | +declare(Ch, Q, Args) -> |
| 99 | + amqp_channel:call(Ch, #'queue.declare'{queue = Q, |
| 100 | + durable = true, |
| 101 | + arguments = Args}). |
| 102 | + |
| 103 | +assert_queue_type(Node, Q, Expected) -> |
| 104 | + Actual = get_queue_type(Node, Q), |
| 105 | + Expected = Actual. |
| 106 | + |
| 107 | +get_queue_type(Node, Q) -> |
| 108 | + QNameRes = rabbit_misc:r(<<"/">>, queue, Q), |
| 109 | + {ok, AMQQueue} = |
| 110 | + rpc:call(Node, rabbit_amqqueue, lookup, [QNameRes]), |
| 111 | + AMQQueue#amqqueue.type. |
0 commit comments