Skip to content

Commit 26328a5

Browse files
Merge pull request #8646 from rabbitmq/mergify/bp/v3.11.x/pr-8644
Test resilience (backport #8643) (backport #8644)
2 parents 2f3c213 + 7c85e55 commit 26328a5

File tree

5 files changed

+27
-29
lines changed

5 files changed

+27
-29
lines changed

deps/rabbit/app.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1086,7 +1086,7 @@ def test_suite_beam_files(name = "test_suite_beam_files"):
10861086
outs = ["test/per_vhost_msg_store_SUITE.beam"],
10871087
app_name = "rabbit",
10881088
erlc_opts = "//:test_erlc_opts",
1089-
deps = ["//deps/amqp_client:erlang_app"],
1089+
deps = ["//deps/amqp_client:erlang_app", "//deps/rabbitmq_ct_helpers:erlang_app"],
10901090
)
10911091
erlang_bytecode(
10921092
name = "per_vhost_queue_limit_SUITE_beam_files",

deps/rabbit/test/per_vhost_msg_store_SUITE.erl

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
-include_lib("common_test/include/ct.hrl").
1111
-include_lib("amqp_client/include/amqp_client.hrl").
12+
-include_lib("rabbitmq_ct_helpers/include/rabbit_assert.hrl").
1213

1314
-compile(export_all).
1415

@@ -109,23 +110,16 @@ storage_deleted_on_vhost_delete(Config) ->
109110
Vhost1 = ?config(vhost1, Config),
110111
Channel1 = ?config(channel1, Config),
111112
Queue1 = declare_durable_queue(Channel1),
112-
FolderSize = get_global_folder_size(Config),
113+
FolderSize = get_folder_size(Vhost1, Config),
113114

114115
publish_persistent_messages(index, Channel1, Queue1),
115116
publish_persistent_messages(store, Channel1, Queue1),
116-
FolderSizeAfterPublish = get_global_folder_size(Config),
117-
118-
%% Total storage size increased
119-
true = (FolderSize < FolderSizeAfterPublish),
117+
?awaitMatch(true, get_folder_size(Vhost1, Config) > FolderSize, 30000),
120118

121119
ok = rabbit_ct_broker_helpers:delete_vhost(Config, Vhost1),
122120

123-
%% Total memory reduced
124-
FolderSizeAfterDelete = get_global_folder_size(Config),
125-
true = (FolderSizeAfterPublish > FolderSizeAfterDelete),
126-
127121
%% There is no Vhost1 folder
128-
0 = get_folder_size(Vhost1, Config).
122+
?awaitMatch(0, get_folder_size(Vhost1, Config), 30000).
129123

130124

131125
single_vhost_storage_delete_is_safe(Config) ->
@@ -192,10 +186,6 @@ folder_size(Dir) ->
192186
filelib:fold_files(Dir, ".*", true,
193187
fun(F,Acc) -> filelib:file_size(F) + Acc end, 0).
194188

195-
get_global_folder_size(Config) ->
196-
BaseDir = rabbit_ct_broker_helpers:rpc(Config, 0, rabbit_mnesia, dir, []),
197-
folder_size(BaseDir).
198-
199189
vhost_dir(Vhost, Config) ->
200190
rabbit_ct_broker_helpers:rpc(Config, 0,
201191
rabbit_vhost, msg_store_dir_path, [Vhost]).

deps/rabbit/test/quorum_queue_SUITE.erl

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2656,6 +2656,13 @@ message_ttl(Config) ->
26562656
ok.
26572657

26582658
message_ttl_policy(Config) ->
2659+
%% Using ttl is very difficul to guarantee 100% test rate success, unless
2660+
%% using really high ttl values. Previously, this test used 1s and 3s ttl,
2661+
%% but expected to see first the messages in the queue and then the messages
2662+
%% gone. A slow CI run, would fail the first assertion as the messages would
2663+
%% have been dropped when the message count was performed. It happened
2664+
%% from time to time making this test case flaky.
2665+
26592666
[Server | _] = rabbit_ct_broker_helpers:get_node_configs(Config, nodename),
26602667

26612668
Ch = rabbit_ct_client_helpers:open_channel(Config, Server),
@@ -2670,21 +2677,21 @@ message_ttl_policy(Config) ->
26702677
RaName = binary_to_atom(<<VHost/binary, "_", QQ/binary>>, utf8),
26712678

26722679
QueryFun = fun rabbit_fifo:overview/1,
2673-
{ok, {_, Overview}, _} = rpc:call(Server, ra, local_query, [RaName, QueryFun]),
2674-
?assertMatch(#{config := #{msg_ttl := 1000}}, Overview),
2675-
%% wait for policy?
2680+
?awaitMatch({ok, {_, #{config := #{msg_ttl := 1000}}}, _},
2681+
rpc:call(Server, ra, local_query, [RaName, QueryFun]),
2682+
?DEFAULT_AWAIT),
26762683
Msg1 = <<"msg1">>,
26772684
Msg2 = <<"msg11">>,
26782685

26792686
publish(Ch, QQ, Msg1),
26802687
publish(Ch, QQ, Msg2),
2681-
wait_for_messages(Config, [[QQ, <<"2">>, <<"2">>, <<"0">>]]),
26822688
wait_for_messages(Config, [[QQ, <<"0">>, <<"0">>, <<"0">>]]),
2689+
26832690
ok = rabbit_ct_broker_helpers:set_policy(Config, 0, <<"msg-ttl">>,
26842691
QQ, <<"queues">>,
2685-
[{<<"message-ttl">>, 3000}]),
2692+
[{<<"message-ttl">>, 10000}]),
26862693
{ok, {_, Overview2}, _} = rpc:call(Server, ra, local_query, [RaName, QueryFun]),
2687-
?assertMatch(#{config := #{msg_ttl := 3000}}, Overview2),
2694+
?assertMatch(#{config := #{msg_ttl := 10000}}, Overview2),
26882695
publish(Ch, QQ, Msg1),
26892696
wait_for_messages(Config, [[QQ, <<"1">>, <<"1">>, <<"0">>]]),
26902697
wait_for_messages(Config, [[QQ, <<"0">>, <<"0">>, <<"0">>]]),

deps/rabbitmq_recent_history_exchange/app.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,5 +75,5 @@ def test_suite_beam_files(name = "test_suite_beam_files"):
7575
hdrs = ["include/rabbit_recent_history.hrl"],
7676
app_name = "rabbitmq_recent_history_exchange",
7777
erlc_opts = "//:test_erlc_opts",
78-
deps = ["//deps/amqp_client:erlang_app"],
78+
deps = ["//deps/amqp_client:erlang_app", "//deps/rabbitmq_ct_helpers:erlang_app"],
7979
)

deps/rabbitmq_recent_history_exchange/test/system_SUITE.erl

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
-include_lib("eunit/include/eunit.hrl").
1313
-include_lib("amqp_client/include/amqp_client.hrl").
1414
-include("rabbit_recent_history.hrl").
15+
-include_lib("rabbitmq_ct_helpers/include/rabbit_assert.hrl").
1516

1617
all() ->
1718
[
@@ -148,13 +149,13 @@ e2e_test(Config) ->
148149
routing_key = <<"">>
149150
}),
150151

151-
#'queue.declare_ok'{message_count = Count, queue = Q} =
152-
amqp_channel:call(Chan, #'queue.declare' {
153-
passive = true,
154-
queue = Q
155-
}),
156-
157-
?assertEqual(MsgCount, Count),
152+
%% Wait for all messages to be queued.
153+
?awaitMatch(#'queue.declare_ok'{message_count = MsgCount, queue = Q},
154+
amqp_channel:call(Chan, #'queue.declare' {
155+
passive = true,
156+
queue = Q
157+
}),
158+
30000),
158159

159160
amqp_channel:call(Chan, #'exchange.delete' { exchange = make_exchange_name(Config, "1") }),
160161
amqp_channel:call(Chan, #'exchange.delete' { exchange = make_exchange_name(Config, "2") }),

0 commit comments

Comments
 (0)