Skip to content

Commit 0c21d68

Browse files
authored
Merge pull request #15222 from rabbitmq/loic-peer-rabbit
Switch integration tests to use the `peer` module
2 parents e68b784 + a282a4b commit 0c21d68

20 files changed

Lines changed: 261 additions & 534 deletions

.github/workflows/test-make-target.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,10 @@ jobs:
112112
ldap-utils \
113113
slapd
114114
115-
sudo systemctl is-active --quiet apparmor.service && sudo systemctl stop apparmor.service
116-
sudo systemctl disable apparmor.service
115+
sudo systemctl stop slapd
116+
117+
sudo aa-teardown || true
118+
sudo systemctl disable --now apparmor.service
117119
118120
- name: RUN LOW VERSION ERLANG NODE IN DOCKER
119121
if: inputs.make_target == 'ct-rabbit_fifo_prop'

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ rabbitmq-server-*.tar.gz
116116
rabbitmq-server-*.tar.bz2
117117
rabbitmq-server-*.tar.xz
118118
rabbitmq-server-*.zip
119+
secondary_dist/
119120

120121
# Trace tools output.
121122
*-ttb

deps/amqp_client/test/system_SUITE.erl

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,8 @@ end_per_suite(Config) ->
129129
] ++ rabbit_ct_broker_helpers:teardown_steps()).
130130

131131
ensure_amqp_client_srcdir(Config) ->
132-
case rabbit_ct_helpers:get_config(Config, rabbitmq_run_cmd) of
133-
undefined ->
134-
rabbit_ct_helpers:ensure_application_srcdir(Config,
135-
amqp_client, amqp_client);
136-
_ -> Config
137-
end.
132+
rabbit_ct_helpers:ensure_application_srcdir(Config,
133+
amqp_client, amqp_client).
138134

139135
create_unauthorized_user(Config) ->
140136
Cmd = ["add_user", ?UNAUTHORIZED_USER, ?UNAUTHORIZED_USER],
@@ -1621,10 +1617,7 @@ set_resource_alarm(Resource, Config)
16211617
Cmd = [{"RABBITMQ_NODENAME=~ts", [Nodename]},
16221618
"set-resource-alarm",
16231619
{"SOURCE=~ts", [Resource]}],
1624-
{ok, _} = case os:getenv("RABBITMQ_RUN") of
1625-
false -> rabbit_ct_helpers:make(Config, SrcDir, Cmd);
1626-
Run -> rabbit_ct_helpers:exec([Run | Cmd])
1627-
end.
1620+
rabbit_ct_helpers:make(Config, SrcDir, Cmd).
16281621

16291622
clear_resource_alarm(Resource, Config)
16301623
when Resource =:= memory orelse Resource =:= disk ->
@@ -1633,9 +1626,6 @@ clear_resource_alarm(Resource, Config)
16331626
Cmd = [{"RABBITMQ_NODENAME=~ts", [Nodename]},
16341627
"clear-resource-alarm",
16351628
{"SOURCE=~ts", [Resource]}],
1636-
{ok, _} = case os:getenv("RABBITMQ_RUN") of
1637-
false -> rabbit_ct_helpers:make(Config, SrcDir, Cmd);
1638-
Run -> rabbit_ct_helpers:exec([Run | Cmd])
1639-
end.
1629+
rabbit_ct_helpers:make(Config, SrcDir, Cmd).
16401630

16411631
fmt(Fmt, Args) -> list_to_binary(rabbit_misc:format(Fmt, Args)).

deps/rabbit/test/amqp_client_SUITE.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4767,7 +4767,7 @@ message_ttl(Config) ->
47674767
plugin(Config) ->
47684768
Node = 0,
47694769
Plugin = rabbitmq_amqp1_0,
4770-
%% rabbit/Makefile and rabbit/BUILD.bazel declare a test dependency on the rabbitmq_amqp1_0 plugin.
4770+
%% rabbit/Makefile declares a test dependency on the rabbitmq_amqp1_0 plugin.
47714771
%% Therefore, we first disable, and then enable.
47724772
?assertEqual(ok, rabbit_ct_broker_helpers:disable_plugin(Config, Node, Plugin)),
47734773
?assertEqual(ok, rabbit_ct_broker_helpers:enable_plugin(Config, Node, Plugin)).

deps/rabbit/test/feature_flags_SUITE.erl

