Skip to content

Make cleanups and ct-master introduction #11778

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ ADDITIONAL_PLUGINS ?=
DEPS = rabbit_common rabbit $(PLUGINS) $(ADDITIONAL_PLUGINS)

DEP_PLUGINS = rabbit_common/mk/rabbitmq-dist.mk \
rabbit_common/mk/rabbitmq-run.mk \
rabbit_common/mk/rabbitmq-tools.mk
rabbit_common/mk/rabbitmq-run.mk

DISABLE_DISTCLEAN = 1

Expand Down Expand Up @@ -61,6 +60,20 @@ include rabbitmq-components.mk
# multiple times (including for release file names and whatnot).
PROJECT_VERSION := $(PROJECT_VERSION)

# Fetch/build community plugins.
#
# To include community plugins in commands, use
# `make COMMUNITY_PLUGINS=1` or export the variable.
# They are not included otherwise. Note that only
# the top-level Makefile can do this.
#
# Note that the community plugins will be fetched using
# SSH and therefore may be subject to GH authentication.

ifdef COMMUNITY_PLUGINS
DEPS += $(RABBITMQ_COMMUNITY)
endif

include erlang.mk
include mk/github-actions.mk
include mk/bazel.mk
Expand Down
9 changes: 3 additions & 6 deletions deps/amqp10_client/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,10 @@ DEPS = amqp10_common credentials_obfuscation
TEST_DEPS = rabbit rabbitmq_ct_helpers
LOCAL_DEPS = ssl inets crypto public_key

DEP_EARLY_PLUGINS = rabbit_common/mk/rabbitmq-early-test.mk
DEP_EARLY_PLUGINS = rabbit_common/mk/rabbitmq-early-plugin.mk
# We do not depend on rabbit therefore can't run the broker.
DEP_PLUGINS = rabbit_common/mk/rabbitmq-build.mk \
rabbit_common/mk/rabbitmq-hexpm.mk \
rabbit_common/mk/rabbitmq-dist.mk \
rabbit_common/mk/rabbitmq-run.mk \
rabbit_common/mk/rabbitmq-test.mk \
rabbit_common/mk/rabbitmq-tools.mk
rabbit_common/mk/rabbitmq-hexpm.mk

DEP_PLUGINS += elvis_mk
dep_elvis_mk = git https://github.com/inaka/elvis.mk.git master
Expand Down
8 changes: 3 additions & 5 deletions deps/amqp10_common/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,10 @@ TEST_DEPS = rabbitmq_ct_helpers proper

-include development.pre.mk

DEP_EARLY_PLUGINS = rabbit_common/mk/rabbitmq-early-test.mk
DEP_EARLY_PLUGINS = rabbit_common/mk/rabbitmq-early-plugin.mk
# We do not depend on rabbit therefore can't run the broker.
DEP_PLUGINS = rabbit_common/mk/rabbitmq-build.mk \
rabbit_common/mk/rabbitmq-hexpm.mk \
rabbit_common/mk/rabbitmq-dist.mk \
rabbit_common/mk/rabbitmq-test.mk \
rabbit_common/mk/rabbitmq-tools.mk
rabbit_common/mk/rabbitmq-hexpm.mk

PLT_APPS = eunit

Expand Down
12 changes: 5 additions & 7 deletions deps/amqp_client/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,11 @@ LOCAL_DEPS = xmerl ssl public_key
DEPS = rabbit_common credentials_obfuscation
TEST_DEPS = rabbitmq_ct_helpers rabbit meck

DEP_EARLY_PLUGINS = rabbit_common/mk/rabbitmq-early-test.mk
DEP_PLUGINS = rabbit_common/mk/rabbitmq-build.mk \
rabbit_common/mk/rabbitmq-hexpm.mk \
rabbit_common/mk/rabbitmq-dist.mk \
rabbit_common/mk/rabbitmq-run.mk \
rabbit_common/mk/rabbitmq-test.mk \
rabbit_common/mk/rabbitmq-tools.mk
DEP_EARLY_PLUGINS = rabbit_common/mk/rabbitmq-early-plugin.mk
# We do not depend on rabbit therefore can't run the broker;
# however we can run a test broker in the test suites.
DEP_PLUGINS = rabbit_common/mk/rabbitmq-plugin.mk \
rabbit_common/mk/rabbitmq-hexpm.mk

