Skip to content

Commit 3378ff0

Browse files
committed
Revert QQ grow-to-N in original grow command
1 parent 39776b9 commit 3378ff0

File tree

2 files changed

+5
-64
lines changed

2 files changed

+5
-64
lines changed

deps/rabbitmq_cli/lib/rabbitmq/cli/queues/commands/grow_command.ex

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,7 @@ defmodule RabbitMQ.CLI.Queues.Commands.GrowCommand do
3333
{:validation_failure, :too_many_args}
3434
end
3535

36-
def validate(args = [n, s], opts) do
37-
case Integer.parse(n) do
38-
{cluster_size, _} when is_integer(cluster_size) ->
39-
do_validate([cluster_size, s], opts)
40-
41-
:error ->
42-
do_validate(args, opts)
43-
end
44-
end
45-
46-
def do_validate([_, s], _)
36+
def validate([_, s], _)
4737
when not (s == "all" or
4838
s == "even") do
4939
{:validation_failure, "strategy '#{s}' is not recognised."}
@@ -56,23 +46,15 @@ defmodule RabbitMQ.CLI.Queues.Commands.GrowCommand do
5646
{:validation_failure, "voter status '#{m}' is not recognised."}
5747
end
5848

59-
def do_validate(_, _) do
49+
def validate(_, _) do
6050
:ok
6151
end
6252

6353
def validate_execution_environment(args, opts) do
6454
Validators.chain(
6555
[
6656
&Validators.rabbit_is_running/2,
67-
fn args = [n, _], opts ->
68-
case Integer.parse(n) do
69-
{cluster_size, _} when is_integer(cluster_size) ->
70-
:ok
71-
72-
:error ->
73-
Validators.existing_cluster_member(args, opts)
74-
end
75-
end
57+
&Validators.existing_cluster_member/2
7658
],
7759
[args, opts]
7860
)
@@ -85,7 +67,6 @@ defmodule RabbitMQ.CLI.Queues.Commands.GrowCommand do
8567
membership: membership,
8668
errors_only: errors_only
8769
}) do
88-
8970
args = [to_atom(node), vhost_pat, queue_pat, to_atom(strategy)]
9071

9172
args =
@@ -155,14 +136,8 @@ defmodule RabbitMQ.CLI.Queues.Commands.GrowCommand do
155136
do:
156137
"Grows quorum queue clusters by adding a member (replica) on the specified node for all matching queues"
157138

158-
def banner([node_or_quorum_cluster_size, strategy], %{queue_pattern: queue_pattern}) do
159-
case Integer.parse(node_or_quorum_cluster_size) do
160-
{cluster_size, _} when is_integer(cluster_size) ->
161-
"Growing #{strategy} quorum queues matching '#{queue_pattern}' to a target cluster size of '#{cluster_size}'..."
162-
163-
:error ->
164-
"Growing #{strategy} quorum queues matching '#{queue_pattern}' to #{node_or_quorum_cluster_size}..."
165-
end
139+
def banner([node, strategy], _) do
140+
"Growing #{strategy} quorum queues on #{node}..."
166141
end
167142

168143
#

deps/rabbitmq_cli/test/queues/grow_command_test.exs

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -82,29 +82,6 @@ defmodule RabbitMQ.CLI.Queues.Commands.GrowCommandTest do
8282
{:validation_failure, "voter status 'banana' is not recognised."}
8383
end
8484

85-
test "validate: when target quorum cluster size greater than zero and membership is voter, returns a success" do
86-
assert @command.validate(["7", "all"], %{membership: "voter", queue_pattern: "qq.*"}) == :ok
87-
end
88-
89-
test "validate: when target quorum cluster size greater than zero and membership is promotable, returns a success" do
90-
assert @command.validate(["5", "all"], %{membership: "promotable", queue_pattern: "qq.*"}) == :ok
91-
end
92-
93-
test "validate: when target quorum cluster size is zero, returns failure" do
94-
assert @command.validate(["0", "all"], %{membership: "voter", queue_pattern: "qq.*"}) ==
95-
{:validation_failure, "target quorum cluster size '0' must be greater than 0."}
96-
end
97-
98-
test "validate: when target quorum cluster size is less than zero, returns failure" do
99-
assert @command.validate(["-1", "all"], %{membership: "voter", queue_pattern: "qq.*"}) ==
100-
{:validation_failure, "target quorum cluster size '-1' must be greater than 0."}
101-
end
102-
103-
test "validate: when target quorum cluster size is provided and membership is not voter, returns failure" do
104-
assert @command.validate(["5", "all"], %{membership: "non_voter", queue_pattern: "qq.*"}) ==
105-
{:validation_failure, "voter status 'non_voter' must be 'voter' or 'promotable' to grow to target quorum cluster size '5'."}
106-
end
107-
10885
@tag test_timeout: 3000
10986
test "run: targeting an unreachable node throws a badrpc when growing to a target node", context do
11087
assert match?(
@@ -115,15 +92,4 @@ defmodule RabbitMQ.CLI.Queues.Commands.GrowCommandTest do
11592
)
11693
)
11794
end
118-
119-
@tag test_timeout: 3000
120-
test "run: targeting an unreachable node throws a badrpc when growing to a target quorum cluster size", context do
121-
assert match?(
122-
{:badrpc, _},
123-
@command.run(
124-
["5", "all"],
125-
Map.merge(context[:opts], %{node: :jake@thedog, queue_pattern: "qq.*"})
126-
)
127-
)
128-
end
12995
end

0 commit comments

Comments
 (0)