rabbitmq-queues: add --errors-only to grow command

For consistency with shrink

[#162782801]
This commit is contained in:
kjnilsson 2019-02-20 17:28:26 +00:00
parent 049717aa2f
commit a56f9cae61
2 changed files with 18 additions and 7 deletions

View File

@ -19,13 +19,15 @@ defmodule RabbitMQ.CLI.Queues.Commands.GrowCommand do
@behaviour RabbitMQ.CLI.CommandBehaviour
defp default_opts, do: %{vhost_pattern: ".*",
queue_pattern: ".*"}
queue_pattern: ".*",
errors_only: false}
def switches(),
do: [
vhost_pattern: :string,
queue_pattern: :string
]
vhost_pattern: :string,
queue_pattern: :string,
errors_only: :boolean
]
def merge_defaults(args, opts) do
{args, Map.merge(default_opts(), opts)}
@ -52,7 +54,8 @@ defmodule RabbitMQ.CLI.Queues.Commands.GrowCommand do
def run([node, strategy],
%{node: node_name,
vhost_pattern: vhost_pat,
queue_pattern: queue_pat}) do
queue_pattern: queue_pat,
errors_only: errors_only}) do
case :rabbit_misc.rpc_call(node_name, :rabbit_quorum_queue, :grow, [
to_atom(node),
vhost_pat,
@ -60,6 +63,12 @@ defmodule RabbitMQ.CLI.Queues.Commands.GrowCommand do
to_atom(strategy)]) do
{:error, _} = error -> error;
{:badrpc, _} = error -> error;
results when errors_only ->
for {{:resource, vhost, _kind, name}, {:errors, _, _} = res} <- results,
do: [{:vhost, vhost},
{:name, name},
{:size, format_size res},
{:result, format_result res}]
results ->
for {{:resource, vhost, _kind, name}, res} <- results,
do: [{:vhost, vhost},

View File

@ -30,14 +30,16 @@ defmodule RabbitMQ.CLI.Queues.Commands.GrowCommandTest do
node: get_rabbit_hostname(),
timeout: context[:test_timeout] || 30000,
vhost_pattern: ".*",
queue_pattern: ".*"
queue_pattern: ".*",
errors_only: false
}}
end
test "merge_defaults: defaults to reporting complete results" do
assert @command.merge_defaults([], %{}) ==
{[], %{vhost_pattern: ".*",
queue_pattern: ".*"}}
queue_pattern: ".*",
errors_only: false}}
end
test "validate: when no arguments are provided, returns a failure" do