Skip to content

Commit c9a35f9

Browse files
Merge pull request #12834 from rabbitmq/fix-flakes
More fixes for test flakes: AMQP 1.0 client, management clustering property-based tests
2 parents c7f6a71 + 9b8f4bf commit c9a35f9

File tree

3 files changed

+34
-24
lines changed

3 files changed

+34
-24
lines changed

deps/amqp10_client/test/system_SUITE.erl

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212

1313
-include_lib("amqp10_common/include/amqp10_framing.hrl").
1414

15-
-include("src/amqp10_client.hrl").
16-
1715
-compile([export_all, nowarn_export_all]).
1816

17+
-define(TIMEOUT, 30000).
18+
1919
suite() ->
2020
[{timetrap, {minutes, 4}}].
2121

@@ -184,7 +184,7 @@ open_close_connection(Config) ->
184184
{ok, Connection2} = amqp10_client:open_connection(OpnConf),
185185
receive
186186
{amqp10_event, {connection, Connection2, opened}} -> ok
187-
after 5000 -> exit(connection_timeout)
187+
after ?TIMEOUT -> exit(connection_timeout)
188188
end,
189189
ok = amqp10_client:close_connection(Connection2),
190190
ok = amqp10_client:close_connection(Connection).
@@ -201,7 +201,7 @@ open_connection_plain_sasl(Config) ->
201201
{ok, Connection} = amqp10_client:open_connection(OpnConf),
202202
receive
203203
{amqp10_event, {connection, Connection, opened}} -> ok
204-
after 5000 -> exit(connection_timeout)
204+
after ?TIMEOUT -> exit(connection_timeout)
205205
end,
206206
ok = amqp10_client:close_connection(Connection).
207207

@@ -225,7 +225,7 @@ open_connection_plain_sasl_parse_uri(Config) ->
225225
{ok, Connection} = amqp10_client:open_connection(OpnConf),
226226
receive
227227
{amqp10_event, {connection, Connection, opened}} -> ok
228-
after 5000 -> exit(connection_timeout)
228+
after ?TIMEOUT -> exit(connection_timeout)
229229
end,
230230
ok = amqp10_client:close_connection(Connection).
231231

@@ -245,7 +245,7 @@ open_connection_plain_sasl_failure(Config) ->
245245
% some implementation may simply close the tcp_connection
246246
{amqp10_event, {connection, Connection, {closed, shutdown}}} -> ok
247247

248-
after 5000 ->
248+
after ?TIMEOUT ->
249249
ct:pal("Connection process is alive? = ~tp~n",
250250
[erlang:is_process_alive(Connection)]),
251251
exit(connection_timeout)
@@ -469,27 +469,27 @@ notify_with_performative(Config) ->
469469

