Skip to content

Commit aeedad7

Browse files
committed
Fix test flake
Prior to this commit, test ``` ERL_AFLAGS="+S 2" make -C deps/rabbit ct-amqp_client t=cluster_size_3:detach_requeues_two_connections_quorum_queue ``` failed rarely locally, and more often in CI. An instance of a failed test in CI is https://github.com/rabbitmq/rabbitmq-server/actions/runs/10298099899/job/28502687451?pr=11945 The test failed with: ``` === === Reason: {assertEqual,[{module,amqp_client_SUITE}, {line,2800}, {expression,"amqp10_msg : body ( Msg1 )"}, {expected,[<<"1">>]}, {value,[<<"2">>]}]} in function amqp_client_SUITE:detach_requeues_two_connections/2 (amqp_client_SUITE.erl, line 2800) ``` because it could happen that Receiver1's credit top up to the quorum queue is applied before Receiver0's credit top up such that Receiver1 gets enqueued to the ServiceQueue before Receiver0.
1 parent 194d4ba commit aeedad7

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

deps/rabbit/test/amqp_client_SUITE.erl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2767,6 +2767,7 @@ detach_requeues_two_connections(QType, Config) ->
27672767
{ok, LinkPair} = rabbitmq_amqp_client:attach_management_link_pair_sync(Session1, <<"my link pair">>),
27682768
QProps = #{arguments => #{<<"x-queue-type">> => {utf8, QType}}},
27692769
{ok, #{type := QType}} = rabbitmq_amqp_client:declare_queue(LinkPair, QName, QProps),
2770+
flush(link_pair_attached),
27702771

27712772
%% Attach 1 sender and 2 receivers.
27722773
{ok, Sender} = amqp10_client:attach_sender_link(Session0, <<"sender">>, Address, settled),
@@ -2778,13 +2779,16 @@ detach_requeues_two_connections(QType, Config) ->
27782779
end,
27792780
ok = gen_statem:cast(Session0, {flow_session, #'v1_0.flow'{incoming_window = {uint, 1}}}),
27802781
ok = amqp10_client:flow_link_credit(Receiver0, 50, never),
2782+
%% Wait for credit being applied to the queue.
2783+
timer:sleep(10),
27812784

27822785
{ok, Receiver1} = amqp10_client:attach_receiver_link(Session1, <<"receiver 1">>, Address, unsettled),
27832786
receive {amqp10_event, {link, Receiver1, attached}} -> ok
27842787
after 5000 -> ct:fail({missing_event, ?LINE})
27852788
end,
2786-
ok = amqp10_client:flow_link_credit(Receiver1, 50, never),
2787-
flush(attached),
2789+
ok = amqp10_client:flow_link_credit(Receiver1, 40, never),
2790+
%% Wait for credit being applied to the queue.
2791+
timer:sleep(10),
27882792

27892793
NumMsgs = 6,
27902794
[begin

0 commit comments

Comments
 (0)