Lines changed: 4 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -130,67 +130,16 @@ end_per_suite(Config) ->
130130
init_per_group(registry, Config) ->
131131
logger:set_primary_config(level, debug),
132132
rabbit_ct_helpers:run_steps(Config, []);
133-
init_per_group(feature_flags_v2, Config) ->
134-
%% @todo Remove this entirely as that FF became required in 3.12.
135-
%% `feature_flags_v2' is now required and won't work in mixed-version
136-
%% clusters if the other version doesn't support it.
137-
case rabbit_ct_helpers:is_mixed_versions() of
138-
false ->
139-
rabbit_ct_helpers:set_config(
140-
Config, {enable_feature_flags_v2, true});
141-
true ->
142-
%% Before we run `feature_flags_v2'-related tests, we must ensure
143-
%% that both umbrellas support them. Otherwise there is no point
144-
%% in running them.
145-
%% To determine that `feature_flags_v2' are supported, we can't
146-
%% query RabbitMQ which is not started. Therefore, we check if the
147-
%% source or bytecode of `rabbit_ff_controller' is present.
148-
Dir1 = ?config(rabbit_srcdir, Config),
149-
File1 = filename:join([Dir1, "ebin", "rabbit_ff_controller.beam"]),
150-
SupportedPrimary = filelib:is_file(File1),
151-
SupportedSecondary =
152-
case rabbit_ct_helpers:get_config(Config, rabbitmq_run_cmd) of
153-
undefined ->
154-
%% make
155-
Dir2 = ?config(secondary_rabbit_srcdir, Config),
156-
File2 = filename:join(
157-
[Dir2, "src", "rabbit_ff_controller.erl"]),
158-
filelib:is_file(File2);
159-
RmqRunSecondary ->
160-
%% bazel
161-
Dir2 = filename:dirname(RmqRunSecondary),
162-
Beam = filename:join(
163-
[Dir2, "plugins", "rabbit-*",
164-
"ebin", "rabbit_ff_controller.beam"]),
165-
case filelib:wildcard(Beam) of
166-
[_] -> true;
167-
[] -> false
168-
end
169-
end,
170-
case {SupportedPrimary, SupportedSecondary} of
171-
{true, true} ->
172-
rabbit_ct_helpers:set_config(
173-
Config, {enable_feature_flags_v2, true});
174-
{false, true} ->
175-
{skip,
176-
"Primary umbrella does not support "
177-
"feature_flags_v2"};
178-
{true, false} ->
179-
{skip,
180-
"Secondary umbrella does not support "
181-
"feature_flags_v2"}
182-
end
183-
end;
184133
init_per_group(enabling_on_single_node, Config) ->
185134
Config1 = rabbit_ct_helpers:set_config(
186135
Config,
187136
[{rmq_nodes_count, 1}]),
188-
rabbit_ct_helpers:run_setup_steps(Config1, [fun prepare_my_plugin/1]);
137+
rabbit_ct_helpers:run_setup_steps(Config1, [fun build_my_plugin/1]);
189138
init_per_group(enabling_in_cluster, Config) ->
190139
Config1 = rabbit_ct_helpers:set_config(
191140
Config,
192141
[{rmq_nodes_count, 5}]),
193-
rabbit_ct_helpers:run_setup_steps(Config1, [fun prepare_my_plugin/1]);
142+
rabbit_ct_helpers:run_setup_steps(Config1, [fun build_my_plugin/1]);
194143
init_per_group(clustering, Config) ->
195144
Config1 = rabbit_ct_helpers:set_config(
196145
Config,
@@ -207,14 +156,14 @@ init_per_group(clustering, Config) ->
207156
message_containers,
208157
quorum_queue_non_voters
209158
]}]}),
210-
rabbit_ct_helpers:run_setup_steps(Config2, [fun prepare_my_plugin/1]);
159+
rabbit_ct_helpers:run_setup_steps(Config2, [fun build_my_plugin/1]);
211160
init_per_group(activating_plugin, Config) ->
212161
Config1 = rabbit_ct_helpers:set_config(
213162
Config,
214163
[{rmq_nodes_count, 2},
215164
{rmq_nodes_clustered, true},
216165
{start_rmq_with_plugins_disabled, true}]),
217-
rabbit_ct_helpers:run_setup_steps(Config1, [fun prepare_my_plugin/1]);
166+
rabbit_ct_helpers:run_setup_steps(Config1, [fun build_my_plugin/1]);
218167
init_per_group(_, Config) ->
219168
Config.
220169

@@ -1367,19 +1316,6 @@ restart_node_with_unknown_enabled_feature_flag(Config) ->
13671316
%% Internal helpers.
13681317
%% -------------------------------------------------------------------
13691318

