Comment out resource record types, dialyzer goes grazy on r1/2/3 helper types

Also fix tests
This commit is contained in:
Iliia Khaprov 2025-06-24 23:24:32 +02:00
parent dd2ccccbf7
commit c0e7df7e45
No known key found for this signature in database
GPG Key ID: 4DCFF8F358E49AED
8 changed files with 19 additions and 37 deletions

View File

@ -3476,14 +3476,14 @@ reclaim_memory_with_wrong_queue_type(Config) ->
%% legacy, special case for classic queues
?assertMatch({error, classic_queue_not_supported},
rabbit_ct_broker_helpers:rpc(Config, 0, rabbit_quorum_queue,
reclaim_memory, [<<"/">>, CQ])),
reclaim_memory, [rabbit_misc:queue_resource(<<"/">>, CQ)])),
SQ = ?config(alt_queue_name, Config),
?assertEqual({'queue.declare_ok', SQ, 0, 0},
declare(Ch, SQ, [{<<"x-queue-type">>, longstr, <<"stream">>}])),
%% all other (future) queue types get the same error
?assertMatch({error, not_quorum_queue},
rabbit_ct_broker_helpers:rpc(Config, 0, rabbit_quorum_queue,
reclaim_memory, [<<"/">>, SQ])),
reclaim_memory, [rabbit_misc:queue_resource(<<"/">>, SQ)])),
ok.
queue_length_limit_drop_head(Config) ->
@ -3703,7 +3703,7 @@ status(Config) ->
T2 /= <<>> andalso
T3 /= <<>>,
rabbit_ct_broker_helpers:rpc(Config, 0, rabbit_quorum_queue,
status, [<<"/">>, QQ])),
status, [rabbit_misc:queue_resource(<<"/">>, QQ)])),
wait_for_messages(Config, [[QQ, <<"2">>, <<"2">>, <<"0">>]]),
ok.

View File

@ -11,9 +11,9 @@
-record(resource, {
%% '_'s come from rabbit_table:resource_match
%% 'undefined' is expected by import definitions module
virtual_host :: rabbit_types:vhost() | undefined | '_',
virtual_host, %% :: rabbit_types:vhost() | undefined | '_',
%% exchange, queue, topic
kind :: resource_kind() | '_',
kind, %% :: resource_kind() | '_',
%% name as a binary
name :: resource_name() | '_'
name %% :: resource_name() | '_'
}).

View File

@ -24,7 +24,7 @@ defmodule RabbitMQ.CLI.Queues.Commands.CheckIfNewQuorumQueueReplicasHaveFinished
# use RabbitMQ.CLI.Core.AcceptsDefaultSwitchesAndTimeout
# use RabbitMQ.CLI.Core.MergesNoDefaults
# use RabbitMQ.CLI.Core.AcceptsNoPositionalArguments
use RabbitMQ.CLI.Core.AcceptsNoPositionalArguments
use RabbitMQ.CLI.Core.RequiresRabbitAppRunning
def merge_defaults(args, opts) do
@ -53,15 +53,11 @@ defmodule RabbitMQ.CLI.Queues.Commands.CheckIfNewQuorumQueueReplicasHaveFinished
type: :string
]
def validate(_, _) do
:ok
end
def output({:error, {:unknown_queue_type, type}}, args) do
def output({:error, {:unknown_queue_type, type}}, _args) do
{:error,
%{
"result" => "error",
"message" => "Unknown queue type #{args}"
"message" => "Unknown queue type #{type}"
}}
end

View File

@ -67,15 +67,9 @@ defmodule RabbitMQ.CLI.Queues.Commands.GrowCommand do
membership: membership,
errors_only: errors_only
}) do
args = [to_atom(node), vhost_pat, queue_pat, to_atom(strategy)]
args = [to_atom(node), vhost_pat, queue_pat, to_atom(strategy), to_atom(membership)]
args =
case to_atom(membership) do
:promotable -> args
other -> args ++ [other]
end
case :rabbit_misc.rpc_call(node_name, :rabbit_queue_command, :grow, args) do
case :rabbit_misc.rpc_call(node_name, :rabbit_queue_commands, :grow, args) do
{:error, _} = error ->
error
@ -153,14 +147,6 @@ defmodule RabbitMQ.CLI.Queues.Commands.GrowCommand do
"?"
end
def output({:error, :not_found}, %{vhost: vhost, formatter: "json"}) do
{:error,
%{
"result" => "error",
"message" => "Target queue was not found in virtual host '#{vhost}'"
}}
end
defp format_size({:error, size, _}) do
size
end

View File

@ -32,7 +32,7 @@ defmodule RabbitMQ.CLI.Queues.Commands.ShrinkCommand do
{:badrpc, _} = error ->
error
results when errs ->
{:ok, results} when errs ->
for {{:resource, vhost, _kind, name}, {:error, _, _} = res} <- results,
do: [
{:vhost, vhost},
@ -41,7 +41,7 @@ defmodule RabbitMQ.CLI.Queues.Commands.ShrinkCommand do
{:result, format_result(res)}
]
results ->
{:ok, results} ->
for {{:resource, vhost, _kind, name}, res} <- results,
do: [
{:vhost, vhost},
@ -85,11 +85,11 @@ defmodule RabbitMQ.CLI.Queues.Commands.ShrinkCommand do
# Implementation
#
def format_output({:error, {:unknown_queue_type, type}}, args) do
def format_output({:error, {:unknown_queue_type, type}}, _args) do
{:error,
%{
"result" => "error",
"message" => "Unknown queue type #{args}"
"message" => "Unknown queue type #{type}"
}}
end

View File

@ -40,6 +40,6 @@ defmodule RabbitMQ.CLI.Queues.Commands.CheckIfNewQuorumQueueReplicasHaveFinished
@tag test_timeout: 3000
test "run: targeting an unreachable node throws a badrpc" do
assert match?({:badrpc, _}, @command.run([], %{node: :jake@thedog, vhost: "/", timeout: 200}))
assert match?({:badrpc, _}, @command.run([], %{node: :jake@thedog, vhost: "/", timeout: 200, type: "quorum"}))
end
end

View File

@ -40,6 +40,6 @@ defmodule RabbitMQ.CLI.Queues.Commands.CheckIfNodeIsQuorumCriticalCommandTest do
@tag test_timeout: 3000
test "run: targeting an unreachable node throws a badrpc" do
assert match?({:badrpc, _}, @command.run([], %{node: :jake@thedog, vhost: "/", timeout: 200}))
assert match?({:badrpc, _}, @command.run([], %{node: :jake@thedog, vhost: "/", timeout: 200, type: "quorum"}))
end
end

View File

@ -26,7 +26,7 @@ defmodule RabbitMQ.CLI.Queues.Commands.ShrinkCommandTest do
end
test "merge_defaults: defaults to reporting complete results" do
assert @command.merge_defaults([], %{}) == {[], %{errors_only: false}}
assert @command.merge_defaults([], %{}) == {[], %{errors_only: false, type: "quorum"}}
end
test "validate: when no arguments are provided, returns a failure" do
@ -55,7 +55,7 @@ defmodule RabbitMQ.CLI.Queues.Commands.ShrinkCommandTest do
{:badrpc, _},
@command.run(
["quorum-queue-a"],
Map.merge(context[:opts], %{node: :jake@thedog, vhost: "/", timeout: 200})
Map.merge(context[:opts], %{node: :jake@thedog, vhost: "/", timeout: 200, type: "quorum"})
)
)
end