470470
{ok, Connection} = amqp10_client:open_connection(OpenConf),
471471
receive {amqp10_event, {connection, Connection, {opened, #'v1_0.open'{}}}} -> ok
472-
after 5000 -> ct:fail({missing_event, ?LINE})
472+
after ?TIMEOUT -> ct:fail({missing_event, ?LINE})
473473
end,
474474

475475
{ok, Session1} = amqp10_client:begin_session(Connection),
476476
receive {amqp10_event, {session, Session1, {begun, #'v1_0.begin'{}}}} -> ok
477-
after 5000 -> ct:fail({missing_event, ?LINE})
477+
after ?TIMEOUT -> ct:fail({missing_event, ?LINE})
478478
end,
479479

480480
{ok, Sender1} = amqp10_client:attach_sender_link(Session1, <<"sender 1">>, <<"/exchanges/amq.fanout">>),
481481
receive {amqp10_event, {link, Sender1, {attached, #'v1_0.attach'{}}}} -> ok
482-
after 5000 -> ct:fail({missing_event, ?LINE})
482+
after ?TIMEOUT -> ct:fail({missing_event, ?LINE})
483483
end,
484484

485485
ok = amqp10_client:detach_link(Sender1),
486486
receive {amqp10_event, {link, Sender1, {detached, #'v1_0.detach'{}}}} -> ok
487-
after 5000 -> ct:fail({missing_event, ?LINE})
487+
after ?TIMEOUT -> ct:fail({missing_event, ?LINE})
488488
end,
489489

490490
ok = amqp10_client:end_session(Session1),
491491
receive {amqp10_event, {session, Session1, {ended, #'v1_0.end'{}}}} -> ok
492-
after 5000 -> ct:fail({missing_event, ?LINE})
492+
after ?TIMEOUT -> ct:fail({missing_event, ?LINE})
493493
end,
494494

495495
%% Test that the amqp10_client:*_sync functions work.
@@ -501,7 +501,7 @@ notify_with_performative(Config) ->
501501

502502
ok = amqp10_client:close_connection(Connection),
503503
receive {amqp10_event, {connection, Connection, {closed, #'v1_0.close'{}}}} -> ok
504-
after 5000 -> ct:fail({missing_event, ?LINE})
504+
after ?TIMEOUT -> ct:fail({missing_event, ?LINE})
505505
end.
506506

507507
% a message is sent before the link attach is guaranteed to
@@ -600,13 +600,13 @@ subscribe(Config) ->
600600
[begin
601601
receive {amqp10_msg, Receiver, Msg} ->
602602
ok = amqp10_client:accept_msg(Receiver, Msg)
603-
after 2000 -> ct:fail(timeout)
603+
after ?TIMEOUT -> ct:fail(timeout)
604604
end
605605
end || _ <- lists:seq(1, 10)],
606606
ok = assert_no_message(Receiver),
607607

608608
receive {amqp10_event, {link, Receiver, credit_exhausted}} -> ok
609-
after 5000 -> flush(),
609+
after ?TIMEOUT -> flush(),
610610
exit(credit_exhausted_assert)
611611
end,
612612

@@ -854,7 +854,7 @@ multi_transfer_without_delivery_id(Config) ->
854854
receive
855855
{amqp10_msg, Receiver, _InMsg} ->
856856
ok
857-
after 2000 ->
857+
after ?TIMEOUT ->
858858
exit(delivery_timeout)
859859
end,
860860

@@ -909,7 +909,7 @@ incoming_heartbeat(Config) ->
909909
{closed, _}}}
910910
when Connection0 =:= Connection ->
911911
ok
912-
after 5000 ->
912+
after ?TIMEOUT ->
913913
exit(incoming_heartbeat_assert)
914914
end,
915915
demonitor(MockRef).
@@ -926,7 +926,7 @@ await_link(Who, What, Err) ->
926926
{amqp10_event, {link, Who0, {detached, Why}}}
927927
when Who0 =:= Who ->
928928
ct:fail(Why)
929-
after 5000 ->
929+
after ?TIMEOUT ->
930930
flush(),
931931
ct:fail(Err)
932932
end.
@@ -943,7 +943,7 @@ await_disposition(DeliveryTag) ->
943943
receive
944944
{amqp10_disposition, {accepted, DeliveryTag0}}
945945
when DeliveryTag0 =:= DeliveryTag -> ok
946-
after 3000 ->
946+
after ?TIMEOUT ->
947947
flush(),
948948
ct:fail(dispostion_timeout)
949949
end.
@@ -955,7 +955,7 @@ count_received_messages0(Receiver, Count) ->
955955
receive
956956
{amqp10_msg, Receiver, _Msg} ->
957957
count_received_messages0(Receiver, Count + 1)
958-
after 500 ->
958+
after 5000 ->
959959
Count
960960
end.
961961

@@ -968,7 +968,7 @@ receive_messages0(Receiver, N, Acc) ->
968968
receive
969969
{amqp10_msg, Receiver, Msg} ->
970970
receive_messages0(Receiver, N - 1, [Msg | Acc])
971-
after 5000 ->
971+
after ?TIMEOUT ->
972972
LastReceivedMsg = case Acc of
973973
[] -> none;
974974
[M | _] -> M

deps/rabbit/test/feature_flags_v2_SUITE.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ stop_slave_node(Node) ->
203203
persistent_term:erase({?MODULE, Node}),
204204

205205
ct:pal("- Stopping slave node `~ts`...", [Node]),
206-
ok = peer:stop(NodePid)
206+
_ = peer:stop(NodePid)
207207
end.
208208

209209
connect_nodes([FirstNode | OtherNodes] = Nodes) ->

deps/rabbitmq_management/test/clustering_prop_SUITE.erl

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,17 +109,19 @@ prop_connection_channel_counts(Config) ->
109109
{1, force_stats}])),
110110
begin
111111
% ensure we begin with no connections
112+
ct:pal("Init testcase"),
112113
true = validate_counts(Config, []),
113114
Cons = lists:foldl(fun (Op, Agg) ->
114115
execute_op(Config, Op, Agg)
115116
end, [], Ops),
116117
%% TODO retry a few times
118+
ct:pal("Check testcase"),
117119
Res = retry_for(
118120
fun() ->
119121
force_stats(Config),
120122
validate_counts(Config, Cons) end,
121123
60),
122-
cleanup(Cons),
124+
ct:pal("Cleanup testcase"),
123125
rabbit_ct_helpers:await_condition(
124126
fun () ->
125127
cleanup(Cons),
@@ -138,8 +140,16 @@ validate_counts(Config, Conns) ->
138140
Ch1 = length(http_get_from_node(Config, 0, "/channels")),
139141
Ch2 = length(http_get_from_node(Config, 1, "/channels")),
140142
Ch3 = length(http_get_from_node(Config, 2, "/channels")),
141-
[Expected, Expected, Expected, ChanCount, ChanCount, ChanCount]
142-
=:= [C1, C2, C3, Ch1, Ch2, Ch3].
143+
Res = ([Expected, Expected, Expected, ChanCount, ChanCount, ChanCount]
144+
=:= [C1, C2, C3, Ch1, Ch2, Ch3]),
145+
case Res of
146+
false ->
147+
ct:pal("Validate counts connections: ~p channels: ~p got ~p",
148+
[Expected, ChanCount, [C1, C2, C3, Ch1, Ch2, Ch3]]);
149+
true ->
150+
ok
151+
end,
152+
Res.
143153

144154

145155
cleanup(Conns) ->

0 commit comments

Comments
 (0)