Skip to content

Commit de866b8

Browse files
Merge pull request #11547 from rabbitmq/speed-up-rabbit-tests
Speed up rabbit tests suites
2 parents 8ae8f73 + 1825f2b commit de866b8

16 files changed

+241
-348
lines changed

deps/rabbit/.DS_Store

6 KB
Binary file not shown.

deps/rabbit/BUILD.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ rabbitmq_integration_suite(
660660
additional_beam = [
661661
":test_queue_utils_beam",
662662
],
663-
shard_count = 5,
663+
shard_count = 3,
664664
)
665665

666666
rabbitmq_integration_suite(
@@ -814,7 +814,7 @@ rabbitmq_integration_suite(
814814
additional_beam = [
815815
":test_queue_utils_beam",
816816
],
817-
shard_count = 22,
817+
shard_count = 19,
818818
deps = [
819819
"@proper//:erlang_app",
820820
],

deps/rabbit/test/consumer_timeout_SUITE.erl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@
1010
-include_lib("amqp_client/include/amqp_client.hrl").
1111
-include_lib("eunit/include/eunit.hrl").
1212

13+
-compile(nowarn_export_all).
1314
-compile(export_all).
1415

15-
-define(CONSUMER_TIMEOUT, 3000).
16-
-define(RECEIVE_TIMEOUT, 5000).
16+
-define(CONSUMER_TIMEOUT, 2000).
17+
-define(RECEIVE_TIMEOUT, ?CONSUMER_TIMEOUT * 2).
1718

1819
-define(GROUP_CONFIG,
1920
#{global_consumer_timeout => [{rabbit, [{consumer_timeout, ?CONSUMER_TIMEOUT}]},
@@ -84,8 +85,9 @@ init_per_group(Group, Config0) ->
8485
GroupConfig = maps:get(Group, ?GROUP_CONFIG),
8586
ClusterSize = 3,
8687
Config = rabbit_ct_helpers:merge_app_env(
87-
Config0, {rabbit, [{channel_tick_interval, 1000},
88-
{quorum_tick_interval, 1000}] ++ ?config(rabbit, GroupConfig)}),
88+
Config0, {rabbit, [{channel_tick_interval, 256},
89+
{quorum_tick_interval, 256}] ++
90+
?config(rabbit, GroupConfig)}),
8991
Config1 = rabbit_ct_helpers:set_config(
9092
Config, [ {rmq_nodename_suffix, Group},
9193
{rmq_nodes_count, ClusterSize}

deps/rabbit/test/dead_lettering_SUITE.erl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ groups() ->
7878
dead_letter_routing_key_cycle_max_length,
7979
dead_letter_headers_reason_maxlen,
8080
%% tested separately in rabbit_fifo_dlx_integration_SUITE
81-
dead_letter_missing_exchange
81+
dead_letter_missing_exchange,
82+
dead_letter_routing_key_cycle_ttl
8283
]}
8384
]
8485
},
@@ -95,9 +96,14 @@ suite() ->
9596
%% -------------------------------------------------------------------
9697

9798
init_per_suite(Config0) ->
99+
Tick = 256,
98100
rabbit_ct_helpers:log_environment(),
99101
Config = rabbit_ct_helpers:merge_app_env(
100-
Config0, {rabbit, [{dead_letter_worker_publisher_confirm_timeout, 2000}]}),
102+
Config0, {rabbit, [{dead_letter_worker_publisher_confirm_timeout, 2000},
103+
{collect_statistics_interval, Tick},
104+
{channel_tick_interval, Tick},
105+
{quorum_tick_interval, Tick},
106+
{stream_tick_interval, Tick}]}),
101107
rabbit_ct_helpers:run_setup_steps(Config).
102108

103109
end_per_suite(Config) ->

deps/rabbit/test/dynamic_qq_SUITE.erl

