Skip to content

Commit bf89c04

Browse files
Test flake chase: adopt eventual matchers in more places
1 parent c470c25 commit bf89c04

4 files changed

Lines changed: 72 additions & 50 deletions

File tree

deps/rabbit/test/per_vhost_connection_limit_SUITE.erl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,7 @@ suite() ->
8585
{timetrap, {minutes, 8}}
8686
].
8787

88-
%% see partitions_SUITE
89-
-define(AWAIT, 1000).
88+
-define(AWAIT, 30000).
9089
-define(INTERVAL, 250).
9190

9291
%% -------------------------------------------------------------------

deps/rabbitmq_management/test/rabbit_mgmt_http_SUITE.erl

Lines changed: 42 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -544,13 +544,21 @@ vhosts_test(Config) ->
544544
rabbit_ct_broker_helpers:force_vhost_failure(Config, <<"myvhost">>),
545545
[NodeData] = http_get(Config, "/nodes"),
546546
Node = binary_to_atom(maps:get(name, NodeData), utf8),
547-
assert_item(#{name => <<"myvhost">>, cluster_state => #{Node => <<"stopped">>}},
548-
http_get(Config, "/vhosts/myvhost")),
547+
?AWAIT(begin
548+
assert_item(#{name => <<"myvhost">>,
549+
cluster_state => #{Node => <<"stopped">>}},
550+
http_get(Config, "/vhosts/myvhost")),
551+
true
552+
end),
549553

550554
%% Restart it
551555
http_post(Config, "/vhosts/myvhost/start/" ++ atom_to_list(Node), [], {group, '2xx'}),
552-
assert_item(#{name => <<"myvhost">>, cluster_state => #{Node => <<"running">>}},
553-
http_get(Config, "/vhosts/myvhost")),
556+
?AWAIT(begin
557+
assert_item(#{name => <<"myvhost">>,
558+
cluster_state => #{Node => <<"running">>}},
559+
http_get(Config, "/vhosts/myvhost")),
560+
true
561+
end),
554562

555563
%% Restart on a non-existent node
556564
http_post(Config, "/vhosts/myvhost/start/does-not-exist", [], ?BAD_REQUEST),
@@ -1408,35 +1416,36 @@ queues_test(Config) ->
14081416
%% The vhost is down
14091417
Node = rabbit_ct_broker_helpers:get_node_config(Config, 0, nodename),
14101418
DownVHost = #{name => <<"downvhost">>, tracing => false, cluster_state => #{Node => <<"stopped">>}},
1411-
assert_item(DownVHost, http_get(Config, "/vhosts/downvhost")),
1412-
1413-
DownQueues = http_get(Config, "/queues/downvhost"),
1414-
DownQueue = http_get(Config, "/queues/downvhost/foo"),
1415-
1416-
assert_list([#{name => <<"bar">>,
1417-
vhost => <<"downvhost">>,
1418-
state => <<"stopped">>,
1419-
durable => true,
1420-
auto_delete => false,
1421-
exclusive => false,
1422-
arguments => #{'x-queue-type' => <<"classic">>}
1423-
},
1424-
#{name => <<"foo">>,
1425-
vhost => <<"downvhost">>,
1426-
state => <<"stopped">>,
1427-
durable => true,
1428-
auto_delete => false,
1429-
exclusive => false,
1430-
arguments => #{'x-queue-type' => <<"classic">>}
1431-
}], DownQueues),
1432-
assert_item(#{name => <<"foo">>,
1433-
vhost => <<"downvhost">>,
1434-
state => <<"stopped">>,
1435-
durable => true,
1436-
auto_delete => false,
1437-
exclusive => false,
1438-
arguments => #{'x-queue-type' => <<"classic">>}
1439-
}, DownQueue),
1419+
DownQueueExpected = [#{name => <<"bar">>,
1420+
vhost => <<"downvhost">>,
1421+
state => <<"stopped">>,
1422+
durable => true,
1423+
auto_delete => false,
1424+
exclusive => false,
1425+
arguments => #{'x-queue-type' => <<"classic">>}
1426+
},
1427+
#{name => <<"foo">>,
1428+
vhost => <<"downvhost">>,
1429+
state => <<"stopped">>,
1430+
durable => true,
1431+
auto_delete => false,
1432+
exclusive => false,
1433+
arguments => #{'x-queue-type' => <<"classic">>}
1434+
}],
1435+
?AWAIT(begin
1436+
assert_item(DownVHost, http_get(Config, "/vhosts/downvhost")),
1437+
assert_list(DownQueueExpected, http_get(Config, "/queues/downvhost")),
1438+
assert_item(#{name => <<"foo">>,
1439+
vhost => <<"downvhost">>,
1440+
state => <<"stopped">>,
1441+
durable => true,
1442+
auto_delete => false,
1443+
exclusive => false,
1444+
arguments => #{'x-queue-type' => <<"classic">>}
1445+
},
1446+
http_get(Config, "/queues/downvhost/foo")),
1447+
true
1448+
end),
14401449

