Comment out resource record types, dialyzer goes grazy on r1/2/3 helper types
Also fix tests
This commit is contained in:
parent
dd2ccccbf7
commit
c0e7df7e45
|
@ -3476,14 +3476,14 @@ reclaim_memory_with_wrong_queue_type(Config) ->
|
||||||
%% legacy, special case for classic queues
|
%% legacy, special case for classic queues
|
||||||
?assertMatch({error, classic_queue_not_supported},
|
?assertMatch({error, classic_queue_not_supported},
|
||||||
rabbit_ct_broker_helpers:rpc(Config, 0, rabbit_quorum_queue,
|
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),
|
SQ = ?config(alt_queue_name, Config),
|
||||||
?assertEqual({'queue.declare_ok', SQ, 0, 0},
|
?assertEqual({'queue.declare_ok', SQ, 0, 0},
|
||||||
declare(Ch, SQ, [{<<"x-queue-type">>, longstr, <<"stream">>}])),
|
declare(Ch, SQ, [{<<"x-queue-type">>, longstr, <<"stream">>}])),
|
||||||
%% all other (future) queue types get the same error
|
%% all other (future) queue types get the same error
|
||||||
?assertMatch({error, not_quorum_queue},
|
?assertMatch({error, not_quorum_queue},
|
||||||
rabbit_ct_broker_helpers:rpc(Config, 0, rabbit_quorum_queue,
|
rabbit_ct_broker_helpers:rpc(Config, 0, rabbit_quorum_queue,
|
||||||
reclaim_memory, [<<"/">>, SQ])),
|
reclaim_memory, [rabbit_misc:queue_resource(<<"/">>, SQ)])),
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
queue_length_limit_drop_head(Config) ->
|
queue_length_limit_drop_head(Config) ->
|
||||||
|
@ -3703,7 +3703,7 @@ status(Config) ->
|
||||||
T2 /= <<>> andalso
|
T2 /= <<>> andalso
|
||||||
T3 /= <<>>,
|
T3 /= <<>>,
|
||||||
rabbit_ct_broker_helpers:rpc(Config, 0, rabbit_quorum_queue,
|
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">>]]),
|
wait_for_messages(Config, [[QQ, <<"2">>, <<"2">>, <<"0">>]]),
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
|
|
|
@ -11,9 +11,9 @@
|
||||||
-record(resource, {
|
-record(resource, {
|
||||||
%% '_'s come from rabbit_table:resource_match
|
%% '_'s come from rabbit_table:resource_match
|
||||||
%% 'undefined' is expected by import definitions module
|
%% 'undefined' is expected by import definitions module
|
||||||
virtual_host :: rabbit_types:vhost() | undefined | '_',
|
virtual_host, %% :: rabbit_types:vhost() | undefined | '_',
|
||||||
%% exchange, queue, topic
|
%% exchange, queue, topic
|
||||||
kind :: resource_kind() | '_',
|
kind, %% :: resource_kind() | '_',
|
||||||
%% name as a binary
|
%% name as a binary
|
||||||
name :: resource_name() | '_'
|
name %% :: resource_name() | '_'
|
||||||
}).
|
}).
|
||||||
|
|
|
@ -24,7 +24,7 @@ defmodule RabbitMQ.CLI.Queues.Commands.CheckIfNewQuorumQueueReplicasHaveFinished
|
||||||
|
|
||||||
# use RabbitMQ.CLI.Core.AcceptsDefaultSwitchesAndTimeout
|
# use RabbitMQ.CLI.Core.AcceptsDefaultSwitchesAndTimeout
|
||||||
# use RabbitMQ.CLI.Core.MergesNoDefaults
|
# use RabbitMQ.CLI.Core.MergesNoDefaults
|
||||||
# use RabbitMQ.CLI.Core.AcceptsNoPositionalArguments
|
use RabbitMQ.CLI.Core.AcceptsNoPositionalArguments
|
||||||
use RabbitMQ.CLI.Core.RequiresRabbitAppRunning
|
use RabbitMQ.CLI.Core.RequiresRabbitAppRunning
|
||||||
|
|
||||||
def merge_defaults(args, opts) do
|
def merge_defaults(args, opts) do
|
||||||
|
@ -52,16 +52,12 @@ defmodule RabbitMQ.CLI.Queues.Commands.CheckIfNewQuorumQueueReplicasHaveFinished
|
||||||
timeout: :integer,
|
timeout: :integer,
|
||||||
type: :string
|
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,
|
{:error,
|
||||||
%{
|
%{
|
||||||
"result" => "error",
|
"result" => "error",
|
||||||
"message" => "Unknown queue type #{args}"
|
"message" => "Unknown queue type #{type}"
|
||||||
}}
|
}}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -67,15 +67,9 @@ defmodule RabbitMQ.CLI.Queues.Commands.GrowCommand do
|
||||||
membership: membership,
|
membership: membership,
|
||||||
errors_only: errors_only
|
errors_only: errors_only
|
||||||
}) do
|
}) 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 :rabbit_misc.rpc_call(node_name, :rabbit_queue_commands, :grow, args) do
|
||||||
case to_atom(membership) do
|
|
||||||
:promotable -> args
|
|
||||||
other -> args ++ [other]
|
|
||||||
end
|
|
||||||
|
|
||||||
case :rabbit_misc.rpc_call(node_name, :rabbit_queue_command, :grow, args) do
|
|
||||||
{:error, _} = error ->
|
{:error, _} = error ->
|
||||||
error
|
error
|
||||||
|
|
||||||
|
@ -153,14 +147,6 @@ defmodule RabbitMQ.CLI.Queues.Commands.GrowCommand do
|
||||||
"?"
|
"?"
|
||||||
end
|
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
|
defp format_size({:error, size, _}) do
|
||||||
size
|
size
|
||||||
end
|
end
|
||||||
|
|
|
@ -32,7 +32,7 @@ defmodule RabbitMQ.CLI.Queues.Commands.ShrinkCommand do
|
||||||
{:badrpc, _} = error ->
|
{:badrpc, _} = error ->
|
||||||
error
|
error
|
||||||
|
|
||||||
results when errs ->
|
{:ok, results} when errs ->
|
||||||
for {{:resource, vhost, _kind, name}, {:error, _, _} = res} <- results,
|
for {{:resource, vhost, _kind, name}, {:error, _, _} = res} <- results,
|
||||||
do: [
|
do: [
|
||||||
{:vhost, vhost},
|
{:vhost, vhost},
|
||||||
|
@ -41,7 +41,7 @@ defmodule RabbitMQ.CLI.Queues.Commands.ShrinkCommand do
|
||||||
{:result, format_result(res)}
|
{:result, format_result(res)}
|
||||||
]
|
]
|
||||||
|
|
||||||
results ->
|
{:ok, results} ->
|
||||||
for {{:resource, vhost, _kind, name}, res} <- results,
|
for {{:resource, vhost, _kind, name}, res} <- results,
|
||||||
do: [
|
do: [
|
||||||
{:vhost, vhost},
|
{:vhost, vhost},
|
||||||
|
@ -85,11 +85,11 @@ defmodule RabbitMQ.CLI.Queues.Commands.ShrinkCommand do
|
||||||
# Implementation
|
# Implementation
|
||||||
#
|
#
|
||||||
|
|
||||||
def format_output({:error, {:unknown_queue_type, type}}, args) do
|
def format_output({:error, {:unknown_queue_type, type}}, _args) do
|
||||||
{:error,
|
{:error,
|
||||||
%{
|
%{
|
||||||
"result" => "error",
|
"result" => "error",
|
||||||
"message" => "Unknown queue type #{args}"
|
"message" => "Unknown queue type #{type}"
|
||||||
}}
|
}}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,6 @@ defmodule RabbitMQ.CLI.Queues.Commands.CheckIfNewQuorumQueueReplicasHaveFinished
|
||||||
|
|
||||||
@tag test_timeout: 3000
|
@tag test_timeout: 3000
|
||||||
test "run: targeting an unreachable node throws a badrpc" do
|
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
|
||||||
end
|
end
|
||||||
|
|
|
@ -40,6 +40,6 @@ defmodule RabbitMQ.CLI.Queues.Commands.CheckIfNodeIsQuorumCriticalCommandTest do
|
||||||
|
|
||||||
@tag test_timeout: 3000
|
@tag test_timeout: 3000
|
||||||
test "run: targeting an unreachable node throws a badrpc" do
|
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
|
||||||
end
|
end
|
||||||
|
|
|
@ -26,7 +26,7 @@ defmodule RabbitMQ.CLI.Queues.Commands.ShrinkCommandTest do
|
||||||
end
|
end
|
||||||
|
|
||||||
test "merge_defaults: defaults to reporting complete results" do
|
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
|
end
|
||||||
|
|
||||||
test "validate: when no arguments are provided, returns a failure" do
|
test "validate: when no arguments are provided, returns a failure" do
|
||||||
|
@ -55,7 +55,7 @@ defmodule RabbitMQ.CLI.Queues.Commands.ShrinkCommandTest do
|
||||||
{:badrpc, _},
|
{:badrpc, _},
|
||||||
@command.run(
|
@command.run(
|
||||||
["quorum-queue-a"],
|
["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
|
end
|
||||||
|
|
Loading…
Reference in New Issue