PLT_APPS = ssl public_key

Expand Down
30 changes: 9 additions & 21 deletions deps/amqp_client/test/system_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -335,14 +335,16 @@ safe_call_timeouts_test(Params = #amqp_params_network{}) ->
meck:unload(amqp_network_connection);

safe_call_timeouts_test(Params = #amqp_params_direct{}) ->
%% We must mock net_kernel:get_net_ticktime/0 as changing
%% the tick time directly could lead to nodes disconnecting.
meck:new(net_kernel, [unstick, passthrough]),

TestCallTimeout = 30000,
NetTicktime0 = net_kernel:get_net_ticktime(),
amqp_util:update_call_timeout(TestCallTimeout),

%% 1. NetTicktime >= DIRECT_OPERATION_TIMEOUT (120s)
NetTicktime1 = 140,
net_kernel:set_net_ticktime(NetTicktime1, 1),
wait_until_net_ticktime(NetTicktime1),
meck:expect(net_kernel, get_net_ticktime, fun() -> NetTicktime1 end),

{ok, Connection1} = amqp_connection:start(Params),
?assertEqual((NetTicktime1 * 1000) + ?CALL_TIMEOUT_DEVIATION,
Expand All @@ -356,15 +358,12 @@ safe_call_timeouts_test(Params = #amqp_params_direct{}) ->

%% 2. Transitioning NetTicktime >= DIRECT_OPERATION_TIMEOUT (120s)
NetTicktime2 = 120,
net_kernel:set_net_ticktime(NetTicktime2, 1),
?assertEqual({ongoing_change_to, NetTicktime2}, net_kernel:get_net_ticktime()),
meck:expect(net_kernel, get_net_ticktime, fun() -> {ongoing_change_to, NetTicktime2} end),

{ok, Connection2} = amqp_connection:start(Params),
?assertEqual((NetTicktime2 * 1000) + ?CALL_TIMEOUT_DEVIATION,
amqp_util:call_timeout()),

wait_until_net_ticktime(NetTicktime2),

?assertEqual(ok, amqp_connection:close(Connection2)),
wait_for_death(Connection2),

Expand All @@ -373,15 +372,14 @@ safe_call_timeouts_test(Params = #amqp_params_direct{}) ->

%% 3. NetTicktime < DIRECT_OPERATION_TIMEOUT (120s)
NetTicktime3 = 60,
net_kernel:set_net_ticktime(NetTicktime3, 1),
wait_until_net_ticktime(NetTicktime3),
meck:expect(net_kernel, get_net_ticktime, fun() -> NetTicktime3 end),

{ok, Connection3} = amqp_connection:start(Params),
?assertEqual((?DIRECT_OPERATION_TIMEOUT + ?CALL_TIMEOUT_DEVIATION),
amqp_util:call_timeout()),

net_kernel:set_net_ticktime(NetTicktime0, 1),
wait_until_net_ticktime(NetTicktime0),
meck:unload(net_kernel),

?assertEqual(ok, amqp_connection:close(Connection3)),
wait_for_death(Connection3),

Expand Down Expand Up @@ -1578,16 +1576,6 @@ assert_down_with_error(MonitorRef, CodeAtom) ->
exit(did_not_die)
end.

wait_until_net_ticktime(NetTicktime) ->
case net_kernel:get_net_ticktime() of
NetTicktime -> ok;
{ongoing_change_to, NetTicktime} ->
timer:sleep(1000),
wait_until_net_ticktime(NetTicktime);
_ ->
throw({error, {net_ticktime_not_set, NetTicktime}})
end.

set_resource_alarm(Resource, Config)
when Resource =:= memory orelse Resource =:= disk ->
SrcDir = ?config(amqp_client_srcdir, Config),
Expand Down
9 changes: 2 additions & 7 deletions deps/oauth2_client/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,8 @@ LOCAL_DEPS = ssl inets crypto public_key

PLT_APPS = rabbit

DEP_EARLY_PLUGINS = rabbit_common/mk/rabbitmq-early-test.mk
DEP_PLUGINS = rabbit_common/mk/rabbitmq-build.mk \
rabbit_common/mk/rabbitmq-hexpm.mk \
rabbit_common/mk/rabbitmq-dist.mk \
rabbit_common/mk/rabbitmq-run.mk \
rabbit_common/mk/rabbitmq-test.mk \
rabbit_common/mk/rabbitmq-tools.mk
DEP_EARLY_PLUGINS = rabbit_common/mk/rabbitmq-early-plugin.mk
DEP_PLUGINS = rabbit_common/mk/rabbitmq-plugin.mk

include rabbitmq-components.mk
include erlang.mk
2 changes: 0 additions & 2 deletions deps/rabbit/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,5 @@
/etc/
/test/config_schema_SUITE_data/schema/**

rabbit-rabbitmq-deps.mk

[Bb]in/
[Oo]bj/
47 changes: 39 additions & 8 deletions deps/rabbit/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,8 @@ MANPAGES = $(wildcard $(DOCS_DIR)/*.[0-9])
WEB_MANPAGES = $(patsubst %,%.html,$(MANPAGES))
MD_MANPAGES = $(patsubst %,%.md,$(MANPAGES))

DEP_EARLY_PLUGINS = rabbit_common/mk/rabbitmq-early-test.mk
DEP_PLUGINS = rabbit_common/mk/rabbitmq-build.mk \
rabbit_common/mk/rabbitmq-dist.mk \
rabbit_common/mk/rabbitmq-run.mk \
rabbit_common/mk/rabbitmq-test.mk \
rabbit_common/mk/rabbitmq-tools.mk
DEP_EARLY_PLUGINS = rabbit_common/mk/rabbitmq-early-plugin.mk
DEP_PLUGINS = rabbit_common/mk/rabbitmq-plugin.mk

include ../../rabbitmq-components.mk
include ../../erlang.mk
Expand Down Expand Up @@ -222,8 +218,43 @@ SLOW_CT_SUITES := backing_queue \
vhost
FAST_CT_SUITES := $(filter-out $(sort $(SLOW_CT_SUITES)),$(CT_SUITES))

ct-fast: CT_SUITES = $(FAST_CT_SUITES)
ct-slow: CT_SUITES = $(SLOW_CT_SUITES)
ct-fast:
$(MAKE) ct CT_SUITES='$(FAST_CT_SUITES)'

ct-slow:
$(MAKE) ct CT_SUITES='$(SLOW_CT_SUITES)'

CT_OPTS += -ct_hooks rabbit_ct_hook []

define ct_master.erl
StartOpts = #{
host => "localhost",
connection => standard_io,
args => ["-hidden"]
},
{ok, Pid1, _} = peer:start(StartOpts#{name => "rabbit_shard1"}),
{ok, Pid2, _} = peer:start(StartOpts#{name => "rabbit_shard2"}),
{ok, Pid3, _} = peer:start(StartOpts#{name => "rabbit_shard3"}),
{ok, Pid4, _} = peer:start(StartOpts#{name => "rabbit_shard4"}),
peer:call(Pid1, net_kernel, set_net_ticktime, [5]),
peer:call(Pid2, net_kernel, set_net_ticktime, [5]),
peer:call(Pid3, net_kernel, set_net_ticktime, [5]),
peer:call(Pid4, net_kernel, set_net_ticktime, [5]),
peer:call(Pid1, persistent_term, put, [rabbit_ct_tcp_port_base, 23000]),
peer:call(Pid2, persistent_term, put, [rabbit_ct_tcp_port_base, 25000]),
peer:call(Pid3, persistent_term, put, [rabbit_ct_tcp_port_base, 27000]),
peer:call(Pid4, persistent_term, put, [rabbit_ct_tcp_port_base, 29000]),
ct_master:run("ct.test.spec"),
peer:stop(Pid4),
peer:stop(Pid3),
peer:stop(Pid2),
peer:stop(Pid1),
halt()
endef

ct-master: test-build
$(verbose) mkdir -p $(CT_LOGS_DIR)
$(call erlang,$(ct_master.erl),-sname rabbit_master@localhost -hidden -kernel net_ticktime 5)

# --------------------------------------------------------------------
# Compilation.
Expand Down
Loading
Loading