Skip to content

Commit 9cc9b12

Browse files
michaelklishinmergify[bot]
authored andcommitted
Test flake chase: adopt eventual matchers in more places
(cherry picked from commit bf89c04) (cherry picked from commit bb85739)
1 parent 30c5c79 commit 9cc9b12

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
@@ -61,8 +61,7 @@ suite() ->
6161
{timetrap, {minutes, 8}}
6262
].
6363

64-
%% see partitions_SUITE
65-
-define(AWAIT, 1000).
64+
-define(AWAIT, 30000).
6665
-define(INTERVAL, 250).
6766

6867
%% -------------------------------------------------------------------

deps/rabbitmq_management/test/rabbit_mgmt_http_SUITE.erl

Lines changed: 42 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -553,13 +553,21 @@ vhosts_test(Config) ->
553553
rabbit_ct_broker_helpers:force_vhost_failure(Config, <<"myvhost">>),
554554
[NodeData] = http_get(Config, "/nodes"),
555555
Node = binary_to_atom(maps:get(name, NodeData), utf8),
556-
assert_item(#{name => <<"myvhost">>, cluster_state => #{Node => <<"stopped">>}},
557-
http_get(Config, "/vhosts/myvhost")),
556+
?AWAIT(begin
557+
assert_item(#{name => <<"myvhost">>,
558+
cluster_state => #{Node => <<"stopped">>}},
559+
http_get(Config, "/vhosts/myvhost")),
560+
true
561+
end),
558562

559563
%% Restart it
560564
http_post(Config, "/vhosts/myvhost/start/" ++ atom_to_list(Node), [], {group, '2xx'}),
561-
assert_item(#{name => <<"myvhost">>, cluster_state => #{Node => <<"running">>}},
562-
http_get(Config, "/vhosts/myvhost")),
565+
?AWAIT(begin
566+
assert_item(#{name => <<"myvhost">>,
567+
cluster_state => #{Node => <<"running">>}},
568+
http_get(Config, "/vhosts/myvhost")),
569+
true
570+
end),
563571

564572
%% Restart on a non-existent node
565573
http_post(Config, "/vhosts/myvhost/start/does-not-exist", [], ?BAD_REQUEST),
@@ -1417,35 +1425,36 @@ queues_test(Config) ->
14171425
%% The vhost is down
14181426
Node = rabbit_ct_broker_helpers:get_node_config(Config, 0, nodename),
14191427
DownVHost = #{name => <<"downvhost">>, tracing => false, cluster_state => #{Node => <<"stopped">>}},
1420-
assert_item(DownVHost, http_get(Config, "/vhosts/downvhost")),
1421-
1422-
DownQueues = http_get(Config, "/queues/downvhost"),
1423-
DownQueue = http_get(Config, "/queues/downvhost/foo"),
1424-
1425-
assert_list([#{name => <<"bar">>,
1426-
vhost => <<"downvhost">>,
1427-
state => <<"stopped">>,
1428-
durable => true,
1429-
auto_delete => false,
1430-
exclusive => false,
1431-
arguments => #{'x-queue-type' => <<"classic">>}
1432-
},
1433-
#{name => <<"foo">>,
1434-
vhost => <<"downvhost">>,
1435-
state => <<"stopped">>,
1436-
durable => true,
1437-
auto_delete => false,
1438-
exclusive => false,
1439-
arguments => #{'x-queue-type' => <<"classic">>}
1440-
}], DownQueues),
1441-
assert_item(#{name => <<"foo">>,
1442-
vhost => <<"downvhost">>,
1443-
state => <<"stopped">>,
1444-
durable => true,
1445-
auto_delete => false,
1446-
exclusive => false,
1447-
arguments => #{'x-queue-type' => <<"classic">>}
1448-
}, DownQueue),
1428+
DownQueueExpected = [#{name => <<"bar">>,
1429+
vhost => <<"downvhost">>,
1430+
state => <<"stopped">>,
1431+
durable => true,
1432+
auto_delete => false,
1433+
exclusive => false,
1434+
arguments => #{'x-queue-type' => <<"classic">>}
1435+
},
1436+
#{name => <<"foo">>,
1437+
vhost => <<"downvhost">>,
1438+
state => <<"stopped">>,
1439+
durable => true,
1440+
auto_delete => false,
1441+
exclusive => false,
1442+
arguments => #{'x-queue-type' => <<"classic">>}
1443+
}],
1444+
?AWAIT(begin
1445+
assert_item(DownVHost, http_get(Config, "/vhosts/downvhost")),
1446+
assert_list(DownQueueExpected, http_get(Config, "/queues/downvhost")),
1447+
assert_item(#{name => <<"foo">>,
1448+
vhost => <<"downvhost">>,
1449+
state => <<"stopped">>,
1450+
durable => true,
1451+
auto_delete => false,
1452+
exclusive => false,
1453+
arguments => #{'x-queue-type' => <<"classic">>}
1454+
},
1455+
http_get(Config, "/queues/downvhost/foo")),
1456+
true
1457+
end),
14491458

14501459
http_put(Config, "/queues/badvhost/bar", Good, ?NOT_FOUND),
14511460
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)