summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Sébastien Pédron <jean-sebastien@rabbitmq.com>2020-03-09 18:36:13 +0100
committerJean-Sébastien Pédron <jean-sebastien@rabbitmq.com>2020-03-09 18:36:13 +0100
commitcb9e739d98f3924696ed2410715a188667ace496 (patch)
tree522bcfd0b2ed8a1d736639ac20353c71ca9fb5c9
parentf05114e8651ac1aebe5841d2d71bd64744391119 (diff)
downloadrabbitmq-server-git-cb9e739d98f3924696ed2410715a188667ace496.tar.gz
dynamic_ha_SUITE: Increase the chance of concurrent rebalances
... in `rebalance_multiple_blocked`. The testcase wants two rebalances to happen at the same time: the first one may succeed (but this is out of scope for this testcase) and the second one must be aborted with `{error, rebalance_in_progress}`. It looks like things are faster with Erlang 23 because the first rebalance is already finished when the second starts, probably due to internode communication being slower than rebalance (the two rebalances are triggered from the common_test node). This time, the testcase starts a function on the remote node which spawns two functions in parallel to request a rebalance. Everything being local, we increase the chance to have concurrent rebalances. We don't know the order of execution of the two functions, so we simply verify that one of them fails. This is still not 100% bullet proof, but should be ok.
-rw-r--r--test/dynamic_ha_SUITE.erl17
1 files changed, 14 insertions, 3 deletions
diff --git a/test/dynamic_ha_SUITE.erl b/test/dynamic_ha_SUITE.erl
index 1fc19a98f5..b83b14e406 100644
--- a/test/dynamic_ha_SUITE.erl
+++ b/test/dynamic_ha_SUITE.erl
@@ -710,9 +710,20 @@ rebalance_multiple_blocked(Config) ->
?assertEqual(A, node(proplists:get_value(pid, find_queue(Q3, A)))),
?assertEqual(A, node(proplists:get_value(pid, find_queue(Q4, A)))),
?assertEqual(A, node(proplists:get_value(pid, find_queue(Q5, A)))),
- true = rpc:cast(A, rabbit_amqqueue, rebalance, [classic, ".*", ".*"]),
- {error, rebalance_in_progress} = rpc:call(A, rabbit_amqqueue, rebalance, [classic, ".*", ".*"]),
- ok.
+ ?assert(rabbit_ct_broker_helpers:rpc(
+ Config, A,
+ ?MODULE, rebalance_multiple_blocked1, [Config])).
+
+rebalance_multiple_blocked1(_) ->
+ Parent = self(),
+ Fun = fun() ->
+ Parent ! rabbit_amqqueue:rebalance(classic, ".*", ".*")
+ end,
+ spawn(Fun),
+ spawn(Fun),
+ Rets = [receive Ret1 -> Ret1 end,
+ receive Ret2 -> Ret2 end],
+ lists:member({error, rebalance_in_progress}, Rets).
%%----------------------------------------------------------------------------