summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJean-Sébastien Pédron <jean-sebastien@rabbitmq.com>2019-11-21 14:16:37 +0100
committerJean-Sébastien Pédron <jean-sebastien@rabbitmq.com>2019-11-21 14:16:37 +0100
commitc96aeeb262b4e47da61a79bb320674862379046c (patch)
tree221edea7992b8c3031f44e5fd71a8d4a7acab1eb /test
parent0991bbf81cbdb04e0ea91d019a82c70d96e90213 (diff)
downloadrabbitmq-server-git-c96aeeb262b4e47da61a79bb320674862379046c.tar.gz
dynamic_ha_SUITE: Ensure conditions for `rebalance_exactly` are met
I.e., queues are using different mirrors so that they are not all rebalanced on the same node (the testcase expects they are spread on all three nodes).
Diffstat (limited to 'test')
-rw-r--r--test/dynamic_ha_SUITE.erl25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/dynamic_ha_SUITE.erl b/test/dynamic_ha_SUITE.erl
index b1171a3f5f..4423ca80cd 100644
--- a/test/dynamic_ha_SUITE.erl
+++ b/test/dynamic_ha_SUITE.erl
@@ -600,6 +600,14 @@ rebalance_exactly(Config) ->
rabbit_ct_broker_helpers:set_ha_policy(Config, A, <<"q.*">>, {<<"exactly">>, 2}),
timer:sleep(1000),
+ %% Rebalancing happens with existing mirrors. Thus, before we
+ %% can verify it works as expected, we need the queues to be on
+ %% different mirrors.
+ %%
+ %% We only test Q3, Q4 and Q5 because the first two are expected to
+ %% stay where they are.
+ ensure_queues_are_mirrored_on_different_mirrors([Q3, Q4, Q5], A, ACh),
+
rabbit_ct_client_helpers:publish(ACh, Q1, 5),
rabbit_ct_client_helpers:publish(ACh, Q2, 3),
@@ -623,6 +631,23 @@ rebalance_exactly(Config) ->
ok.
+ensure_queues_are_mirrored_on_different_mirrors(Queues, Master, Ch) ->
+ SNodes = [node(SPid)
+ || Q <- Queues,
+ SPid <- proplists:get_value(slave_pids, find_queue(Q, Master))],
+ UniqueSNodes = lists:usort(SNodes),
+ case UniqueSNodes of
+ [_] ->
+ %% All passed queues are on the same mirror. Let's redeclare
+ %% one of them and test again.
+ Q = hd(Queues),
+ amqp_channel:call(Ch, #'queue.delete'{queue = Q}),
+ amqp_channel:call(Ch, #'queue.declare'{queue = Q}),
+ ensure_queues_are_mirrored_on_different_mirrors(Queues, Master, Ch);
+ _ ->
+ ok
+ end.
+
rebalance_nodes(Config) ->
[A, B, _] = rabbit_ct_broker_helpers:get_node_configs(Config, nodename),
ACh = rabbit_ct_client_helpers:open_channel(Config, A),