Skip to content

Commit eaf1f0e

Browse files
authored
Merge pull request #8694 from rabbitmq/test-resilience
Tests: more resilient time-dependent tests
2 parents 3ce37e1 + 2aa84d6 commit eaf1f0e

16 files changed

+613
-556
lines changed

deps/rabbit/BUILD.bazel

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,6 @@ rabbitmq_integration_suite(
377377
additional_beam = [
378378
":test_quorum_queue_utils_beam",
379379
],
380-
flaky = True,
381380
shard_count = 7,
382381
)
383382

@@ -565,7 +564,6 @@ rabbitmq_integration_suite(
565564
rabbitmq_integration_suite(
566565
name = "per_user_connection_channel_limit_partitions_SUITE",
567566
size = "large",
568-
flaky = True,
569567
)
570568

571569
rabbitmq_integration_suite(
@@ -1045,7 +1043,6 @@ rabbitmq_integration_suite(
10451043
additional_beam = [
10461044
"test/test_rabbit_event_handler.beam",
10471045
],
1048-
flaky = True,
10491046
)
10501047

10511048
rabbitmq_suite(

deps/rabbit/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ TEST_DEPS = rabbitmq_ct_helpers rabbitmq_ct_client_helpers amqp_client meck prop
149149
PLT_APPS += mnesia
150150

151151
dep_syslog = git https://github.com/schlagert/syslog 4.0.0
152-
dep_osiris = git https://github.com/rabbitmq/osiris v1.6.0
152+
dep_osiris = git https://github.com/rabbitmq/osiris v1.6.1
153153
dep_systemd = hex 0.6.1
154154
dep_seshat = hex 0.4.0
155155

deps/rabbit/app.bzl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,7 @@ def test_suite_beam_files(name = "test_suite_beam_files"):
880880
outs = ["test/definition_import_SUITE.beam"],
881881
app_name = "rabbit",
882882
erlc_opts = "//:test_erlc_opts",
883-
deps = ["//deps/rabbit_common:erlang_app"],
883+
deps = ["//deps/amqp_client:erlang_app", "//deps/rabbitmq_ct_helpers:erlang_app"],
884884
)
885885
erlang_bytecode(
886886
name = "deprecated_features_SUITE_beam_files",
@@ -932,7 +932,7 @@ def test_suite_beam_files(name = "test_suite_beam_files"):
932932
outs = ["test/dynamic_qq_SUITE.beam"],
933933
app_name = "rabbit",
934934
erlc_opts = "//:test_erlc_opts",
935-
deps = ["//deps/amqp_client:erlang_app"],
935+
deps = ["//deps/amqp_client:erlang_app", "//deps/rabbitmq_ct_helpers:erlang_app"],
936936
)
937937
erlang_bytecode(
938938
name = "eager_sync_SUITE_beam_files",
@@ -1111,7 +1111,7 @@ def test_suite_beam_files(name = "test_suite_beam_files"):
11111111
outs = ["test/per_user_connection_tracking_SUITE.beam"],
11121112
app_name = "rabbit",
11131113
erlc_opts = "//:test_erlc_opts",
1114-
deps = ["//deps/amqp_client:erlang_app"],
1114+
deps = ["//deps/amqp_client:erlang_app", "//deps/rabbitmq_ct_helpers:erlang_app"],
11151115
)
11161116
erlang_bytecode(
11171117
name = "per_vhost_connection_limit_SUITE_beam_files",
@@ -1147,7 +1147,7 @@ def test_suite_beam_files(name = "test_suite_beam_files"):
11471147
outs = ["test/per_vhost_queue_limit_SUITE.beam"],
11481148
app_name = "rabbit",
11491149
erlc_opts = "//:test_erlc_opts",
1150-
deps = ["//deps/amqp_client:erlang_app"],
1150+
deps = ["//deps/amqp_client:erlang_app", "//deps/rabbitmq_ct_helpers:erlang_app"],
11511151
)
11521152
erlang_bytecode(
11531153
name = "policy_SUITE_beam_files",
@@ -1218,7 +1218,7 @@ def test_suite_beam_files(name = "test_suite_beam_files"):
12181218
outs = ["test/queue_master_location_SUITE.beam"],
12191219
app_name = "rabbit",
12201220
erlc_opts = "//:test_erlc_opts",
1221-
deps = ["//deps/amqp_client:erlang_app"],
1221+
deps = ["//deps/amqp_client:erlang_app", "//deps/rabbitmq_ct_helpers:erlang_app"],
12221222
)
12231223
erlang_bytecode(
12241224
name = "queue_parallel_SUITE_beam_files",
@@ -1726,7 +1726,7 @@ def test_suite_beam_files(name = "test_suite_beam_files"):
17261726
outs = ["test/unit_log_management_SUITE.beam"],
17271727
app_name = "rabbit",
17281728
erlc_opts = "//:test_erlc_opts",
1729-
deps = ["//deps/amqp_client:erlang_app"],
1729+
deps = ["//deps/amqp_client:erlang_app", "//deps/rabbitmq_ct_helpers:erlang_app"],
17301730
)
17311731
erlang_bytecode(
17321732
name = "unit_operator_policy_SUITE_beam_files",
@@ -1828,7 +1828,7 @@ def test_suite_beam_files(name = "test_suite_beam_files"):
18281828
outs = ["test/vhost_SUITE.beam"],
18291829
app_name = "rabbit",
18301830
erlc_opts = "//:test_erlc_opts",
1831-
deps = ["//deps/amqp_client:erlang_app"],
1831+
deps = ["//deps/amqp_client:erlang_app", "//deps/rabbitmq_ct_helpers:erlang_app"],
18321832
)
18331833
erlang_bytecode(
18341834
name = "rabbit_cuttlefish_SUITE_beam_files",

deps/rabbit/test/dead_lettering_SUITE.erl

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -188,14 +188,15 @@ init_per_testcase(Testcase, Config) ->
188188
rabbit_ct_helpers:testcase_started(Config1, Testcase).
189189

190190
end_per_testcase(Testcase, Config) ->
191+
rabbit_ct_broker_helpers:rpc(Config, 0, ?MODULE, delete_queues, []),
191192
{_, Ch} = rabbit_ct_client_helpers:open_connection_and_channel(Config, 0),
192-
amqp_channel:call(Ch, #'queue.delete'{queue = ?config(queue_name, Config)}),
193-
amqp_channel:call(Ch, #'queue.delete'{queue = ?config(queue_name_dlx, Config)}),
194-
amqp_channel:call(Ch, #'queue.delete'{queue = ?config(queue_name_dlx_2, Config)}),
195193
amqp_channel:call(Ch, #'exchange.delete'{exchange = ?config(dlx_exchange, Config)}),
196194
_ = rabbit_ct_broker_helpers:clear_policy(Config, 0, ?config(policy, Config)),
197195
rabbit_ct_helpers:testcase_finished(Config, Testcase).
198196

197+
delete_queues() ->
198+
[rabbit_amqqueue:delete(Q, false, false, <<"tests">>) || Q <- rabbit_amqqueue:list()].
199+
199200
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
200201
%% Dead letter exchanges
201202
%%
@@ -850,7 +851,15 @@ dead_letter_policy(Config) ->
850851
<<"queues">>,
851852
[{<<"dead-letter-exchange">>, DLXExchange},
852853
{<<"dead-letter-routing-key">>, DLXQName}]),
853-
timer:sleep(1000),
854+
?awaitMatch([_ | _],
855+
begin
856+
{ok, Q0} = rabbit_ct_broker_helpers:rpc(
857+
Config, 0,
858+
rabbit_amqqueue, lookup,
859+
[rabbit_misc:r(<<"/">>, queue, QName)], infinity),
860+
amqqueue:get_policy(Q0)
861+
end,
862+
30000),
854863
%% Nack the second message
855864
amqp_channel:cast(Ch, #'basic.nack'{delivery_tag = DTag2,
856865
multiple = false,
@@ -1319,7 +1328,12 @@ dead_letter_headers_first_death_route(Config) ->
13191328
%% Send and reject the 3rd message.
13201329
P3 = <<"msg3">>,
13211330
publish(Ch, QName2, [P3]),
1322-
timer:sleep(1000),
1331+
case group_name(Config) of
1332+
at_most_once ->
1333+
wait_for_messages(Config, [[QName2, <<"1">>, <<"1">>, <<"0">>]]);
1334+
at_least_once ->
1335+
wait_for_messages(Config, [[QName2, <<"2">>, <<"1">>, <<"0">>]])
1336+
end,
13231337
[DTag] = consume(Ch, QName2, [P3]),
13241338
amqp_channel:cast(Ch, #'basic.reject'{delivery_tag = DTag,
13251339
requeue = false}),

deps/rabbit/test/definition_import_SUITE.erl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
-module(definition_import_SUITE).
99

10+
-include_lib("rabbitmq_ct_helpers/include/rabbit_assert.hrl").
1011
-include_lib("common_test/include/ct.hrl").
1112
-include_lib("rabbit_common/include/rabbit.hrl").
1213
-include_lib("eunit/include/eunit.hrl").
@@ -245,8 +246,7 @@ import_case13a(Config) ->
245246
%% We expect that importing an existing queue (i.e. same vhost and name)
246247
%% but with different arguments and different properties is a no-op.
247248
import_file_case(Config, "case13a"),
248-
timer:sleep(1000),
249-
?assertMatch({ok, Q}, queue_lookup(Config, VHost, QueueName)).
249+
?awaitMatch({ok, Q}, queue_lookup(Config, VHost, QueueName), 30000).
250250

251251
import_case14(Config) -> import_file_case(Config, "case14").
252252
%% contains a user with tags as a list

deps/rabbit/test/dynamic_qq_SUITE.erl

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
-include_lib("common_test/include/ct.hrl").
1010
-include_lib("eunit/include/eunit.hrl").
1111
-include_lib("amqp_client/include/amqp_client.hrl").
12+
-include_lib("rabbitmq_ct_helpers/include/rabbit_assert.hrl").
1213

1314
-import(quorum_queue_utils, [wait_for_messages_ready/3,
1415
ra_name/1]).
@@ -179,21 +180,29 @@ quorum_unaffected_after_vhost_failure(Config) ->
179180
arguments = Args,
180181
durable = true
181182
}),
182-
timer:sleep(300),
183-
184-
Info0 = rpc:call(A, rabbit_quorum_queue, infos,
185-
[rabbit_misc:r(<<"/">>, queue, QName)]),
186-
?assertEqual(Servers, lists:sort(proplists:get_value(online, Info0, []))),
183+
?awaitMatch(
184+
Servers,
185+
begin
186+
Info0 = rpc:call(A, rabbit_quorum_queue, infos,
187+
[rabbit_misc:r(<<"/">>, queue, QName)]),
188+
lists:sort(proplists:get_value(online, Info0, []))
189+
end,
190+
60000),
187191

188192
%% Crash vhost on both nodes
189193
{ok, SupA} = rabbit_ct_broker_helpers:rpc(Config, A, rabbit_vhost_sup_sup, get_vhost_sup, [<<"/">>]),
190194
exit(SupA, foo),
191195
{ok, SupB} = rabbit_ct_broker_helpers:rpc(Config, B, rabbit_vhost_sup_sup, get_vhost_sup, [<<"/">>]),
192196
exit(SupB, foo),
193197

194-
Info = rpc:call(A, rabbit_quorum_queue, infos,
195-
[rabbit_misc:r(<<"/">>, queue, QName)]),
196-
?assertEqual(Servers, lists:sort(proplists:get_value(online, Info, []))).
198+
?awaitMatch(
199+
Servers,
200+
begin
201+
Info = rpc:call(A, rabbit_quorum_queue, infos,
202+
[rabbit_misc:r(<<"/">>, queue, QName)]),
203+
lists:sort(proplists:get_value(online, Info, []))
204+
end,
205+
60000).
197206

198207
recover_follower_after_standalone_restart(Config) ->
199208
case rabbit_ct_helpers:is_mixed_versions() of

deps/rabbit/test/per_user_connection_channel_limit_partitions_SUITE.erl

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,10 @@ cluster_full_partition_with_autoheal(Config) ->
105105
%% B drops off the network, non-reachable by either A or C
106106
rabbit_ct_broker_helpers:block_traffic_between(A, B),
107107
rabbit_ct_broker_helpers:block_traffic_between(B, C),
108-
timer:sleep(?DELAY),
108+
LargeCluster = lists:sort([A, C]),
109+
?awaitMatch(LargeCluster, list_running(Config, A), 60000, 3000),
110+
?awaitMatch([B], list_running(Config, B), 60000, 3000),
111+
?awaitMatch(LargeCluster, list_running(Config, C), 60000, 3000),
109112

110113
%% A and C are still connected, so 4 connections are tracked
111114
%% All connections to B are dropped
@@ -116,7 +119,10 @@ cluster_full_partition_with_autoheal(Config) ->
116119

117120
rabbit_ct_broker_helpers:allow_traffic_between(A, B),
118121
rabbit_ct_broker_helpers:allow_traffic_between(B, C),
119-
timer:sleep(?DELAY),
122+
All = lists:sort([A, B, C]),
123+
?awaitMatch(All, list_running(Config, A), 60000, 3000),
124+
?awaitMatch(All, list_running(Config, B), 60000, 3000),
125+
?awaitMatch(All, list_running(Config, C), 60000, 3000),
120126

121127
%% during autoheal B's connections were dropped
122128
?awaitMatch({4, 10},
@@ -167,3 +173,18 @@ tracked_list_of_user(Config, NodeIndex, TrackingMod, Username) ->
167173
rabbit_ct_broker_helpers:rpc(Config, NodeIndex,
168174
TrackingMod,
169175
list_of_user, [Username]).
176+
177+
list_running(Config, NodeIndex) ->
178+
Ret = (catch rabbit_ct_broker_helpers:rpc(Config, NodeIndex, rabbit_nodes, list_running, [])),
179+
Running = case Ret of
180+
{'EXIT', {{exception, undef, _}, _}} ->
181+
rabbit_ct_broker_helpers:rpc(Config, NodeIndex, rabbit_mnesia, cluster_nodes, [running]);
182+
_ ->
183+
Ret
184+
end,
185+
case Running of
186+
List when is_list(List) ->
187+
lists:sort(List);
188+
Any ->
189+
Any
190+
end.

0 commit comments

Comments
 (0)