14411450
http_put(Config, "/queues/badvhost/bar", Good, ?NOT_FOUND),
14421451
http_put(Config, "/queues/%2F/bar",

deps/rabbitmq_management/test/rabbit_mgmt_only_http_SUITE.erl

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -293,13 +293,23 @@ vhosts_test(Config) ->
293293
rabbit_ct_broker_helpers:force_vhost_failure(Config, <<"myvhost">>),
294294
[NodeData] = http_get(Config, "/nodes"),
295295
Node = binary_to_atom(maps:get(name, NodeData), utf8),
296-
assert_item(#{name => <<"myvhost">>, cluster_state => #{Node => <<"stopped">>}},
297-
http_get(Config, "/vhosts/myvhost")),
296+
await_condition(
297+
fun() ->
298+
assert_item(#{name => <<"myvhost">>,
299+
cluster_state => #{Node => <<"stopped">>}},
300+
http_get(Config, "/vhosts/myvhost")),
301+
true
302+
end),
298303

299304
%% Restart it
300305
http_post(Config, "/vhosts/myvhost/start/" ++ atom_to_list(Node), [], {group, '2xx'}),
301-
assert_item(#{name => <<"myvhost">>, cluster_state => #{Node => <<"running">>}},
302-
http_get(Config, "/vhosts/myvhost")),
306+
await_condition(
307+
fun() ->
308+
assert_item(#{name => <<"myvhost">>,
309+
cluster_state => #{Node => <<"running">>}},
310+
http_get(Config, "/vhosts/myvhost")),
311+
true
312+
end),
303313

304314
%% Delete it
305315
http_delete(Config, "/vhosts/myvhost", {group, '2xx'}),
@@ -391,7 +401,6 @@ queues_test(Config) ->
391401
await_condition(
392402
fun() ->
393403
assert_item(DownVHost, http_get(Config, "/vhosts/downvhost")),
394-
DownQueues = http_get(Config, "/queues/downvhost"),
395404
assert_list([#{name => <<"bar">>,
396405
vhost => <<"downvhost">>,
397406
state => <<"stopped">>,
@@ -407,17 +416,17 @@ queues_test(Config) ->
407416
auto_delete => false,
408417
exclusive => false,
409418
arguments => #{'x-queue-type' => <<"classic">>}
410-
}], DownQueues),
419+
}], http_get(Config, "/queues/downvhost")),
420+
assert_item(#{name => <<"foo">>,
421+
vhost => <<"downvhost">>,
422+
state => <<"stopped">>,
423+
durable => true,
424+
auto_delete => false,
425+
exclusive => false,
426+
arguments => #{'x-queue-type' => <<"classic">>}},
427+
http_get(Config, "/queues/downvhost/foo")),
411428
true
412429
end),
413-
DownQueue = http_get(Config, "/queues/downvhost/foo"),
414-
assert_item(#{name => <<"foo">>,
415-
vhost => <<"downvhost">>,
416-
state => <<"stopped">>,
417-
durable => true,
418-
auto_delete => false,
419-
exclusive => false,
420-
arguments => #{'x-queue-type' => <<"classic">>}}, DownQueue),
421430

422431
http_put(Config, "/queues/badvhost/bar", Good, ?NOT_FOUND),
423432
http_put(Config, "/queues/%2F/bar",

deps/rabbitmq_mqtt/test/v5_SUITE.erl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,12 @@ session_expiry_disconnect_decrease(QueueType, Config) ->
440440
{?LINE, fun() -> assert_queue_ttl(1, 1, Config) end},
441441
100, 50),
442442

443-
timer:sleep(1500),
443+
%% Wait for the TTL to expire and the queue to be deleted before
444+
%% reconnecting. Otherwise C2 may hit the queue mid-deletion and the broker
445+
%% rejects the connection with an error.
446+
rabbit_ct_helpers:eventually(
447+
?_assertEqual(0, rpc(Config, rabbit_amqqueue, count, [])),
448+
200, 50),
444449
C2 = connect(ClientId, Config, [{clean_start, false}]),
445450
%% Server should reply in CONNACK that it does not have session state for our client ID.
446451
?assertEqual({session_present, 0},

0 commit comments

Comments
 (0)