1370-
prepare_my_plugin(Config) ->
1371-
case os:getenv("RABBITMQ_RUN") of
1372-
false ->
1373-
build_my_plugin(Config);
1374-
_ ->
1375-
MyPluginDir = filename:dirname(
1376-
filename:dirname(
1377-
code:where_is_file("my_plugin.app"))),
1378-
PluginsDir = filename:dirname(MyPluginDir),
1379-
rabbit_ct_helpers:set_config(
1380-
Config, [{rmq_plugins_dir, PluginsDir}])
1381-
end.
1382-
13831319
build_my_plugin(Config) ->
13841320
DataDir = filename:join(
13851321
filename:dirname(filename:dirname(?config(data_dir, Config))),

deps/rabbit/test/feature_flags_v2_SUITE.erl

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,7 @@ all() ->
6565
].
6666

6767
groups() ->
68-
%% Don't run testcases in parallel when Bazel is used because they fail
69-
%% with various system errors in CI, like the inability to spawn system
70-
%% processes or to open a TCP port.
71-
UsesBazel = case os:getenv("RABBITMQ_RUN") of
72-
false -> false;
73-
_ -> true
74-
end,
75-
GroupOptions = case UsesBazel of
76-
false -> [parallel];
77-
true -> []
78-
end,
68+
GroupOptions = [parallel],
7969
Groups =
8070
[
8171
{direct, GroupOptions,
@@ -123,8 +113,6 @@ init_per_suite(Config) ->
123113
end_per_suite(Config) ->
124114
Config.
125115

126-
init_per_group(feature_flags_v2, Config) ->
127-
rabbit_ct_helpers:set_config(Config, {enable_feature_flags_v2, true});
128116
init_per_group(direct, Config) ->
129117
Config;
130118
init_per_group(cluster_size_1, Config) ->

deps/rabbit/test/queue_parallel_SUITE.erl

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,7 @@ all() ->
2121
].
2222

2323
groups() ->
24-
%% Don't run testcases in parallel when Bazel is used because they fail
25-
%% with various system errors in CI, like the inability to spawn system
26-
%% processes or to open a TCP port.
27-
UsesBazel = case os:getenv("RABBITMQ_RUN") of
28-
false -> false;
29-
_ -> true
30-
end,
31-
GroupOptions = case UsesBazel of
32-
false -> [parallel];
33-
true -> []
34-
end,
24+
GroupOptions = [parallel],
3525
AllTests = [publish,
3626
consume,
3727
consume_first_empty,

deps/rabbit/test/quorum_queue_SUITE.erl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1813,7 +1813,7 @@ dont_leak_file_handles(Config) ->
18131813
ok.
18141814

18151815
grow_queue(Config) ->
1816-
[Server0, Server1, Server2, _Server3, _Server4] =
1816+
[Server0, Server1, _Server2, _Server3, _Server4] =
18171817
rabbit_ct_broker_helpers:get_node_configs(Config, nodename),
18181818

18191819
Ch = rabbit_ct_client_helpers:open_channel(Config, Server0),
@@ -5394,7 +5394,7 @@ delete_queues() ->
53945394
|| Q <- rabbit_amqqueue:list()].
53955395

53965396
stop_node(Config, Server) ->
5397-
rabbit_ct_broker_helpers:rabbitmqctl(Config, Server, ["stop"]).
5397+
rabbit_ct_broker_helpers:stop_node(Config, Server).
53985398

53995399
get_message_bytes(Leader, QRes) ->
54005400
case rpc:call(Leader, ets, lookup, [queue_metrics, QRes]) of

deps/rabbit/test/rabbit_access_control_SUITE.erl

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ init_per_testcase(Testcase, Config)
7979
Testcase =:= with_disabled_plugin orelse
8080
Testcase =:= with_disabled_plugin_plus_internal ->
8181
rabbit_ct_helpers:testcase_started(Config, Testcase),
82-
do_init_per_testcase(Testcase, Config, [fun prepare_my_plugin/1]);
82+
do_init_per_testcase(Testcase, Config, [fun build_my_plugin/1]);
8383
init_per_testcase(_TestCase, Config) ->
8484
Config.
8585

@@ -327,19 +327,6 @@ with_disabled_plugin_plus_internal(Config) ->
327327
%% Internal helpers.
328328
%% -------------------------------------------------------------------
329329

330-
prepare_my_plugin(Config) ->
331-
case os:getenv("RABBITMQ_RUN") of
332-
false ->
333-
build_my_plugin(Config);
334-
_ ->
335-
MyPluginDir = filename:dirname(
336-
filename:dirname(
337-
code:where_is_file("my_auth_plugin.app"))),
338-
PluginsDir = filename:dirname(MyPluginDir),
339-
rabbit_ct_helpers:set_config(
340-
Config, [{rmq_plugins_dir, PluginsDir}])
341-
end.
342-
343330
build_my_plugin(Config) ->
344331
DataDir = filename:join(
345332
filename:dirname(filename:dirname(?config(data_dir, Config))),

deps/rabbit_common/mk/rabbitmq-early-plugin.mk

Lines changed: 27 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -25,41 +25,38 @@ CT_OPTS += -hidden
2525

2626
CT_OPTS += -kernel net_ticktime 5
2727

28-
# Enable the following common_test hooks on GH and Concourse:
29-
#
30-
# cth_fail_fast
31-
# This hook will make sure the first failure puts an end to the
32-
# testsuites; ie. all remaining tests are skipped.
33-
#
34-
# cth_styledout
35-
# This hook will change the output of common_test to something more
36-
# concise and colored. Not used on GitHub Actions except in parallel CT.
37-
38-
ifndef GITHUB_ACTIONS
28+
ifdef GITHUB_ACTIONS
29+
# On CI, set $RABBITMQ_CT_SKIP_AS_ERROR so that any skipped
30+
# testsuite/testgroup/testcase is considered an error.
31+
export RABBITMQ_CT_SKIP_AS_ERROR = true
32+
else
33+
# This hook will change the output of common_test to something more
34+
# concise and colored. Not used on GitHub Actions except in parallel
35+
# CT where it is hardcoded.
3936
CT_HOOKS += cth_styledout
4037
endif
38+
4139
TEST_DEPS += cth_styledout
40+
dep_cth_styledout = git https://github.com/rabbitmq/cth_styledout.git master
4241

43-
ifdef CONCOURSE
44-
FAIL_FAST = 1
45-
SKIP_AS_ERROR = 1
42+
ifneq ($(strip $(CT_HOOKS)),)
43+
CT_OPTS += -ct_hooks $(CT_HOOKS)
4644
endif
4745

48-
RMQ_CI_CT_HOOKS = cth_fail_fast
49-
ifeq ($(FAIL_FAST),1)
50-
CT_HOOKS += $(RMQ_CI_CT_HOOKS)
51-
TEST_DEPS += $(RMQ_CI_CT_HOOKS)
46+
# We fetch a SECONDARY_DIST if SECONDARY_DIST_VSN is set and
47+
# we setup the SECONDARY_DIST variable. The location of the
48+
# secondary dists can be customized using SECONDARY_DIST_DIR
49+
# but note that it only works with an absolute path.
50+
ifneq ($(strip $(SECONDARY_DIST_VSN)),)
51+
SECONDARY_DIST_DIR ?= $(abspath $(CURDIR)/../../)/secondary_dist
52+
SECONDARY_DIST=$(SECONDARY_DIST_DIR)/rabbitmq_server-$(SECONDARY_DIST_VSN)
53+
export SECONDARY_DIST
54+
55+
SECONDARY_DIST_DOWNLOAD_URL = https://github.com/rabbitmq/rabbitmq-server/releases/download/v$(SECONDARY_DIST_VSN)/rabbitmq-server-generic-unix-$(SECONDARY_DIST_VSN).tar.xz
56+
57+
ifeq ($(wildcard $(SECONDARY_DIST)),)
58+
$(shell curl -L -o $(ERLANG_MK_TMP)/rabbitmq_server-$(SECONDARY_DIST_VSN).tar.xz $(SECONDARY_DIST_DOWNLOAD_URL) \
59+
&& mkdir -p $(SECONDARY_DIST) \
60+
&& tar -xf $(ERLANG_MK_TMP)/rabbitmq_server-$(SECONDARY_DIST_VSN).tar.xz -C $(dir $(SECONDARY_DIST)))
5261
endif
53-
54-
dep_cth_fail_fast = git https://github.com/rabbitmq/cth_fail_fast.git master
55-
dep_cth_styledout = git https://github.com/rabbitmq/cth_styledout.git master
56-
57-
CT_HOOKS_PARAM_VALUE = $(patsubst %,and %,$(CT_HOOKS))
58-
CT_OPTS += -ct_hooks $(wordlist 2,$(words $(CT_HOOKS_PARAM_VALUE)),$(CT_HOOKS_PARAM_VALUE))
59-
60-
# On CI, set $RABBITMQ_CT_SKIP_AS_ERROR so that any skipped
61-
# testsuite/testgroup/testcase is considered an error.
62-
63-
ifeq ($(SKIP_AS_ERROR),1)
64-
export RABBITMQ_CT_SKIP_AS_ERROR = true
6562
endif

0 commit comments

Comments
 (0)