Skip to content

Commit

Permalink
Fix test flake
Browse files Browse the repository at this point in the history
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.

(cherry picked from commit aeedad7)
  • Loading branch information
ansd committed Aug 8, 2024
1 parent ba2388b commit cf719bc
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions deps/rabbit/test/amqp_client_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -2767,6 +2767,7 @@ detach_requeues_two_connections(QType, Config) ->
{ok, LinkPair} = rabbitmq_amqp_client:attach_management_link_pair_sync(Session1, <<"my link pair">>),
QProps = #{arguments => #{<<"x-queue-type">> => {utf8, QType}}},
{ok, #{type := QType}} = rabbitmq_amqp_client:declare_queue(LinkPair, QName, QProps),
flush(link_pair_attached),

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

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

NumMsgs = 6,
[begin
Expand Down

0 comments on commit cf719bc

Please sign in to comment.