Skip to content

Commit 6a1faa6

Browse files
committed
Keep checking that replica recovered in rabbit_stream_queue
Rather than sleeping for 6 seconds, we want to check that replica recovered multiple times within 30 seconds, and either eventually succeed, or fail if this does not recover within 30 seconds, the default await_condition time interval. Pair: @kjnilsson Signed-off-by: Gerhard Lazu <[email protected]>
1 parent c240ec2 commit 6a1faa6

File tree

1 file changed

+23
-16
lines changed

1 file changed

+23
-16
lines changed

deps/rabbit/test/rabbit_stream_queue_SUITE.erl

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1443,29 +1443,36 @@ replica_recovery(Config) ->
14431443
publish_confirm(Ch1, Q, [<<"msg1">> || _ <- lists:seq(1, 100)]),
14441444
amqp_channel:close(Ch1),
14451445

1446+
CheckReplicaRecovered =
1447+
fun(DownNode) ->
1448+
rabbit_ct_helpers:await_condition(
1449+
fun () ->
1450+
timer:sleep(1000),
1451+
ct:pal("Wait for replica to recover..."),
1452+
try
1453+
{Conn, Ch2} = rabbit_ct_client_helpers:open_connection_and_channel(Config, DownNode),
1454+
qos(Ch2, 10, false),
1455+
subscribe(Ch2, Q, false, 0),
1456+
receive_batch(Ch2, 0, 99),
1457+
amqp_connection:close(Conn),
1458+
true
1459+
catch _:_ ->
1460+
false
1461+
end
1462+
end, 30000)
1463+
end,
1464+
14461465
[begin
1447-
[DownNode | _] = PNodes,
14481466
rabbit_control_helper:command(stop_app, DownNode),
14491467
rabbit_control_helper:command(start_app, DownNode),
1450-
timer:sleep(6000),
1451-
Ch2 = rabbit_ct_client_helpers:open_channel(Config, DownNode),
1452-
qos(Ch2, 10, false),
1453-
subscribe(Ch2, Q, false, 0),
1454-
receive_batch(Ch2, 0, 99),
1455-
amqp_channel:close(Ch2)
1456-
end || PNodes <- permute(Nodes)],
1468+
CheckReplicaRecovered(DownNode)
1469+
end || [DownNode | _] <- permute(Nodes)],
14571470

14581471
[begin
1459-
[DownNode | _] = PNodes,
14601472
ok = rabbit_ct_broker_helpers:stop_node(Config, DownNode),
14611473
ok = rabbit_ct_broker_helpers:start_node(Config, DownNode),
1462-
timer:sleep(6000),
1463-
Ch2 = rabbit_ct_client_helpers:open_channel(Config, DownNode),
1464-
qos(Ch2, 10, false),
1465-
subscribe(Ch2, Q, false, 0),
1466-
receive_batch(Ch2, 0, 99),
1467-
amqp_channel:close(Ch2)
1468-
end || PNodes <- permute(Nodes)],
1474+
CheckReplicaRecovered(DownNode)
1475+
end || [DownNode | _] <- permute(Nodes)],
14691476
rabbit_ct_broker_helpers:rpc(Config, 0, ?MODULE, delete_testcase_queue, [Q]).
14701477

14711478
leader_failover(Config) ->

0 commit comments

Comments
 (0)