Skip to content

Commit 37d5d18

Browse files
An attempt to make dynamic_ha suite more resilient
(cherry picked from commit 527cc56df4bb801349828eb958c1719d58dc618c)
1 parent eb1b137 commit 37d5d18

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

test/dynamic_ha_SUITE.erl

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ groups() ->
6161
promote_on_shutdown,
6262
promote_on_failure,
6363
slave_recovers_after_vhost_failure,
64-
slave_recovers_after_vhost_down_an_up,
64+
slave_recovers_after_vhost_down_and_up,
6565
master_migrates_on_vhost_down,
6666
slave_recovers_after_vhost_down_and_master_migrated,
6767
queue_survive_adding_dead_vhost_mirror
@@ -133,7 +133,7 @@ change_policy(Config) ->
133133

134134
%% When we first declare a queue with no policy, it's not HA.
135135
amqp_channel:call(ACh, #'queue.declare'{queue = ?QNAME}),
136-
timer:sleep(100),
136+
timer:sleep(200),
137137
assert_slaves(A, ?QNAME, {A, ''}),
138138

139139
%% Give it policy "all", it becomes HA and gets all mirrors
@@ -417,7 +417,7 @@ slave_recovers_after_vhost_failure(Config) ->
417417
ACh = rabbit_ct_client_helpers:open_channel(Config, A),
418418
QName = <<"slave_recovers_after_vhost_failure-q">>,
419419
amqp_channel:call(ACh, #'queue.declare'{queue = QName}),
420-
timer:sleep(300),
420+
timer:sleep(500),
421421
assert_slaves(A, QName, {A, [B]}, [{A, []}]),
422422

423423
%% Crash vhost on a node hosting a mirror
@@ -426,22 +426,25 @@ slave_recovers_after_vhost_failure(Config) ->
426426

427427
assert_slaves(A, QName, {A, [B]}, [{A, []}]).
428428

429-
slave_recovers_after_vhost_down_an_up(Config) ->
429+
slave_recovers_after_vhost_down_and_up(Config) ->
430430
[A, B] = rabbit_ct_broker_helpers:get_node_configs(Config, nodename),
431431
rabbit_ct_broker_helpers:set_ha_policy_all(Config),
432432
ACh = rabbit_ct_client_helpers:open_channel(Config, A),
433-
QName = <<"slave_recovers_after_vhost_down_an_up-q">>,
433+
QName = <<"slave_recovers_after_vhost_down_and_up-q">>,
434434
amqp_channel:call(ACh, #'queue.declare'{queue = QName}),
435-
timer:sleep(100),
435+
timer:sleep(200),
436436
assert_slaves(A, QName, {A, [B]}, [{A, []}]),
437437

438438
%% Crash vhost on a node hosting a mirror
439439
rabbit_ct_broker_helpers:force_vhost_failure(Config, B, <<"/">>),
440440
%% Vhost is down now
441441
false = rabbit_ct_broker_helpers:rpc(Config, B, rabbit_vhost_sup_sup, is_vhost_alive, [<<"/">>]),
442-
timer:sleep(300),
442+
timer:sleep(500),
443443
%% Vhost is back up
444-
{ok, _Sup} = rabbit_ct_broker_helpers:rpc(Config, B, rabbit_vhost_sup_sup, start_vhost, [<<"/">>]),
444+
case rabbit_ct_broker_helpers:rpc(Config, B, rabbit_vhost_sup_sup, start_vhost, [<<"/">>]) of
445+
{ok, _Sup} -> ok;
446+
{error,{already_started, _Sup}} -> ok
447+
end,
445448

446449
assert_slaves(A, QName, {A, [B]}, [{A, []}]).
447450

@@ -451,12 +454,12 @@ master_migrates_on_vhost_down(Config) ->
451454
ACh = rabbit_ct_client_helpers:open_channel(Config, A),
452455
QName = <<"master_migrates_on_vhost_down-q">>,
453456
amqp_channel:call(ACh, #'queue.declare'{queue = QName}),
454-
timer:sleep(100),
457+
timer:sleep(200),
455458
assert_slaves(A, QName, {A, [B]}, [{A, []}]),
456459

457460
%% Crash vhost on the node hosting queue master
458461
rabbit_ct_broker_helpers:force_vhost_failure(Config, A, <<"/">>),
459-
timer:sleep(300),
462+
timer:sleep(500),
460463
assert_slaves(A, QName, {B, []}).
461464

462465
slave_recovers_after_vhost_down_and_master_migrated(Config) ->
@@ -465,16 +468,19 @@ slave_recovers_after_vhost_down_and_master_migrated(Config) ->
465468
ACh = rabbit_ct_client_helpers:open_channel(Config, A),
466469
QName = <<"slave_recovers_after_vhost_down_and_master_migrated-q">>,
467470
amqp_channel:call(ACh, #'queue.declare'{queue = QName}),
468-
timer:sleep(100),
471+
timer:sleep(200),
469472
assert_slaves(A, QName, {A, [B]}, [{A, []}]),
470473
%% Crash vhost on the node hosting queue master
471474
rabbit_ct_broker_helpers:force_vhost_failure(Config, A, <<"/">>),
472-
timer:sleep(300),
475+
timer:sleep(500),
473476
assert_slaves(B, QName, {B, []}),
474477

475478
%% Restart the vhost on the node (previously) hosting queue master
476-
{ok, _Sup} = rabbit_ct_broker_helpers:rpc(Config, A, rabbit_vhost_sup_sup, start_vhost, [<<"/">>]),
477-
timer:sleep(300),
479+
case rabbit_ct_broker_helpers:rpc(Config, A, rabbit_vhost_sup_sup, start_vhost, [<<"/">>]) of
480+
{ok, _Sup} -> ok;
481+
{error,{already_started, _Sup}} -> ok
482+
end,
483+
timer:sleep(500),
478484
assert_slaves(B, QName, {B, [A]}, [{B, []}]).
479485

480486
random_policy(Config) ->
@@ -569,7 +575,7 @@ assert_slaves0(RPCNode, QName, {ExpMNode, ExpSNodes}, PermittedIntermediate, Att
569575
State ->
570576
ct:pal("Waiting to leave state ~p~n Waiting for ~p~n",
571577
[State, {ExpMNode, ExpSNodes}]),
572-
timer:sleep(100),
578+
timer:sleep(200),
573579
assert_slaves0(RPCNode, QName, {ExpMNode, ExpSNodes},
574580
PermittedIntermediate,
575581
Attempts - 1)

0 commit comments

Comments
 (0)