Lines changed: 38 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,7 @@ groups() ->
2727
{clustered, [], [
2828
{cluster_size_3, [], [
2929
vhost_deletion,
30-
quorum_unaffected_after_vhost_failure
31-
]},
32-
{cluster_size_5, [], [
33-
%% Khepri does not work on a cluster in minority. Thus, to test these
34-
%% specific cases with quorum queues in minority we need a bigger cluster.
35-
%% 5-nodes RMQ and 3-nodes quorum queues allows to test the same test
36-
%% cases than a 3-nodes mnesia cluster.
30+
quorum_unaffected_after_vhost_failure,
3731
recover_follower_after_standalone_restart,
3832
force_delete_if_no_consensus,
3933
takeover_on_failure,
@@ -129,8 +123,11 @@ force_delete_if_no_consensus(Config) ->
129123
ACh = rabbit_ct_client_helpers:open_channel(Config, A),
130124
rabbit_ct_client_helpers:publish(ACh, QName, 10),
131125

132-
ok = rabbit_ct_broker_helpers:restart_node(Config, B),
133-
ok = rabbit_ct_broker_helpers:stop_node(Config, A),
126+
%% Delete a member on one node
127+
?assertEqual(ok,
128+
rpc:call(Server, rabbit_quorum_queue, delete_member,
129+
[<<"/">>, QName, B])),
130+
%% stop another node
134131
ok = rabbit_ct_broker_helpers:stop_node(Config, C),
135132

136133
BCh = rabbit_ct_client_helpers:open_channel(Config, B),
@@ -144,6 +141,7 @@ force_delete_if_no_consensus(Config) ->
144141
BCh2 = rabbit_ct_client_helpers:open_channel(Config, B),
145142
?assertMatch(#'queue.delete_ok'{},
146143
amqp_channel:call(BCh2, #'queue.delete'{queue = QName})),
144+
ok = rabbit_ct_broker_helpers:restart_node(Config, C),
147145
ok.
148146

149147
takeover_on_failure(Config) ->
@@ -222,56 +220,38 @@ quorum_unaffected_after_vhost_failure(Config) ->
222220
60000).
223221

224222
recover_follower_after_standalone_restart(Config) ->
225-
case rabbit_ct_helpers:is_mixed_versions() of
226-
false ->
227-
%% Tests that followers can be brought up standalone after forgetting the
228-
%% rest of the cluster. Consensus won't be reached as there is only one node in the
229-
%% new cluster.
230-
[Server | _] = rabbit_ct_broker_helpers:get_node_configs(Config, nodename),
231-
Ch = rabbit_ct_client_helpers:open_channel(Config, Server),
232-
233-
QName = ?config(queue_name, Config),
234-
Args = ?config(queue_args, Config),
235-
amqp_channel:call(Ch, #'queue.declare'{queue = QName,
236-
arguments = Args,
237-
durable = true
238-
}),
239-
240-
RaName = queue_utils:ra_name(QName),
241-
{ok, [{_, A}, {_, B}, {_, C}], _} = ra:members({RaName, Server}),
242-
Servers = [A, B, C],
243-
244-
rabbit_ct_client_helpers:publish(Ch, QName, 15),
245-
rabbit_ct_client_helpers:close_channel(Ch),
246-
247-
Name = ra_name(QName),
248-
wait_for_messages_ready(Servers, Name, 15),
249-
250-
rabbit_ct_broker_helpers:stop_node(Config, C),
251-
rabbit_ct_broker_helpers:stop_node(Config, B),
252-
rabbit_ct_broker_helpers:stop_node(Config, A),
253-
254-
%% Restart one follower
255-
forget_cluster_node(Config, B, C),
256-
forget_cluster_node(Config, B, A),
257-
258-
ok = rabbit_ct_broker_helpers:start_node(Config, B),
259-
wait_for_messages_ready([B], Name, 15),
260-
ok = rabbit_ct_broker_helpers:stop_node(Config, B),
261-
262-
%% Restart the other
263-
forget_cluster_node(Config, C, B),
264-
forget_cluster_node(Config, C, A),
265-
266-
ok = rabbit_ct_broker_helpers:start_node(Config, C),
267-
wait_for_messages_ready([C], Name, 15),
268-
ok = rabbit_ct_broker_helpers:stop_node(Config, C),
269-
ok;
270-
_ ->
271-
{skip, "cannot be run in mixed mode"}
272-
end.
223+
%% Tests that quorum queues shrink when forget_cluster_node
224+
%% operations are issues.
225+
[Server | _] = rabbit_ct_broker_helpers:get_node_configs(Config, nodename),
226+
Ch = rabbit_ct_client_helpers:open_channel(Config, Server),
227+
228+
QName = ?config(queue_name, Config),
229+
Args = ?config(queue_args, Config),
230+
amqp_channel:call(Ch, #'queue.declare'{queue = QName,
231+
arguments = Args,
232+
durable = true
233+
}),
234+
235+
RaName = queue_utils:ra_name(QName),
236+
{ok, [{_, A}, {_, B}, {_, C}], _} = ra:members({RaName, Server}),
237+
Servers = [A, B, C],
238+
239+
Name = ra_name(QName),
240+
241+
rabbit_ct_client_helpers:publish(Ch, QName, 15),
242+
wait_for_messages_ready(Servers, Name, 15),
243+
rabbit_ct_client_helpers:close_channel(Ch),
244+
245+
%% Restart one follower
246+
forget_cluster_node(Config, B, C),
247+
wait_for_messages_ready([B], Name, 15),
248+
forget_cluster_node(Config, B, A),
249+
wait_for_messages_ready([B], Name, 15),
250+
251+
ok.
273252

274253
%%----------------------------------------------------------------------------
275254
forget_cluster_node(Config, Node, NodeToRemove) ->
255+
ok = rabbit_control_helper:command(stop_app, NodeToRemove),
276256
rabbit_ct_broker_helpers:rabbitmqctl(
277-
Config, Node, ["forget_cluster_node", "--offline", NodeToRemove]).
257+
Config, Node, ["forget_cluster_node", NodeToRemove]).

deps/rabbit/test/metrics_SUITE.erl

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
%% Copyright (c) 2007-2024 Broadcom. All Rights Reserved. The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. All rights reserved.
66
%%
77
-module(metrics_SUITE).
8+
-compile(nowarn_export_all).
89
-compile(export_all).
910

10-
-include_lib("common_test/include/ct.hrl").
1111
-include_lib("proper/include/proper.hrl").
1212
-include_lib("eunit/include/eunit.hrl").
1313
-include_lib("amqp_client/include/amqp_client.hrl").
@@ -142,7 +142,12 @@ connection_metric_idemp(Config, {N, R}) ->
142142
5000),
143143
Table2 = [ Pid || {Pid, _} <- read_table_rpc(Config, connection_coarse_metrics)],
144144
% refresh stats 'R' times
145-
[[Pid ! emit_stats || Pid <- Table] || _ <- lists:seq(1, R)],
145+
[[begin
146+
Pid ! emit_stats
147+
end|| Pid <- Table] || _ <- lists:seq(1, R)],
148+
[begin
149+
_ = gen_server:call(Pid, {info, [pid]})
150+
end|| Pid <- Table],
146151
force_metric_gc(Config),
147152
TableAfter = [ Pid || {Pid, _} <- read_table_rpc(Config, connection_metrics)],
148153
TableAfter2 = [ Pid || {Pid, _} <- read_table_rpc(Config, connection_coarse_metrics)],
@@ -159,6 +164,9 @@ channel_metric_idemp(Config, {N, R}) ->
159164
Table2 = [ Pid || {Pid, _} <- read_table_rpc(Config, channel_process_metrics)],
160165
% refresh stats 'R' times
161166
[[Pid ! emit_stats || Pid <- Table] || _ <- lists:seq(1, R)],
167+
[begin
168+
_ = gen_server:call(Pid, {info, [pid]})
169+
end|| Pid <- Table],
162170
force_metric_gc(Config),
163171
TableAfter = [ Pid || {Pid, _} <- read_table_rpc(Config, channel_metrics)],
164172
TableAfter2 = [ Pid || {Pid, _} <- read_table_rpc(Config, channel_process_metrics)],
@@ -182,7 +190,10 @@ queue_metric_idemp(Config, {N, R}) ->
182190
Table2 = [ Pid || {Pid, _, _} <- read_table_rpc(Config, queue_coarse_metrics)],
183191
% refresh stats 'R' times
184192
ChanTable = read_table_rpc(Config, channel_created),
185-
[[Pid ! emit_stats || {Pid, _, _} <- ChanTable ] || _ <- lists:seq(1, R)],
193+
[[begin
194+
Pid ! emit_stats,
195+
gen_server2:call(Pid, flush)
196+
end|| {Pid, _, _} <- ChanTable ] || _ <- lists:seq(1, R)],
186197
force_metric_gc(Config),
187198
TableAfter = [ Pid || {Pid, _, _} <- read_table_rpc(Config, queue_metrics)],
188199
TableAfter2 = [ Pid || {Pid, _, _} <- read_table_rpc(Config, queue_coarse_metrics)],
@@ -383,8 +394,13 @@ ensure_channel_queue_metrics_populated(Chan, Queue) ->
383394
{#'basic.get_ok'{}, #amqp_msg{}} = amqp_channel:call(Chan, Get).
384395

385396
force_channel_stats(Config) ->
386-
[ Pid ! emit_stats || {Pid, _} <- read_table_rpc(Config, channel_created) ],
387-
timer:sleep(100).
397+
[begin
398+
Pid ! emit_stats,
399+
gen_server2:call(Pid, flush)
400+
end
401+
|| {Pid, _} <- read_table_rpc(Config, channel_created)
402+
],
403+
ok.
388404

389405
read_table_rpc(Config, Table) ->
390406
rabbit_ct_broker_helpers:rpc(Config, 0, ?MODULE, read_table, [Table]).
@@ -397,7 +413,6 @@ read_table(Table) ->
397413
ets:tab2list(Table).
398414

399415
force_metric_gc(Config) ->
400-
timer:sleep(300),
401416
rabbit_ct_broker_helpers:rpc(Config, 0, erlang, send,
402417
[rabbit_core_metrics_gc, start_gc]),
403418
rabbit_ct_broker_helpers:rpc(Config, 0, gen_server, call,

deps/rabbit/test/peer_discovery_classic_config_SUITE.erl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
cluster_members_online/2
1616
]).
1717

18+
-compile(nowarn_export_all).
1819
-compile(export_all).
1920

2021
all() ->

deps/rabbit/test/product_info_SUITE.erl

Lines changed: 27 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -55,53 +55,43 @@ init_per_suite(Config) ->
5555
end.
5656

5757
end_per_suite(Config) ->
58-
rabbit_ct_helpers:run_teardown_steps(Config).
59-
60-
init_per_group(_, Config) ->
61-
Config.
62-
63-
end_per_group(_, Config) ->
6458
Config.
6559

66-
init_per_testcase(Testcase, Config) ->
67-
rabbit_ct_helpers:testcase_started(Config, Testcase),
60+
init_per_group(Group, Config0) ->
6861
ClusterSize = 1,
69-
TestNumber = rabbit_ct_helpers:testcase_number(Config, ?MODULE, Testcase),
62+
PrivDir = ?config(priv_dir, Config0),
63+
MotdFile = filename:join(PrivDir, "motd.txt"),
64+
ok = file:write_file(MotdFile, <<"My MOTD\n">>),
7065
Config1 = rabbit_ct_helpers:set_config(
71-
Config,
66+
Config0,
7267
[
73-
{rmq_nodename_suffix, Testcase},
74-
{tcp_ports_base, {skip_n_nodes, TestNumber * ClusterSize}}
68+
{rmq_nodename_suffix, Group},
69+
{tcp_ports_base, {skip_n_nodes, ClusterSize}},
70+
{motd_file, MotdFile}
7571
]),
76-
Config2 = case Testcase of
77-
override_product_name_in_conf ->
78-
rabbit_ct_helpers:merge_app_env(
79-
Config1,
80-
{rabbit, [{product_name, "MyProduct"}]});
81-
override_product_version_in_conf ->
82-
rabbit_ct_helpers:merge_app_env(
83-
Config1,
84-
{rabbit, [{product_version, "MyVersion"}]});
85-
set_motd_in_conf ->
86-
PrivDir = ?config(priv_dir, Config),
87-
MotdFile = filename:join(PrivDir, "motd.txt"),
88-
ok = file:write_file(MotdFile, <<"My MOTD\n">>),
89-
C2 = rabbit_ct_helpers:set_config(
90-
Config1,
91-
{motd_file, MotdFile}),
92-
rabbit_ct_helpers:merge_app_env(
93-
C2,
94-
{rabbit, [{motd_file, MotdFile}]})
95-
end,
96-
rabbit_ct_helpers:run_steps(Config2,
72+
73+
Config = rabbit_ct_helpers:merge_app_env(
74+
Config1,
75+
{rabbit, [
76+
{product_name, "MyProduct"},
77+
{product_version, "MyVersion"},
78+
{motd_file, MotdFile}]}),
79+
rabbit_ct_helpers:run_steps(Config,
9780
rabbit_ct_broker_helpers:setup_steps() ++
9881
rabbit_ct_client_helpers:setup_steps()).
9982

83+
end_per_group(_, Config) ->
84+
rabbit_ct_helpers:run_steps(Config,
85+
rabbit_ct_client_helpers:teardown_steps() ++
86+
rabbit_ct_broker_helpers:teardown_steps()).
87+
88+
init_per_testcase(Testcase, Config) ->
89+
rabbit_ct_helpers:testcase_started(Config, Testcase),
90+
Config.
91+
10092
end_per_testcase(Testcase, Config) ->
101-
Config1 = rabbit_ct_helpers:run_steps(Config,
102-
rabbit_ct_client_helpers:teardown_steps() ++
103-
rabbit_ct_broker_helpers:teardown_steps()),
104-
rabbit_ct_helpers:testcase_finished(Config1, Testcase).
93+
rabbit_ct_helpers:testcase_finished(Config, Testcase),
94+
Config.
10595

10696
%% -------------------------------------------------------------------
10797
%% Testcases.

deps/rabbit/test/queue_parallel_SUITE.erl

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ groups() ->
6868
{classic_queue, GroupOptions, AllTests ++ [delete_immediately_by_pid_succeeds,
6969
trigger_message_store_compaction]},
7070
{quorum_queue, GroupOptions, AllTests ++ ExtraBccTests ++ [delete_immediately_by_pid_fails]},
71-
{quorum_queue_in_memory_limit, GroupOptions, AllTests ++ [delete_immediately_by_pid_fails]},
72-
{quorum_queue_in_memory_bytes, GroupOptions, AllTests ++ [delete_immediately_by_pid_fails]},
7371
{stream_queue, GroupOptions, ExtraBccTests ++ [publish, subscribe]}
7472
]}
7573
].
@@ -102,20 +100,6 @@ init_per_group(quorum_queue, Config) ->
102100
[{queue_args, [{<<"x-queue-type">>, longstr, <<"quorum">>}]},
103101
{consumer_args, []},
104102
{queue_durable, true}]);
105-
init_per_group(quorum_queue_in_memory_limit, Config) ->
106-
rabbit_ct_helpers:set_config(
107-
Config,
108-
[{queue_args, [{<<"x-queue-type">>, longstr, <<"quorum">>},
109-
{<<"x-max-in-memory-length">>, long, 1}]},
110-
{consumer_args, []},
111-
{queue_durable, true}]);
112-
init_per_group(quorum_queue_in_memory_bytes, Config) ->
113-
rabbit_ct_helpers:set_config(
114-
Config,
115-
[{queue_args, [{<<"x-queue-type">>, longstr, <<"quorum">>},
116-
{<<"x-max-in-memory-bytes">>, long, 1}]},
117-
{consumer_args, []},
118-
{queue_durable, true}]);
119103
init_per_group(stream_queue, Config) ->
120104
rabbit_ct_helpers:set_config(
121105
Config,
@@ -126,10 +110,11 @@ init_per_group(Group, Config0) ->
126110
case lists:member({group, Group}, all()) of
127111
true ->
128112
ClusterSize = 3,
113+
Tick = 256,
129114
Config = rabbit_ct_helpers:merge_app_env(
130-
Config0, {rabbit, [{channel_tick_interval, 1000},
131-
{quorum_tick_interval, 1000},
132-
{stream_tick_interval, 1000}]}),
115+
Config0, {rabbit, [{channel_tick_interval, Tick},
116+
{quorum_tick_interval, Tick},
117+
{stream_tick_interval, Tick}]}),
133118
Config1 = rabbit_ct_helpers:set_config(
134119
Config, [ {rmq_nodename_suffix, Group},
135120
{rmq_nodes_count, ClusterSize}

0 commit comments

Comments
 (0)