diff --git a/.github/workflows/test-make-target.yaml b/.github/workflows/test-make-target.yaml index 8d3be67e43b4..ddc9f9868a97 100644 --- a/.github/workflows/test-make-target.yaml +++ b/.github/workflows/test-make-target.yaml @@ -112,8 +112,10 @@ jobs: ldap-utils \ slapd - sudo systemctl is-active --quiet apparmor.service && sudo systemctl stop apparmor.service - sudo systemctl disable apparmor.service + sudo systemctl stop slapd + + sudo aa-teardown || true + sudo systemctl disable --now apparmor.service - name: RUN LOW VERSION ERLANG NODE IN DOCKER if: inputs.make_target == 'ct-rabbit_fifo_prop' diff --git a/.gitignore b/.gitignore index 272050aff697..2dcd36a723ce 100644 --- a/.gitignore +++ b/.gitignore @@ -116,6 +116,7 @@ rabbitmq-server-*.tar.gz rabbitmq-server-*.tar.bz2 rabbitmq-server-*.tar.xz rabbitmq-server-*.zip +secondary_dist/ # Trace tools output. *-ttb diff --git a/deps/amqp_client/test/system_SUITE.erl b/deps/amqp_client/test/system_SUITE.erl index a8e1b5896342..78a665d634b3 100644 --- a/deps/amqp_client/test/system_SUITE.erl +++ b/deps/amqp_client/test/system_SUITE.erl @@ -129,12 +129,8 @@ end_per_suite(Config) -> ] ++ rabbit_ct_broker_helpers:teardown_steps()). ensure_amqp_client_srcdir(Config) -> - case rabbit_ct_helpers:get_config(Config, rabbitmq_run_cmd) of - undefined -> - rabbit_ct_helpers:ensure_application_srcdir(Config, - amqp_client, amqp_client); - _ -> Config - end. + rabbit_ct_helpers:ensure_application_srcdir(Config, + amqp_client, amqp_client). create_unauthorized_user(Config) -> Cmd = ["add_user", ?UNAUTHORIZED_USER, ?UNAUTHORIZED_USER], @@ -1621,10 +1617,7 @@ set_resource_alarm(Resource, Config) Cmd = [{"RABBITMQ_NODENAME=~ts", [Nodename]}, "set-resource-alarm", {"SOURCE=~ts", [Resource]}], - {ok, _} = case os:getenv("RABBITMQ_RUN") of - false -> rabbit_ct_helpers:make(Config, SrcDir, Cmd); - Run -> rabbit_ct_helpers:exec([Run | Cmd]) - end. + rabbit_ct_helpers:make(Config, SrcDir, Cmd). clear_resource_alarm(Resource, Config) when Resource =:= memory orelse Resource =:= disk -> @@ -1633,9 +1626,6 @@ clear_resource_alarm(Resource, Config) Cmd = [{"RABBITMQ_NODENAME=~ts", [Nodename]}, "clear-resource-alarm", {"SOURCE=~ts", [Resource]}], - {ok, _} = case os:getenv("RABBITMQ_RUN") of - false -> rabbit_ct_helpers:make(Config, SrcDir, Cmd); - Run -> rabbit_ct_helpers:exec([Run | Cmd]) - end. + rabbit_ct_helpers:make(Config, SrcDir, Cmd). fmt(Fmt, Args) -> list_to_binary(rabbit_misc:format(Fmt, Args)). diff --git a/deps/rabbit/test/amqp_client_SUITE.erl b/deps/rabbit/test/amqp_client_SUITE.erl index 30e0f1b061a5..21a8d5ea97b7 100644 --- a/deps/rabbit/test/amqp_client_SUITE.erl +++ b/deps/rabbit/test/amqp_client_SUITE.erl @@ -4767,7 +4767,7 @@ message_ttl(Config) -> plugin(Config) -> Node = 0, Plugin = rabbitmq_amqp1_0, - %% rabbit/Makefile and rabbit/BUILD.bazel declare a test dependency on the rabbitmq_amqp1_0 plugin. + %% rabbit/Makefile declares a test dependency on the rabbitmq_amqp1_0 plugin. %% Therefore, we first disable, and then enable. ?assertEqual(ok, rabbit_ct_broker_helpers:disable_plugin(Config, Node, Plugin)), ?assertEqual(ok, rabbit_ct_broker_helpers:enable_plugin(Config, Node, Plugin)). diff --git a/deps/rabbit/test/feature_flags_SUITE.erl b/deps/rabbit/test/feature_flags_SUITE.erl index 0931a8b04ff1..7aad2104940c 100644 --- a/deps/rabbit/test/feature_flags_SUITE.erl +++ b/deps/rabbit/test/feature_flags_SUITE.erl @@ -130,67 +130,16 @@ end_per_suite(Config) -> init_per_group(registry, Config) -> logger:set_primary_config(level, debug), rabbit_ct_helpers:run_steps(Config, []); -init_per_group(feature_flags_v2, Config) -> - %% @todo Remove this entirely as that FF became required in 3.12. - %% `feature_flags_v2' is now required and won't work in mixed-version - %% clusters if the other version doesn't support it. - case rabbit_ct_helpers:is_mixed_versions() of - false -> - rabbit_ct_helpers:set_config( - Config, {enable_feature_flags_v2, true}); - true -> - %% Before we run `feature_flags_v2'-related tests, we must ensure - %% that both umbrellas support them. Otherwise there is no point - %% in running them. - %% To determine that `feature_flags_v2' are supported, we can't - %% query RabbitMQ which is not started. Therefore, we check if the - %% source or bytecode of `rabbit_ff_controller' is present. - Dir1 = ?config(rabbit_srcdir, Config), - File1 = filename:join([Dir1, "ebin", "rabbit_ff_controller.beam"]), - SupportedPrimary = filelib:is_file(File1), - SupportedSecondary = - case rabbit_ct_helpers:get_config(Config, rabbitmq_run_cmd) of - undefined -> - %% make - Dir2 = ?config(secondary_rabbit_srcdir, Config), - File2 = filename:join( - [Dir2, "src", "rabbit_ff_controller.erl"]), - filelib:is_file(File2); - RmqRunSecondary -> - %% bazel - Dir2 = filename:dirname(RmqRunSecondary), - Beam = filename:join( - [Dir2, "plugins", "rabbit-*", - "ebin", "rabbit_ff_controller.beam"]), - case filelib:wildcard(Beam) of - [_] -> true; - [] -> false - end - end, - case {SupportedPrimary, SupportedSecondary} of - {true, true} -> - rabbit_ct_helpers:set_config( - Config, {enable_feature_flags_v2, true}); - {false, true} -> - {skip, - "Primary umbrella does not support " - "feature_flags_v2"}; - {true, false} -> - {skip, - "Secondary umbrella does not support " - "feature_flags_v2"} - end - end; init_per_group(enabling_on_single_node, Config) -> Config1 = rabbit_ct_helpers:set_config( Config, [{rmq_nodes_count, 1}]), - rabbit_ct_helpers:run_setup_steps(Config1, [fun prepare_my_plugin/1]); + rabbit_ct_helpers:run_setup_steps(Config1, [fun build_my_plugin/1]); init_per_group(enabling_in_cluster, Config) -> Config1 = rabbit_ct_helpers:set_config( Config, [{rmq_nodes_count, 5}]), - rabbit_ct_helpers:run_setup_steps(Config1, [fun prepare_my_plugin/1]); + rabbit_ct_helpers:run_setup_steps(Config1, [fun build_my_plugin/1]); init_per_group(clustering, Config) -> Config1 = rabbit_ct_helpers:set_config( Config, @@ -207,14 +156,14 @@ init_per_group(clustering, Config) -> message_containers, quorum_queue_non_voters ]}]}), - rabbit_ct_helpers:run_setup_steps(Config2, [fun prepare_my_plugin/1]); + rabbit_ct_helpers:run_setup_steps(Config2, [fun build_my_plugin/1]); init_per_group(activating_plugin, Config) -> Config1 = rabbit_ct_helpers:set_config( Config, [{rmq_nodes_count, 2}, {rmq_nodes_clustered, true}, {start_rmq_with_plugins_disabled, true}]), - rabbit_ct_helpers:run_setup_steps(Config1, [fun prepare_my_plugin/1]); + rabbit_ct_helpers:run_setup_steps(Config1, [fun build_my_plugin/1]); init_per_group(_, Config) -> Config. @@ -1367,19 +1316,6 @@ restart_node_with_unknown_enabled_feature_flag(Config) -> %% Internal helpers. %% ------------------------------------------------------------------- -prepare_my_plugin(Config) -> - case os:getenv("RABBITMQ_RUN") of - false -> - build_my_plugin(Config); - _ -> - MyPluginDir = filename:dirname( - filename:dirname( - code:where_is_file("my_plugin.app"))), - PluginsDir = filename:dirname(MyPluginDir), - rabbit_ct_helpers:set_config( - Config, [{rmq_plugins_dir, PluginsDir}]) - end. - build_my_plugin(Config) -> DataDir = filename:join( filename:dirname(filename:dirname(?config(data_dir, Config))), diff --git a/deps/rabbit/test/feature_flags_v2_SUITE.erl b/deps/rabbit/test/feature_flags_v2_SUITE.erl index 85178e3a68a7..c47b60b4de92 100644 --- a/deps/rabbit/test/feature_flags_v2_SUITE.erl +++ b/deps/rabbit/test/feature_flags_v2_SUITE.erl @@ -65,17 +65,7 @@ all() -> ]. groups() -> - %% Don't run testcases in parallel when Bazel is used because they fail - %% with various system errors in CI, like the inability to spawn system - %% processes or to open a TCP port. - UsesBazel = case os:getenv("RABBITMQ_RUN") of - false -> false; - _ -> true - end, - GroupOptions = case UsesBazel of - false -> [parallel]; - true -> [] - end, + GroupOptions = [parallel], Groups = [ {direct, GroupOptions, @@ -123,8 +113,6 @@ init_per_suite(Config) -> end_per_suite(Config) -> Config. -init_per_group(feature_flags_v2, Config) -> - rabbit_ct_helpers:set_config(Config, {enable_feature_flags_v2, true}); init_per_group(direct, Config) -> Config; init_per_group(cluster_size_1, Config) -> diff --git a/deps/rabbit/test/queue_parallel_SUITE.erl b/deps/rabbit/test/queue_parallel_SUITE.erl index 7c8ac82a386d..d702ff541773 100644 --- a/deps/rabbit/test/queue_parallel_SUITE.erl +++ b/deps/rabbit/test/queue_parallel_SUITE.erl @@ -21,17 +21,7 @@ all() -> ]. groups() -> - %% Don't run testcases in parallel when Bazel is used because they fail - %% with various system errors in CI, like the inability to spawn system - %% processes or to open a TCP port. - UsesBazel = case os:getenv("RABBITMQ_RUN") of - false -> false; - _ -> true - end, - GroupOptions = case UsesBazel of - false -> [parallel]; - true -> [] - end, + GroupOptions = [parallel], AllTests = [publish, consume, consume_first_empty, diff --git a/deps/rabbit/test/quorum_queue_SUITE.erl b/deps/rabbit/test/quorum_queue_SUITE.erl index 88c72aa09087..6a478d5b7c58 100644 --- a/deps/rabbit/test/quorum_queue_SUITE.erl +++ b/deps/rabbit/test/quorum_queue_SUITE.erl @@ -1813,7 +1813,7 @@ dont_leak_file_handles(Config) -> ok. grow_queue(Config) -> - [Server0, Server1, Server2, _Server3, _Server4] = + [Server0, Server1, _Server2, _Server3, _Server4] = rabbit_ct_broker_helpers:get_node_configs(Config, nodename), Ch = rabbit_ct_client_helpers:open_channel(Config, Server0), @@ -5394,7 +5394,7 @@ delete_queues() -> || Q <- rabbit_amqqueue:list()]. stop_node(Config, Server) -> - rabbit_ct_broker_helpers:rabbitmqctl(Config, Server, ["stop"]). + rabbit_ct_broker_helpers:stop_node(Config, Server). get_message_bytes(Leader, QRes) -> case rpc:call(Leader, ets, lookup, [queue_metrics, QRes]) of diff --git a/deps/rabbit/test/rabbit_access_control_SUITE.erl b/deps/rabbit/test/rabbit_access_control_SUITE.erl index 2911769830f4..b3ad547d8c02 100644 --- a/deps/rabbit/test/rabbit_access_control_SUITE.erl +++ b/deps/rabbit/test/rabbit_access_control_SUITE.erl @@ -79,7 +79,7 @@ init_per_testcase(Testcase, Config) Testcase =:= with_disabled_plugin orelse Testcase =:= with_disabled_plugin_plus_internal -> rabbit_ct_helpers:testcase_started(Config, Testcase), - do_init_per_testcase(Testcase, Config, [fun prepare_my_plugin/1]); + do_init_per_testcase(Testcase, Config, [fun build_my_plugin/1]); init_per_testcase(_TestCase, Config) -> Config. @@ -327,19 +327,6 @@ with_disabled_plugin_plus_internal(Config) -> %% Internal helpers. %% ------------------------------------------------------------------- -prepare_my_plugin(Config) -> - case os:getenv("RABBITMQ_RUN") of - false -> - build_my_plugin(Config); - _ -> - MyPluginDir = filename:dirname( - filename:dirname( - code:where_is_file("my_auth_plugin.app"))), - PluginsDir = filename:dirname(MyPluginDir), - rabbit_ct_helpers:set_config( - Config, [{rmq_plugins_dir, PluginsDir}]) - end. - build_my_plugin(Config) -> DataDir = filename:join( filename:dirname(filename:dirname(?config(data_dir, Config))), diff --git a/deps/rabbit_common/mk/rabbitmq-early-plugin.mk b/deps/rabbit_common/mk/rabbitmq-early-plugin.mk index 94e153e2139e..9a84d971f7db 100644 --- a/deps/rabbit_common/mk/rabbitmq-early-plugin.mk +++ b/deps/rabbit_common/mk/rabbitmq-early-plugin.mk @@ -25,41 +25,38 @@ CT_OPTS += -hidden CT_OPTS += -kernel net_ticktime 5 -# Enable the following common_test hooks on GH and Concourse: -# -# cth_fail_fast -# This hook will make sure the first failure puts an end to the -# testsuites; ie. all remaining tests are skipped. -# -# cth_styledout -# This hook will change the output of common_test to something more -# concise and colored. Not used on GitHub Actions except in parallel CT. - -ifndef GITHUB_ACTIONS +ifdef GITHUB_ACTIONS +# On CI, set $RABBITMQ_CT_SKIP_AS_ERROR so that any skipped +# testsuite/testgroup/testcase is considered an error. +export RABBITMQ_CT_SKIP_AS_ERROR = true +else +# This hook will change the output of common_test to something more +# concise and colored. Not used on GitHub Actions except in parallel +# CT where it is hardcoded. CT_HOOKS += cth_styledout endif + TEST_DEPS += cth_styledout +dep_cth_styledout = git https://github.com/rabbitmq/cth_styledout.git master -ifdef CONCOURSE -FAIL_FAST = 1 -SKIP_AS_ERROR = 1 +ifneq ($(strip $(CT_HOOKS)),) +CT_OPTS += -ct_hooks $(CT_HOOKS) endif -RMQ_CI_CT_HOOKS = cth_fail_fast -ifeq ($(FAIL_FAST),1) -CT_HOOKS += $(RMQ_CI_CT_HOOKS) -TEST_DEPS += $(RMQ_CI_CT_HOOKS) +# We fetch a SECONDARY_DIST if SECONDARY_DIST_VSN is set and +# we setup the SECONDARY_DIST variable. The location of the +# secondary dists can be customized using SECONDARY_DIST_DIR +# but note that it only works with an absolute path. +ifneq ($(strip $(SECONDARY_DIST_VSN)),) +SECONDARY_DIST_DIR ?= $(abspath $(CURDIR)/../../)/secondary_dist +SECONDARY_DIST=$(SECONDARY_DIST_DIR)/rabbitmq_server-$(SECONDARY_DIST_VSN) +export SECONDARY_DIST + +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 + +ifeq ($(wildcard $(SECONDARY_DIST)),) +$(shell curl -L -o $(ERLANG_MK_TMP)/rabbitmq_server-$(SECONDARY_DIST_VSN).tar.xz $(SECONDARY_DIST_DOWNLOAD_URL) \ + && mkdir -p $(SECONDARY_DIST) \ + && tar -xf $(ERLANG_MK_TMP)/rabbitmq_server-$(SECONDARY_DIST_VSN).tar.xz -C $(dir $(SECONDARY_DIST))) endif - -dep_cth_fail_fast = git https://github.com/rabbitmq/cth_fail_fast.git master -dep_cth_styledout = git https://github.com/rabbitmq/cth_styledout.git master - -CT_HOOKS_PARAM_VALUE = $(patsubst %,and %,$(CT_HOOKS)) -CT_OPTS += -ct_hooks $(wordlist 2,$(words $(CT_HOOKS_PARAM_VALUE)),$(CT_HOOKS_PARAM_VALUE)) - -# On CI, set $RABBITMQ_CT_SKIP_AS_ERROR so that any skipped -# testsuite/testgroup/testcase is considered an error. - -ifeq ($(SKIP_AS_ERROR),1) -export RABBITMQ_CT_SKIP_AS_ERROR = true endif diff --git a/deps/rabbit_common/mk/rabbitmq-run.mk b/deps/rabbit_common/mk/rabbitmq-run.mk index d75fc3b8a8fc..c624fe331341 100644 --- a/deps/rabbit_common/mk/rabbitmq-run.mk +++ b/deps/rabbit_common/mk/rabbitmq-run.mk @@ -335,7 +335,7 @@ start-background-node: node-tmpdir $(DIST_TARGET) $(RABBITMQ_SERVER) \ $(REDIRECT_STDIO) & ERL_LIBS="$(DIST_ERL_LIBS)" \ - $(RABBITMQCTL) -n $(RABBITMQ_NODENAME) wait --timeout $(RMQCTL_WAIT_TIMEOUT) $(RABBITMQ_PID_FILE) kernel + $(RABBITMQCTL) -n $(RABBITMQ_NODENAME) wait --timeout $(RMQCTL_WAIT_TIMEOUT) $(RABBITMQ_PID_FILE) start-background-broker: node-tmpdir $(DIST_TARGET) $(maybe_enabled_plugins); \ diff --git a/deps/rabbit_common/src/rabbit_misc.erl b/deps/rabbit_common/src/rabbit_misc.erl index f904fa4e8522..0a403357d56d 100644 --- a/deps/rabbit_common/src/rabbit_misc.erl +++ b/deps/rabbit_common/src/rabbit_misc.erl @@ -1160,7 +1160,11 @@ get_channel_operation_timeout() -> %% Default channel_operation_timeout set to net_ticktime + 10s to %% give allowance for any down messages to be received first, %% whenever it is used for cross-node calls with timeouts. - Default = (net_kernel:get_net_ticktime() + 10) * 1000, + Tick = case net_kernel:get_net_ticktime() of + {ongoing_change_to, Tick0} -> Tick0; + Tick0 -> Tick0 + end, + Default = (Tick + 10) * 1000, application:get_env(rabbit, channel_operation_timeout, Default). moving_average(_Time, _HalfLife, Next, undefined) -> diff --git a/deps/rabbitmq_cli/mix.exs b/deps/rabbitmq_cli/mix.exs index c9010bacf9e2..32fc10fc7956 100644 --- a/deps/rabbitmq_cli/mix.exs +++ b/deps/rabbitmq_cli/mix.exs @@ -138,8 +138,6 @@ defmodule RabbitMQCtl.MixfileBase do end make_cmd = System.get_env("MAKE", "make") - fake_cmd = "true" - is_bazel = System.get_env("IS_BAZEL") != nil # Note that normal deps will be fetched by Erlang.mk on build. [ @@ -154,12 +152,12 @@ defmodule RabbitMQCtl.MixfileBase do { :stdout_formatter, path: Path.join(deps_dir, "stdout_formatter"), - compile: if(is_bazel, do: fake_cmd, else: make_cmd) + compile: make_cmd }, { :rabbit_common, path: Path.join(deps_dir, "rabbit_common"), - compile: if(is_bazel, do: fake_cmd, else: make_cmd), + compile: make_cmd, override: true } ] ++ @@ -173,7 +171,7 @@ defmodule RabbitMQCtl.MixfileBase do { :rabbit, path: Path.join(deps_dir, "rabbit"), - compile: if(is_bazel, do: fake_cmd, else: make_cmd), + compile: make_cmd, override: true }, { @@ -187,7 +185,7 @@ defmodule RabbitMQCtl.MixfileBase do { :amqp_client, path: Path.join(deps_dir, "amqp_client"), - compile: if(is_bazel, do: fake_cmd, else: make_cmd), + compile: make_cmd, override: true } ] diff --git a/deps/rabbitmq_cli/test/test_helper.exs b/deps/rabbitmq_cli/test/test_helper.exs index 172453f61b85..5bb4319f250a 100644 --- a/deps/rabbitmq_cli/test/test_helper.exs +++ b/deps/rabbitmq_cli/test/test_helper.exs @@ -12,14 +12,7 @@ ExUnit.configure( timeout: ten_minutes ) -if System.get_env("BAZEL_TEST") == "1" do - ExUnit.configure(seed: 0) - :application.ensure_all_started(:mix) - :application.ensure_all_started(:rabbitmqctl) - ExUnit.start(trace: true) -else - ExUnit.start() -end +ExUnit.start() # Elixir 1.15 compiler optimizations seem to require that we explicitly add to the code path true = Code.append_path(Path.join([System.get_env("DEPS_DIR"), "rabbit_common", "ebin"])) diff --git a/deps/rabbitmq_ct_helpers/src/ct_master_fork.erl b/deps/rabbitmq_ct_helpers/src/ct_master_fork.erl index 27be13619e22..628b25117ba7 100644 --- a/deps/rabbitmq_ct_helpers/src/ct_master_fork.erl +++ b/deps/rabbitmq_ct_helpers/src/ct_master_fork.erl @@ -738,11 +738,11 @@ master_format_gh_anno({error, {{exception, Reason, [{Mod, Fun, Arity, Loc}|_]}, %% if we don't have the real file name. File = proplists:get_value(file, Loc, ".github"), Line = proplists:get_value(line, Loc, 0), - io_lib:format("::error file=~s,line=~b::~w:~tw/~b: ~w~n", + io_lib:format("::error file=~s,line=~b::~w:~tw/~b: ~0p~n", [File, Line, Mod, Fun, Arity, Reason]); master_format_gh_anno(Reason) -> %% Do the bare minimum if we don't know the error reason. - io_lib:format("::error file=.github,line=0::~w~n", + io_lib:format("::error file=.github,line=0::~0p~n", [Reason]). update_queue(take,Node,From,Lock={Op,Resource},Locks,Blocked) -> diff --git a/deps/rabbitmq_ct_helpers/src/rabbit_ct_broker_helpers.erl b/deps/rabbitmq_ct_helpers/src/rabbit_ct_broker_helpers.erl index 6dec1179bb9f..1e32d606b779 100644 --- a/deps/rabbitmq_ct_helpers/src/rabbit_ct_broker_helpers.erl +++ b/deps/rabbitmq_ct_helpers/src/rabbit_ct_broker_helpers.erl @@ -216,31 +216,17 @@ %% ------------------------------------------------------------------- setup_steps() -> - case os:getenv("RABBITMQ_RUN") of - false -> - [ - fun run_make_dist/1, - fun rabbit_ct_helpers:ensure_rabbitmqctl_cmd/1, - fun rabbit_ct_helpers:ensure_rabbitmqctl_app/1, - fun rabbit_ct_helpers:ensure_rabbitmq_plugins_cmd/1, - fun rabbit_ct_helpers:ensure_rabbitmq_diagnostics_cmd/1, - fun set_lager_flood_limit/1, - fun configure_metadata_store/1, - fun start_rabbitmq_nodes/1, - fun share_dist_and_proxy_ports_map/1 - ]; - _ -> - [ - fun rabbit_ct_helpers:ensure_rabbitmqctl_cmd/1, - fun rabbit_ct_helpers:load_rabbitmqctl_app/1, - fun rabbit_ct_helpers:ensure_rabbitmq_plugins_cmd/1, - fun rabbit_ct_helpers:ensure_rabbitmq_diagnostics_cmd/1, - fun set_lager_flood_limit/1, - fun configure_metadata_store/1, - fun start_rabbitmq_nodes/1, - fun share_dist_and_proxy_ports_map/1 - ] - end. + [ + fun run_make_dist/1, + fun rabbit_ct_helpers:ensure_rabbitmqctl_cmd/1, + fun rabbit_ct_helpers:ensure_rabbitmqctl_app/1, + fun rabbit_ct_helpers:ensure_rabbitmq_plugins_cmd/1, + fun rabbit_ct_helpers:ensure_rabbitmq_diagnostics_cmd/1, + fun set_lager_flood_limit/1, + fun configure_metadata_store/1, + fun start_rabbitmq_nodes/1, + fun share_dist_and_proxy_ports_map/1 + ]. teardown_steps() -> [ @@ -690,12 +676,8 @@ write_config_file(Config, NodeConfig, _I) -> ]). do_start_rabbitmq_node(Config, NodeConfig, I) -> - WithPlugins0 = rabbit_ct_helpers:get_config(Config, - broker_with_plugins), %% @todo This is probably not used. - WithPlugins = case is_list(WithPlugins0) of - true -> lists:nth(I + 1, WithPlugins0); - false -> WithPlugins0 - end, + %% @todo Review all instances of secondary_dist and secondary_umbrella and ensure it works for both. + %% @todo A SECONDARY_DIST_TAG= could be useful, fetching automatically the dist. ForceUseSecondary = rabbit_ct_helpers:get_config( Config, force_secondary, undefined), CanUseSecondary = case ForceUseSecondary of @@ -712,178 +694,168 @@ do_start_rabbitmq_node(Config, NodeConfig, I) -> false -> false; _ -> CanUseSecondary end, - SrcDir = case WithPlugins of - false when UseSecondaryUmbrella -> ?config(secondary_rabbit_srcdir, - Config); - false -> ?config(rabbit_srcdir, Config); - _ when UseSecondaryUmbrella -> ?config(secondary_current_srcdir, - Config); - _ -> ?config(current_srcdir, Config) + SrcDir = case UseSecondaryUmbrella of + true -> ?config(secondary_current_srcdir, Config); + false -> ?config(current_srcdir, Config) end, PrivDir = ?config(priv_dir, Config), Nodename = ?config(nodename, NodeConfig), InitialNodename = ?config(initial_nodename, NodeConfig), DistPort = ?config(tcp_port_erlang_dist, NodeConfig), ConfigFile = ?config(erlang_node_config_filename, NodeConfig), - AdditionalErlArgs = rabbit_ct_helpers:get_config(Config, additional_erl_args, []), %% Use inet_proxy_dist to handle distribution. This is used by the %% partitions testsuite. DistMod = rabbit_ct_helpers:get_config(Config, erlang_dist_module), - StartArgs0 = case DistMod of + %% Peer arguments. + PeerArgs0 = case DistMod of undefined -> - ""; + []; _ -> DistModS = atom_to_list(DistMod), DistModPath = filename:absname( filename:dirname(code:where_is_file(DistModS ++ ".beam"))), DistArg = re:replace(DistModS, "_dist$", "", [{return, list}]), - "-pa \"" ++ DistModPath ++ "\" -proto_dist " ++ DistArg + [ + "-pa", DistModPath, + "-proto_dist", DistArg + ] end, - %% Set the net_ticktime to 5s for all nodes (including CT via CT_OPTS). - %% A lower tick time helps trigger distribution failures faster. - StartArgs1 = StartArgs0 ++ " -kernel net_ticktime 5", - ExtraArgs0 = [], - ExtraArgs1 = case rabbit_ct_helpers:get_config(Config, rmq_plugins_dir) of + PeerArgs1 = [ +% "-init_debug", + "-boot", "start_sasl", + "+W", "w", + "+MBas", "ageffcbf", + "+MHas", "ageffcbf", + "+MBlmbcs", "512", + "+MHlmbcs", "512", + "+MMmcs", "30", + "+S", "2", + "+sbwt", "very_short", %% @todo Used twice in server start script? + "+A", "24", %% @todo Remove this from server start script? + %% $SERVER_ERL_ARGS + "+pc", "unicode", + "+P", "1048576", + "+t", "5000000", + "+stbt", "db", + "+zdbbl", "128000", + "+sbwt", "none", + "+sbwtdcpu", "none", + "+sbwtdio", "none", + %% Set the net_ticktime to 5s for all nodes (including CT via CT_OPTS). + %% A lower tick time helps trigger distribution failures faster. + "-kernel", "net_ticktime", "5", %% @todo Update parallel-test stuff to set it properly. + "-kernel", "prevent_overlapping_partitions", "false", + "-syslog", "logger", "[]", + "-syslog", "syslog_error_logger", "false" + |PeerArgs0], + AdditionalErlArgs = rabbit_ct_helpers:get_config(Config, additional_erl_args, []), + PeerArgs = PeerArgs1 ++ case AdditionalErlArgs of [] -> []; _ -> string:split(AdditionalErlArgs, " ", all) end, + %% Peer environment. + NodeDir = filename:join(PrivDir, atom_to_list(InitialNodename)), + [Nodename1, HostName1] = string:split(atom_to_list(Nodename), "@"), + PeerEnv0 = [ + {"RABBITMQ_NODENAME", atom_to_list(Nodename)}, + {"RABBITMQ_BASE", NodeDir}, + {"RABBITMQ_PID_FILE", filename:join(NodeDir, atom_to_list(InitialNodename) ++ ".pid")}, + {"RABBITMQ_LOG_BASE", filename:join(NodeDir, "log")}, + {"RABBITMQ_MNESIA_BASE", filename:join(NodeDir, "mnesia")}, + {"RABBITMQ_MNESIA_DIR", filename:join(filename:join(NodeDir, "mnesia"), atom_to_list(InitialNodename))}, + {"RABBITMQ_QUORUM_DIR", filename:join([NodeDir, "mnesia", "quorum"])}, + {"RABBITMQ_STREAM_DIR", filename:join([NodeDir, "mnesia", "stream"])}, + {"RABBITMQ_FEATURE_FLAGS_FILE", filename:join(NodeDir, "feature_flags")}, + {"RABBITMQ_PLUGINS_EXPAND_DIR", filename:join(NodeDir, "plugins")}, + {"RABBITMQ_ENABLED_PLUGINS_FILE", filename:join(NodeDir, "enabled_plugins")}, + {"RABBITMQ_DIST_PORT", integer_to_list(DistPort)}, + {"RABBITMQ_CONFIG_FILE", ConfigFile}, + {"RABBITMQ_LOG", "debug"} + ], + PluginsDir = case UseSecondaryDist of + true -> filename:join(?config(secondary_dist, Config), "plugins"); + false -> filename:join(SrcDir, "plugins") + end, + PeerEnv1 = case rabbit_ct_helpers:get_config(Config, rmq_plugins_dir) of undefined -> - ExtraArgs0; - ExtraPluginsDir -> - [{"EXTRA_PLUGINS_DIR=~ts", [ExtraPluginsDir]} - | ExtraArgs0] + [{"RABBITMQ_PLUGINS_DIR", PluginsDir}|PeerEnv0]; + ExtraPluginsDir1 -> + [{"RABBITMQ_PLUGINS_DIR", ExtraPluginsDir1 ++ ":" ++ PluginsDir}|PeerEnv0] end, StartWithPluginsDisabled = rabbit_ct_helpers:get_config( Config, start_rmq_with_plugins_disabled), - ExtraArgs2 = case StartWithPluginsDisabled of - true -> - ["LEAVE_PLUGINS_DISABLED=1" | ExtraArgs1]; - _ -> - ExtraArgs1 - end, + PeerEnv2 = if + StartWithPluginsDisabled -> + PeerEnv1; + UseSecondaryDist -> + case ?config(secondary_enabled_plugins, Config) of + undefined -> + case filename:basename(SrcDir) of + "rabbit" -> PeerEnv1; + SrcPlugin -> + [{"RABBITMQ_ENABLED_PLUGINS", SrcPlugin}|PeerEnv1] + end; + SecondaryEnabledPlugins -> + [{"RABBITMQ_ENABLED_PLUGINS", SecondaryEnabledPlugins}|PeerEnv1] + end; + true -> + [{"RABBITMQ_ENABLED_PLUGINS", "ALL"}|PeerEnv1] + end, + %% @todo Seems like this variable is set twice? Seen in rabbit logs. KeepPidFile = rabbit_ct_helpers:get_config( Config, keep_pid_file_on_exit), - ExtraArgs3 = case KeepPidFile of - true -> ["RABBITMQ_KEEP_PID_FILE_ON_EXIT=yes" | ExtraArgs2]; - _ -> ExtraArgs2 + PeerEnv3 = case KeepPidFile of + true -> [{"RABBITMQ_KEEP_PID_FILE_ON_EXIT", "yes"}|PeerEnv2]; + _ -> PeerEnv2 end, - ExtraArgs4 = case WithPlugins of - false -> ExtraArgs3; - _ -> ["NOBUILD=1" | ExtraArgs3] - end, - ExtraArgs = case UseSecondaryUmbrella of - true -> - DepsDir = ?config(erlang_mk_depsdir, Config), - ErlLibs = os:getenv("ERL_LIBS"), - SecDepsDir = ?config(secondary_erlang_mk_depsdir, - Config), - SecErlLibs = lists:flatten( - string:replace(ErlLibs, - DepsDir, - SecDepsDir, - all)), - SecNewScriptsDir = filename:join([SecDepsDir, - SrcDir, - "sbin"]), - SecOldScriptsDir = filename:join([SecDepsDir, - "rabbit", - "scripts"]), - SecNewScriptsDirExists = filelib:is_dir( - SecNewScriptsDir), - SecScriptsDir = case SecNewScriptsDirExists of - true -> SecNewScriptsDir; - false -> SecOldScriptsDir - end, - [{"DEPS_DIR=~ts", [SecDepsDir]}, - {"REBAR_DEPS_DIR=~ts", [SecDepsDir]}, - {"ERL_LIBS=~ts", [SecErlLibs]}, - {"RABBITMQ_SCRIPTS_DIR=~ts", [SecScriptsDir]}, - {"RABBITMQ_SERVER=~ts/rabbitmq-server", [SecScriptsDir]}, - {"RABBITMQCTL=~ts/rabbitmqctl", [SecScriptsDir]}, - {"RABBITMQ_PLUGINS=~ts/rabbitmq-plugins", [SecScriptsDir]} - | ExtraArgs4]; - false -> - case UseSecondaryDist of - true -> - SecondaryDist = ?config(secondary_dist, Config), - SecondaryEnabledPlugins = case { - StartWithPluginsDisabled, - ?config(secondary_enabled_plugins, Config), - filename:basename(SrcDir) - } of - {true, _, _} -> ""; - {_, undefined, "rabbit"} -> ""; - {_, undefined, SrcPlugin} -> SrcPlugin; - {_, SecondaryEnabledPlugins0, _} -> SecondaryEnabledPlugins0 - end, - [{"DIST_DIR=~ts/plugins", [SecondaryDist]}, - {"CLI_SCRIPTS_DIR=~ts/sbin", [SecondaryDist]}, - {"CLI_ESCRIPTS_DIR=~ts/escript", [SecondaryDist]}, - {"RABBITMQ_SCRIPTS_DIR=~ts/sbin", [SecondaryDist]}, - {"RABBITMQ_SERVER=~ts/sbin/rabbitmq-server", [SecondaryDist]}, - {"RABBITMQ_ENABLED_PLUGINS=~ts", [SecondaryEnabledPlugins]} - | ExtraArgs4]; - false -> - ExtraArgs4 - end - end, - MakeVars = [ - {"RABBITMQ_NODENAME=~ts", [Nodename]}, - {"RABBITMQ_NODENAME_FOR_PATHS=~ts", [InitialNodename]}, - {"RABBITMQ_DIST_PORT=~b", [DistPort]}, - {"RABBITMQ_CONFIG_FILE=~ts", [ConfigFile]}, - {"RABBITMQ_SERVER_START_ARGS=~ts", [StartArgs1]}, - {"RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS=+S 2 +sbwt very_short +A 24 ~ts", [AdditionalErlArgs]}, - "RABBITMQ_LOG=debug", - {"TEST_TMPDIR=~ts", [PrivDir]} - | ExtraArgs], - Cmd = ["start-background-broker" | MakeVars], - case rabbit_ct_helpers:get_config(Config, rabbitmq_run_cmd) of - undefined -> - case rabbit_ct_helpers:make(Config, SrcDir, Cmd) of - {ok, _} -> - NodeConfig1 = rabbit_ct_helpers:set_config( - NodeConfig, - [{use_secondary_umbrella, - UseSecondaryUmbrella orelse - UseSecondaryDist}, - {effective_srcdir, SrcDir}, - {make_vars_for_node_startup, MakeVars}]), - query_node(Config, NodeConfig1); - _ -> - AbortCmd = ["stop-node" | MakeVars], - _ = rabbit_ct_helpers:make(Config, SrcDir, AbortCmd), - %% @todo Need to stop all nodes in the cluster, not just the one node. - {skip, "Failed to initialize RabbitMQ"} - end; - RunCmd -> - UseSecondary = CanUseSecondary andalso - rabbit_ct_helpers:get_config(Config, rabbitmq_run_secondary_cmd) =/= undefined, - PluginsMakeVars = case {UseSecondary, WithPlugins} of - {_, false} -> - ["LEAVE_PLUGINS_DISABLED=1"]; - {true, _} -> - case filename:basename(SrcDir) of - "rabbit" -> - ["LEAVE_PLUGINS_DISABLED=1"]; - Plugin -> - [{"RABBITMQ_ENABLED_PLUGINS=~ts", [Plugin]}] - end; - _ -> - [] - end, - RmqRun = case CanUseSecondary of - false -> RunCmd; - _ -> rabbit_ct_helpers:get_config(Config, rabbitmq_run_secondary_cmd, RunCmd) - end, - case rabbit_ct_helpers:exec([RmqRun, "-C", SrcDir] ++ PluginsMakeVars ++ Cmd) of - {ok, _} -> - NodeConfig1 = rabbit_ct_helpers:set_config( - NodeConfig, - [{make_vars_for_node_startup, MakeVars}]), - query_node(Config, NodeConfig1); - _ -> - AbortCmd = ["stop-node" | MakeVars], - _ = rabbit_ct_helpers:exec([RunCmd | AbortCmd]), - {skip, "Failed to initialize RabbitMQ"} - end + PeerEnv = if + UseSecondaryDist -> + [{"ERL_LIBS", filename:join(?config(secondary_dist, Config), "plugins")}|PeerEnv3]; + UseSecondaryUmbrella -> + [{"ERL_LIBS", ?config(secondary_erlang_mk_depsdir, Config)}|PeerEnv3]; + true -> + PeerEnv3 + end, + %% Start the peer node. + {ok, PeerPid, Nodename} = peer:start(#{ + name => Nodename1, + longnames => false, + host => HostName1, + connection => standard_io, + exec => os:find_executable("erl"), + args => PeerArgs, + env => PeerEnv}), + %% Redirect the PeerPid's standard output to a file. + %% The standard output of the peer process is a redirect + %% from the peer node. We tie the file's process to PeerPid + %% so that it stays open until PeerPid exits. + %% + %% Both stdio and stderr are redirected to this file, + %% unlike when using make run-broker and friends. + _ = sys:replace_state(PeerPid, fun(St) -> + StdoutPath = filename:join([NodeDir, "log", "startup_log"]), + ok = filelib:ensure_dir(StdoutPath), + {ok, StdoutFd} = file:open(StdoutPath, [write, {encoding, utf8}]), + group_leader(StdoutFd, self()), + St + end), + %% Make sure the node runs in the right directory. + SetCwdPath = case UseSecondaryDist of + true -> ?config(secondary_dist, Config); + false -> SrcDir + end, + ok = peer:call(PeerPid, file, set_cwd, [SetCwdPath]), + %% Boot RabbitMQ. + try peer:call(PeerPid, rabbit, boot, [], 60_000) of + ok -> + store_peer_pid(Nodename, PeerPid), + NodeConfig1 = rabbit_ct_helpers:set_config( + NodeConfig, + [ + {use_secondary_umbrella, UseSecondaryUmbrella orelse UseSecondaryDist} + ]), + query_node(Config, NodeConfig1) + catch Class:Error -> + %% @todo Get rid of {skip,_} returns. + peer:stop(PeerPid), + {skip, {Class, Error}} end. query_node(Config, NodeConfig) -> @@ -1319,25 +1291,32 @@ stop_rabbitmq_nodes(Config) -> end, proplists:delete(rmq_nodes, Config). -stop_rabbitmq_node(Config, NodeConfig) -> +stop_rabbitmq_node(_Config, NodeConfig) -> Nodename = ?config(nodename, NodeConfig), - cover_remove_node(Nodename), - SrcDir = ?config(effective_srcdir, NodeConfig), - InitialMakeVars = ?config(make_vars_for_node_startup, NodeConfig), - InitialNodename = ?config(initial_nodename, NodeConfig), - MakeVars = InitialMakeVars ++ [ - {"RABBITMQ_NODENAME=~ts", [Nodename]}, - {"RABBITMQ_NODENAME_FOR_PATHS=~ts", [InitialNodename]} - ], - Cmd = ["stop-node" | MakeVars], - _ = case rabbit_ct_helpers:get_config(Config, rabbitmq_run_cmd) of - undefined -> - rabbit_ct_helpers:make(Config, SrcDir, Cmd); - RunCmd -> - rabbit_ct_helpers:exec([RunCmd | Cmd]) + try query_peer_pid(Nodename) of + PeerPid -> + cover_remove_node(Nodename), + try + peer:call(PeerPid, rabbit, stop, [], 60_000), + peer:stop(PeerPid) + catch exit:{noproc, _} -> + ct:pal("Node ~p was previously killed.", [Nodename]) + end + catch error:badarg -> + ct:pal("Node ~p is already stopped.", [Nodename]) end, + erase_peer_pid(Nodename), NodeConfig. +store_peer_pid(Nodename, PeerPid) -> + persistent_term:put({peer_pid, Nodename}, PeerPid). + +query_peer_pid(Nodename) -> + persistent_term:get({peer_pid, Nodename}). + +erase_peer_pid(Nodename) -> + persistent_term:erase({peer_pid, Nodename}). + find_crashes_in_logs(NodeConfigs, IgnoredCrashes) -> ct:log( "Looking up any crash reports in the nodes' log files. If we find " @@ -1479,53 +1458,23 @@ rabbitmqctl(Config, Node, Args, Timeout) -> %% umbrella being configured. I = get_node_index(Config, Node), CanUseSecondary = (I + 1) rem 2 =:= 0, - BazelRunSecCmd = rabbit_ct_helpers:get_config( - Config, rabbitmq_run_secondary_cmd), UseSecondaryDist = case ?config(secondary_dist, Config) of false -> false; _ -> CanUseSecondary end, UseSecondaryUmbrella = case ?config(secondary_umbrella, Config) of - false -> - case BazelRunSecCmd of - undefined -> false; - _ -> CanUseSecondary - end; - _ -> - CanUseSecondary + false -> false; + _ -> CanUseSecondary end, - WithPlugins0 = rabbit_ct_helpers:get_config(Config, - broker_with_plugins), - WithPlugins = case is_list(WithPlugins0) of - true -> lists:nth(I + 1, WithPlugins0); - false -> WithPlugins0 - end, Rabbitmqctl = case UseSecondaryUmbrella of true -> - case BazelRunSecCmd of - undefined -> - SrcDir = case WithPlugins of - false -> - ?config( - secondary_rabbit_srcdir, - Config); - _ -> - ?config( - secondary_current_srcdir, - Config) - end, - SecScriptsDir = filename:join( - [SrcDir, "sbin"]), - rabbit_misc:format( - "~ts/rabbitmqctl", [SecScriptsDir]); - _ -> - BazelSecScriptsDir = filename:dirname( - BazelRunSecCmd), - filename:join( - [BazelSecScriptsDir, - "sbin", - "rabbitmqctl"]) - end; + SrcDir = ?config( + secondary_current_srcdir, + Config), + SecScriptsDir = filename:join( + [SrcDir, "sbin"]), + rabbit_misc:format( + "~ts/rabbitmqctl", [SecScriptsDir]); false -> case UseSecondaryDist of true -> @@ -2426,12 +2375,6 @@ plugin_action(Config, Node, Args) -> %% umbrella being configured. I = get_node_index(Config, Node), CanUseSecondary = (I + 1) rem 2 =:= 0, - WithPlugins0 = rabbit_ct_helpers:get_config(Config, - broker_with_plugins), - WithPlugins = case is_list(WithPlugins0) of - true -> lists:nth(I + 1, WithPlugins0); - false -> WithPlugins0 - end, UseSecondaryDist = case ?config(secondary_dist, Config) of false -> false; _ -> CanUseSecondary @@ -2444,16 +2387,9 @@ plugin_action(Config, Node, Args) -> end, Rabbitmqplugins = case UseSecondaryUmbrella of true -> - SrcDir = case WithPlugins of - false -> - ?config( - secondary_rabbit_srcdir, - Config); - _ -> - ?config( - secondary_current_srcdir, - Config) - end, + SrcDir = ?config( + secondary_current_srcdir, + Config), SecScriptsDir = filename:join( [SrcDir, "sbin"]), rabbit_misc:format( @@ -2539,13 +2475,8 @@ cover_remove_node(Config, Node) -> cover_remove_node(Nodename). if_cover(F) -> - case { - %% make ct COVER=1 - os:getenv("COVER"), - %% bazel coverage - os:getenv("COVERAGE") - } of - {false, false} -> ok; + case os:getenv("COVER") of + false -> ok; _ -> _ = F(), ok end. diff --git a/deps/rabbitmq_ct_helpers/src/rabbit_ct_helpers.erl b/deps/rabbitmq_ct_helpers/src/rabbit_ct_helpers.erl index 1d785266d55a..16f1c6cc92e8 100644 --- a/deps/rabbitmq_ct_helpers/src/rabbit_ct_helpers.erl +++ b/deps/rabbitmq_ct_helpers/src/rabbit_ct_helpers.erl @@ -24,7 +24,6 @@ ensure_application_srcdir/4, ensure_rabbitmqctl_cmd/1, ensure_rabbitmqctl_app/1, - load_rabbitmqctl_app/1, ensure_rabbitmq_plugins_cmd/1, ensure_rabbitmq_queues_cmd/1, ensure_rabbitmq_streams_cmd/1, @@ -81,9 +80,7 @@ run_setup_steps(Config) -> run_setup_steps(Config, []). run_setup_steps(Config, ExtraSteps) -> - Steps = case os:getenv("RABBITMQ_RUN") of - false -> - [ + Steps = [ fun init_skip_as_error_flag/1, fun guess_tested_erlang_app_name/1, fun ensure_secondary_dist/1, @@ -97,25 +94,10 @@ run_setup_steps(Config, ExtraSteps) -> fun ensure_rabbitmq_cli_srcdir/1, fun ensure_rabbit_srcdir/1, fun ensure_make_cmd/1, - fun ensure_erl_call_cmd/1, fun ensure_ssl_certs/1, fun start_long_running_testsuite_monitor/1, fun load_elixir/1 - ]; - _ -> - [ - fun init_skip_as_error_flag/1, - fun ensure_secondary_umbrella/1, - fun ensure_current_srcdir/1, - fun ensure_rabbitmq_ct_helpers_srcdir/1, - fun maybe_rabbit_srcdir/1, - fun ensure_make_cmd/1, - fun ensure_rabbitmq_run_cmd/1, - fun ensure_rabbitmq_run_secondary_cmd/1, - fun ensure_ssl_certs/1, - fun start_long_running_testsuite_monitor/1 - ] - end, + ], run_steps(Config, Steps ++ ExtraSteps). run_teardown_steps(Config) -> @@ -337,15 +319,6 @@ ensure_rabbitmq_cli_srcdir(Config) -> ensure_rabbit_srcdir(Config) -> ensure_application_srcdir(Config, rabbit, rabbit). -maybe_rabbit_srcdir(Config) -> - % Some tests under bazel use this value, others do not. - % By allowing this config to be optional, we avoid making - % more tests depend on rabbit - case ensure_application_srcdir(Config, rabbit, rabbit) of - {skip, _} -> Config; - Config1 -> Config1 - end. - ensure_application_srcdir(Config, App, Module) -> ensure_application_srcdir(Config, App, erlang, Module). @@ -407,38 +380,6 @@ ensure_make_cmd(Config) -> "please set MAKE or 'make_cmd' in ct config"} end. -ensure_rabbitmq_run_cmd(Config) -> - Path = os:getenv("RABBITMQ_RUN"), - case filelib:is_file(Path) of - true -> set_config(Config, {rabbitmq_run_cmd, Path}); - false -> {skip, - "Bazel helper rabbitmq-run required, " ++ - "please set RABBITMQ_RUN"} - end. - -ensure_rabbitmq_run_secondary_cmd(Config) -> - case os:getenv("RABBITMQ_RUN_SECONDARY") of - false -> - Config; - Path -> - case filelib:is_file(Path) of - true -> - set_config(Config, {rabbitmq_run_secondary_cmd, Path}); - false -> - error("RABBITMQ_RUN_SECONDARY was set, but is not a valid file") - end - end. - -ensure_erl_call_cmd(Config) -> - ErlCall = filename:join(code:lib_dir(erl_interface), "bin/erl_call"), - Cmd = [ErlCall], - case exec(Cmd, [{match_stdout, "Usage: "}]) of - {ok, _} -> set_config(Config, {erl_call_cmd, ErlCall}); - _ -> {skip, - "erl_call required, " ++ - "please set ERL_CALL or 'erl_call_cmd' in ct config"} - end. - ensure_rabbitmqctl_cmd(Config) -> Rabbitmqctl = case get_config(Config, rabbitmqctl_cmd) of undefined -> @@ -518,19 +459,6 @@ ensure_rabbitmqctl_app(Config) -> "please build rabbitmq_cli"} end. -load_rabbitmqctl_app(Config) -> - case application:load(rabbitmqctl) of - ok -> - Config; - {error, {already_loaded, rabbitmqctl}} -> - Config; - {error, Reason} -> - ct:pal(?LOW_IMPORTANCE, - "Failed to load rabbitmqctl application: ~tp", [Reason]), - {skip, "Application rabbitmqctl could not be loaded, " ++ - "please place compiled rabbitmq_cli on the code path"} - end. - ensure_rabbitmq_plugins_cmd(Config) -> Rabbitmqplugins = case get_config(Config, rabbitmq_plugins_cmd) of undefined -> @@ -727,11 +655,8 @@ get_selection(Config) -> symlink_priv_dir(Config) -> - case {os:type(), ?config(rabbitmq_run_cmd, Config)} of - {{win32, _}, _} -> - Config; - {_, Cmd} when Cmd =/= undefined -> - %% skip if bazel + case os:type() of + {win32, _} -> Config; _ -> SrcDir = ?config(current_srcdir, Config), @@ -1148,13 +1073,11 @@ convert_to_unicode_binary(Arg) when is_binary(Arg) -> is_mixed_versions() -> os:getenv("SECONDARY_DIST") =/= false - orelse os:getenv("SECONDARY_UMBRELLA") =/= false - orelse os:getenv("RABBITMQ_RUN_SECONDARY") =/= false. + orelse os:getenv("SECONDARY_UMBRELLA") =/= false. is_mixed_versions(Config) -> get_config(Config, secondary_dist, false) =/= false - orelse get_config(Config, secondary_umbrella, false) =/= false - orelse get_config(Config, rabbitmq_run_secondary_cmd, false) =/= false. + orelse get_config(Config, secondary_umbrella, false) =/= false. %% ------------------------------------------------------------------- %% Assertions that retry diff --git a/deps/rabbitmq_ct_helpers/tools/tls-certs/Makefile b/deps/rabbitmq_ct_helpers/tools/tls-certs/Makefile index 5071bedb62da..7e28422fd507 100644 --- a/deps/rabbitmq_ct_helpers/tools/tls-certs/Makefile +++ b/deps/rabbitmq_ct_helpers/tools/tls-certs/Makefile @@ -43,8 +43,8 @@ $(DIR)/testca/cacert.pem: chmod 700 private && \ echo 01 > serial && \ :> index.txt && \ - sed -e 's/@HOSTNAME@/$(HOSTNAME)/g' $(CURDIR)/openssl.cnf.in > $(CURDIR)/openssl.cnf && \ - openssl req -x509 -config $(CURDIR)/openssl.cnf -newkey rsa:2048 -days 365 \ + sed -e 's/@HOSTNAME@/$(HOSTNAME)/g' $(CURDIR)/openssl.cnf.in > $(dir $@)/openssl.cnf && \ + openssl req -x509 -config $(dir $@)/openssl.cnf -newkey rsa:2048 -days 365 \ -out cacert.pem -outform PEM -subj /CN=MyTestCA/L=$$$$/ -nodes && \ openssl x509 -in cacert.pem -out cacert.cer -outform DER ) $(openssl_output) \ || (rm -rf $(dir $@) && false); } @@ -52,12 +52,12 @@ $(DIR)/testca/cacert.pem: $(DIR)/%/cert.pem: $(DIR)/testca/cacert.pem $(gen_verbose) mkdir -p $(DIR)/$(TARGET) $(verbose) { ( cd $(DIR)/$(TARGET) && \ - sed -e 's/@HOSTNAME@/$(HOSTNAME)/g' $(CURDIR)/openssl.cnf.in > $(CURDIR)/openssl.cnf && \ + sed -e 's/@HOSTNAME@/$(HOSTNAME)/g' $(CURDIR)/openssl.cnf.in > $(DIR)/$(TARGET)/openssl.cnf && \ openssl genrsa -out key.pem 2048 && \ - openssl req -config $(CURDIR)/openssl.cnf -new -key key.pem -out req.pem -outform PEM \ + openssl req -config $(DIR)/$(TARGET)/openssl.cnf -new -key key.pem -out req.pem -outform PEM \ -subj /C=UK/ST=England/CN=$(HOSTNAME)/O=$(TARGET)/L=$$$$/ -nodes && \ cd ../testca && \ - openssl ca -config $(CURDIR)/openssl.cnf -in ../$(TARGET)/req.pem -out \ + openssl ca -config $(DIR)/$(TARGET)/openssl.cnf -in ../$(TARGET)/req.pem -out \ ../$(TARGET)/cert.pem -notext -batch -extensions \ $(TARGET)_ca_extensions && \ cd ../$(TARGET) && \ diff --git a/deps/rabbitmq_peer_discovery_common/test/peer_discovery_cleanup_SUITE.erl b/deps/rabbitmq_peer_discovery_common/test/peer_discovery_cleanup_SUITE.erl index e04d725528a7..051c658c0eda 100644 --- a/deps/rabbitmq_peer_discovery_common/test/peer_discovery_cleanup_SUITE.erl +++ b/deps/rabbitmq_peer_discovery_common/test/peer_discovery_cleanup_SUITE.erl @@ -57,6 +57,9 @@ init_per_testcase(Testcase, Config) -> [{cluster_formation, [{peer_discovery_backend, rabbit_peer_discovery_dns}, {peer_discovery_dns, [{hostname, Hostname}]}, + %% We are going to cluster nodes after setting up meck so + %% limit the number of times it tries to cluster during boot. + {discovery_retry_limit, 0}, %% Enable cleanup but set the interval high. Test cases should %% call rabbit_peer_discovery_cleanup:check_cluster/0 to force %% cleanup evaluation. diff --git a/selenium/README.md b/selenium/README.md index c667f8ceef11..c44aaa1644c2 100644 --- a/selenium/README.md +++ b/selenium/README.md @@ -92,17 +92,6 @@ cd ../../../../ make package-generic-unix make docker-image ``` ->> Equivalent bazel command: `bazelisk run packaging/docker-image:rabbitmq` - -The last command prints something like this: -``` - => => naming to docker.io/pivotalrabbitmq/rabbitmq:3.11.0-rc.2.51.g4f3e539.dirty 0.0s -``` - -Or if you prefer to use bazel run instead: -``` -bazelisk run packaging/docker-image:rabbitmq -``` To run a suite with a particular docker image you do it like this: @@ -110,11 +99,6 @@ To run a suite with a particular docker image you do it like this: cd deps/rabbitmq_management/selenium RABBITMQ_DOCKER_IMAGE=pivotalrabbitmq/rabbitmq:3.11.0-rc.2.51.g4f3e539.dirty suites/authnz-mgt/oauth-with-uaa-with-mgt-prefix.sh ``` -or like this if you built the docker image using bazel: -``` -cd deps/rabbitmq_management/selenium -RABBITMQ_DOCKER_IMAGE=bazel/packaging/docker-image:rabbitmq suites/authnz-mgt/oauth-with-uaa-with-mgt-prefix.sh -``` To customise the Selenium docker image, use the env variable `SELENIUM_DOCKER_IMAGE`: