rabbitmq-upgrade: basic tests for post_upgrade, polishing
This commit is contained in:
parent
dc29e5546c
commit
ccc7ebbafc
|
|
@ -17,18 +17,16 @@ defmodule RabbitMQ.CLI.Upgrade.Commands.PostUpgradeCommand do
|
|||
alias RabbitMQ.CLI.Core.DocGuide
|
||||
|
||||
@behaviour RabbitMQ.CLI.CommandBehaviour
|
||||
use RabbitMQ.CLI.DefaultOutput
|
||||
|
||||
use RabbitMQ.CLI.Core.RequiresRabbitAppRunning
|
||||
use RabbitMQ.CLI.Core.MergesNoDefaults
|
||||
use RabbitMQ.CLI.Core.AcceptsNoPositionalArguments
|
||||
|
||||
def run([], %{node: node_name}) do
|
||||
arg = String.to_atom("all")
|
||||
:rabbit_misc.rpc_call(node_name, :rabbit_amqqueue, :rebalance, [arg, ".*", ".*"])
|
||||
:rabbit_misc.rpc_call(node_name, :rabbit_amqqueue, :rebalance, [:all, ".*", ".*"])
|
||||
end
|
||||
|
||||
def formatter(), do: RabbitMQ.CLI.Formatters.PrettyTable
|
||||
use RabbitMQ.CLI.DefaultOutput
|
||||
|
||||
def usage, do: "post_upgrade"
|
||||
|
||||
|
|
@ -40,10 +38,11 @@ defmodule RabbitMQ.CLI.Upgrade.Commands.PostUpgradeCommand do
|
|||
|
||||
def help_section, do: :upgrade
|
||||
|
||||
def description, do: "Post upgrade tasks"
|
||||
def description, do: "Runs post-upgrade tasks"
|
||||
|
||||
def banner([], _) do
|
||||
"Executing post upgrade tasks...\nRebalancing all queues..."
|
||||
"Executing post upgrade tasks...\n" <>
|
||||
"Rebalancing queue masters..."
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -0,0 +1,58 @@
|
|||
## The contents of this file are subject to the Mozilla Public License
|
||||
## Version 1.1 (the "License"); you may not use this file except in
|
||||
## compliance with the License. You may obtain a copy of the License
|
||||
## at https://www.mozilla.org/MPL/
|
||||
##
|
||||
## Software distributed under the License is distributed on an "AS IS"
|
||||
## basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
||||
## the License for the specific language governing rights and
|
||||
## limitations under the License.
|
||||
##
|
||||
## The Original Code is RabbitMQ.
|
||||
##
|
||||
## The Initial Developer of the Original Code is GoPivotal, Inc.
|
||||
## Copyright (c) 2007-2019 Pivotal Software, Inc. All rights reserved.
|
||||
|
||||
|
||||
defmodule PostUpgradeCommandTest do
|
||||
use ExUnit.Case
|
||||
import TestHelper
|
||||
|
||||
@command RabbitMQ.CLI.Upgrade.Commands.PostUpgradeCommand
|
||||
|
||||
setup_all do
|
||||
RabbitMQ.CLI.Core.Distribution.start()
|
||||
|
||||
:ok
|
||||
end
|
||||
|
||||
setup context do
|
||||
{:ok, opts: %{
|
||||
node: get_rabbit_hostname(),
|
||||
timeout: context[:test_timeout] || 5000
|
||||
}}
|
||||
end
|
||||
|
||||
test "merge_defaults: nothing to do" do
|
||||
assert @command.merge_defaults([], %{}) == {[], %{}}
|
||||
end
|
||||
|
||||
test "validate: accepts no positional arguments" do
|
||||
assert @command.validate(["extra-arg"], %{}) == {:validation_failure, :too_many_args}
|
||||
end
|
||||
|
||||
test "validate: succeeds with no positional arguments" do
|
||||
assert @command.validate([], %{}) == :ok
|
||||
end
|
||||
|
||||
@tag test_timeout: 3000
|
||||
test "run: targeting an unreachable node throws a badrpc", context do
|
||||
opts = %{node: :jake@thedog, timeout: 200}
|
||||
assert match?({:badrpc, _}, @command.run([], Map.merge(context[:opts], opts)))
|
||||
end
|
||||
|
||||
test "run: returns the erlang cookie hash", context do
|
||||
assert match?({:ok, _}, @command.run([], context[:opts]))
|
||||
end
|
||||
|
||||
end
|
||||
Loading…
Reference in New Issue