Skip to content

Commit 27be877

Browse files
acogoluegnesmergify[bot]
authored andcommitted
Poll with basic.get in test
To make sure to get the message. (cherry picked from commit b840200)
1 parent a93f20d commit 27be877

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

deps/rabbit/test/quorum_queue_SUITE.erl

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -921,18 +921,18 @@ reject_after_leader_transfer(Config) ->
921921

922922
Ch2 = rabbit_ct_client_helpers:open_channel(Config, Server2),
923923
{#'basic.get_ok'{delivery_tag = Tag}, #amqp_msg{}} =
924-
amqp_channel:call(Ch2, #'basic.get'{queue = QQ, no_ack = false}),
924+
basic_get(Ch2, QQ, false, 10),
925925

926926
ServerId1 = {RaName, Server1},
927-
ct:pal("transfser leadership ~p",
927+
ct:pal("transfer leadership ~p",
928928
[rabbit_ct_broker_helpers:rpc(Config, 0, ra,
929929
transfer_leadership, [ServerId1, ServerId1])]),
930930
ok = amqp_channel:call(Ch2, #'basic.reject'{delivery_tag = Tag,
931931
requeue = true}),
932932
wait_for_messages(Config, [[QQ, <<"1">>, <<"1">>, <<"0">>]]),
933933

934934
{#'basic.get_ok'{delivery_tag = Tag2}, #amqp_msg{}} =
935-
amqp_channel:call(Ch2, #'basic.get'{queue = QQ, no_ack = false}),
935+
basic_get(Ch2, QQ, false, 10),
936936

937937
ok = amqp_channel:call(Ch2, #'basic.reject'{delivery_tag = Tag2,
938938
requeue = true}),
@@ -3371,3 +3371,14 @@ validate_queue(Ch, Queue, ExpectedMsgs) ->
33713371
end
33723372
end || M <- ExpectedMsgs],
33733373
ok.
3374+
3375+
basic_get(_, _, _, 0) ->
3376+
empty;
3377+
basic_get(Ch, Q, NoAck, Attempt) ->
3378+
case amqp_channel:call(Ch, #'basic.get'{queue = Q, no_ack = NoAck}) of
3379+
{#'basic.get_ok'{}, #amqp_msg{}} = R ->
3380+
R;
3381+
_ ->
3382+
timer:sleep(100),
3383+
basic_get(Ch, Q, NoAck, Attempt - 1)
3384+
end.

0 commit comments

Comments
 (0)