From 345aebbf06b6af7cdaa7b9a7e7584915d0b07d2d Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Wed, 4 Dec 2024 11:07:34 -0500 Subject: [PATCH 1/5] CLI: Resolve elixirc warnings (cherry picked from commit d58d874a0b9744fc3c3f790f0f85d58f7ec08a7d) --- deps/rabbitmq_cli/lib/rabbitmq/cli/auto_complete.ex | 2 +- .../check_if_any_deprecated_features_are_used_command_test.exs | 2 +- ..._cluster_has_classic_queue_mirroring_policy_command_test.exs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/deps/rabbitmq_cli/lib/rabbitmq/cli/auto_complete.ex b/deps/rabbitmq_cli/lib/rabbitmq/cli/auto_complete.ex index 9983125bf272..9a0cfe342c63 100644 --- a/deps/rabbitmq_cli/lib/rabbitmq/cli/auto_complete.ex +++ b/deps/rabbitmq_cli/lib/rabbitmq/cli/auto_complete.ex @@ -94,7 +94,7 @@ defmodule RabbitMQ.CLI.AutoComplete do defp complete_command_opts(command, <<"-", _::binary>> = opt) do switches = - command.switches + command.switches() |> Keyword.keys() |> Enum.map(fn sw -> "--" <> to_string(sw) end) diff --git a/deps/rabbitmq_cli/test/diagnostics/check_if_any_deprecated_features_are_used_command_test.exs b/deps/rabbitmq_cli/test/diagnostics/check_if_any_deprecated_features_are_used_command_test.exs index 4f05e67052f8..b7cb27683e08 100644 --- a/deps/rabbitmq_cli/test/diagnostics/check_if_any_deprecated_features_are_used_command_test.exs +++ b/deps/rabbitmq_cli/test/diagnostics/check_if_any_deprecated_features_are_used_command_test.exs @@ -10,7 +10,7 @@ defmodule CheckIfAnyDeprecatedFeaturesAreUsedCommandTest do @command RabbitMQ.CLI.Diagnostics.Commands.CheckIfAnyDeprecatedFeaturesAreUsedCommand @policy_name "cmq-policy-8373" - @policy_value "{\"ha-mode\":\"all\"}" + # @policy_value "{\"ha-mode\":\"all\"}" setup_all do RabbitMQ.CLI.Core.Distribution.start() diff --git a/deps/rabbitmq_cli/test/diagnostics/check_if_cluster_has_classic_queue_mirroring_policy_command_test.exs b/deps/rabbitmq_cli/test/diagnostics/check_if_cluster_has_classic_queue_mirroring_policy_command_test.exs index bcc926e5558b..b5b3e95d9dbf 100644 --- a/deps/rabbitmq_cli/test/diagnostics/check_if_cluster_has_classic_queue_mirroring_policy_command_test.exs +++ b/deps/rabbitmq_cli/test/diagnostics/check_if_cluster_has_classic_queue_mirroring_policy_command_test.exs @@ -10,7 +10,7 @@ defmodule CheckIfClusterHasClassicQueueMirroringPolicyCommandTest do @command RabbitMQ.CLI.Diagnostics.Commands.CheckIfClusterHasClassicQueueMirroringPolicyCommand @policy_name "cmq-policy-8373" - @policy_value "{\"ha-mode\":\"all\"}" + # @policy_value "{\"ha-mode\":\"all\"}" setup_all do RabbitMQ.CLI.Core.Distribution.start() From b89b8907878b58db977134d0746928fb53c76673 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Wed, 4 Dec 2024 11:07:46 -0500 Subject: [PATCH 2/5] CLI: Fix match of discover peers command test This previously emitted a warning because Elixir will rebind `this_node` by default, so the `this_node` binding in the line above was unused. (As opposed to Erlang which would treat this as a match - rejecting the binding if `this_node` was not equal to the value being matched.) The node needed to be adjusted as well - `node()` returned the ExUnit runner's node while the command returned the remote node, which is stored in the context under `opts.node`. (cherry picked from commit c328922a2a0fa3dd32b92d27ecf68b95d398e12a) --- .../test/diagnostics/discover_peers_command_test.exs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deps/rabbitmq_cli/test/diagnostics/discover_peers_command_test.exs b/deps/rabbitmq_cli/test/diagnostics/discover_peers_command_test.exs index 791d07dc484f..b68ed35ffa59 100644 --- a/deps/rabbitmq_cli/test/diagnostics/discover_peers_command_test.exs +++ b/deps/rabbitmq_cli/test/diagnostics/discover_peers_command_test.exs @@ -37,7 +37,7 @@ defmodule DiscoverPeersCommandTest do @tag test_timeout: 15000 test "run: returns a list of nodes when the backend isn't configured", context do - this_node = node() - assert match?({:ok, {[this_node], _}}, @command.run([], context[:opts])) + this_node = context.opts.node + assert match?({:ok, {[^this_node], _}}, @command.run([], context[:opts])) end end From b747ff23648f4a31ce433370eb51818a814881e7 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Wed, 4 Dec 2024 11:10:46 -0500 Subject: [PATCH 3/5] CLI: Silence `status` command test This check is expected to succeed and the status is expected to be printed to stdout rather than stderr. This change silences the status output. The status text was printed mistakenly previously because we captured stderr rather than stdout. (cherry picked from commit 9f603255639639ed94f9d86d9cbcd612e1ee3ef1) --- deps/rabbitmq_cli/test/rabbitmqctl_test.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps/rabbitmq_cli/test/rabbitmqctl_test.exs b/deps/rabbitmq_cli/test/rabbitmqctl_test.exs index 52ed2e10b2a3..a34b2b07e3cb 100644 --- a/deps/rabbitmq_cli/test/rabbitmqctl_test.exs +++ b/deps/rabbitmq_cli/test/rabbitmqctl_test.exs @@ -121,7 +121,7 @@ defmodule RabbitMQCtlTest do test "short node name without the host part connects properly" do command = ["status", "-n", "rabbit"] - capture_io(:stderr, fn -> error_check(command, exit_ok()) end) + capture_io(:stdio, fn -> error_check(command, exit_ok()) end) end test "a non-existent command results in help message displayed" do From dab2a2575cb5a246df49e07e6e34196148ddd0d5 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Wed, 4 Dec 2024 11:19:55 -0500 Subject: [PATCH 4/5] CLI: Compile and test with --warnings-as-errors (cherry picked from commit 430cd2f57837d4b6f45caf4136d21466bae791cf) --- deps/rabbitmq_cli/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps/rabbitmq_cli/Makefile b/deps/rabbitmq_cli/Makefile index c02761053edf..d32cc0b8c948 100644 --- a/deps/rabbitmq_cli/Makefile +++ b/deps/rabbitmq_cli/Makefile @@ -17,7 +17,7 @@ VERBOSE_TEST ?= true MAX_CASES ?= 1 MIX_TEST_OPTS ?= "" -MIX_TEST = ERL_COMPILER_OPTIONS=deterministic mix test --max-cases=$(MAX_CASES) +MIX_TEST = ERL_COMPILER_OPTIONS=deterministic MIX_ENV=test mix do compile --warnings-as-errors, test --max-cases=$(MAX_CASES) --warnings-as-errors ifneq ("",$(MIX_TEST_OPTS)) MIX_TEST := $(MIX_TEST) $(MIX_TEST_OPTS) From 7ca679d2d65ff025afbc1b1fb06e03860da092d0 Mon Sep 17 00:00:00 2001 From: Michael Klishin Date: Wed, 4 Dec 2024 13:44:29 -0500 Subject: [PATCH 5/5] CLI: test/diagnostics cosmetics #12894 (cherry picked from commit 9b6ab77f8795da0d2ccf117dc55ad6ecabca7d8d) --- .../check_if_any_deprecated_features_are_used_command_test.exs | 1 - ...f_cluster_has_classic_queue_mirroring_policy_command_test.exs | 1 - 2 files changed, 2 deletions(-) diff --git a/deps/rabbitmq_cli/test/diagnostics/check_if_any_deprecated_features_are_used_command_test.exs b/deps/rabbitmq_cli/test/diagnostics/check_if_any_deprecated_features_are_used_command_test.exs index b7cb27683e08..221f733a1c29 100644 --- a/deps/rabbitmq_cli/test/diagnostics/check_if_any_deprecated_features_are_used_command_test.exs +++ b/deps/rabbitmq_cli/test/diagnostics/check_if_any_deprecated_features_are_used_command_test.exs @@ -10,7 +10,6 @@ defmodule CheckIfAnyDeprecatedFeaturesAreUsedCommandTest do @command RabbitMQ.CLI.Diagnostics.Commands.CheckIfAnyDeprecatedFeaturesAreUsedCommand @policy_name "cmq-policy-8373" - # @policy_value "{\"ha-mode\":\"all\"}" setup_all do RabbitMQ.CLI.Core.Distribution.start() diff --git a/deps/rabbitmq_cli/test/diagnostics/check_if_cluster_has_classic_queue_mirroring_policy_command_test.exs b/deps/rabbitmq_cli/test/diagnostics/check_if_cluster_has_classic_queue_mirroring_policy_command_test.exs index b5b3e95d9dbf..d92a9fda4e0d 100644 --- a/deps/rabbitmq_cli/test/diagnostics/check_if_cluster_has_classic_queue_mirroring_policy_command_test.exs +++ b/deps/rabbitmq_cli/test/diagnostics/check_if_cluster_has_classic_queue_mirroring_policy_command_test.exs @@ -10,7 +10,6 @@ defmodule CheckIfClusterHasClassicQueueMirroringPolicyCommandTest do @command RabbitMQ.CLI.Diagnostics.Commands.CheckIfClusterHasClassicQueueMirroringPolicyCommand @policy_name "cmq-policy-8373" - # @policy_value "{\"ha-mode\":\"all\"}" setup_all do RabbitMQ.CLI.Core.Distribution.start()