2020-07-12 02:23:07 +08:00
|
|
|
## This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
## License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
## file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
2016-06-02 00:46:12 +08:00
|
|
|
##
|
2020-03-10 22:39:56 +08:00
|
|
|
## Copyright (c) 2007-2020 VMware, Inc. or its affiliates. All rights reserved.
|
2016-06-02 00:46:12 +08:00
|
|
|
|
|
|
|
|
|
|
|
defmodule StartAppCommandTest do
|
|
|
|
use ExUnit.Case, async: false
|
|
|
|
import TestHelper
|
|
|
|
|
2016-06-10 07:54:22 +08:00
|
|
|
@command RabbitMQ.CLI.Ctl.Commands.StartAppCommand
|
2016-06-02 00:46:12 +08:00
|
|
|
|
|
|
|
setup_all do
|
2016-11-15 01:52:08 +08:00
|
|
|
RabbitMQ.CLI.Core.Distribution.start()
|
2017-06-07 23:21:53 +08:00
|
|
|
|
2017-02-28 23:16:54 +08:00
|
|
|
start_rabbitmq_app()
|
2016-06-02 00:46:12 +08:00
|
|
|
|
|
|
|
on_exit([], fn ->
|
2017-02-28 23:16:54 +08:00
|
|
|
start_rabbitmq_app()
|
2016-06-02 00:46:12 +08:00
|
|
|
end)
|
|
|
|
|
|
|
|
:ok
|
|
|
|
end
|
|
|
|
|
|
|
|
setup do
|
2017-01-24 20:33:48 +08:00
|
|
|
{:ok, opts: %{node: get_rabbit_hostname()}}
|
2016-06-02 00:46:12 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
test "validate: with extra arguments returns an arg count error", context do
|
|
|
|
assert @command.validate(["extra"], context[:opts]) == {:validation_failure, :too_many_args}
|
|
|
|
end
|
|
|
|
|
|
|
|
test "run: request to an active node succeeds", context do
|
2019-02-05 23:00:55 +08:00
|
|
|
node = RabbitMQ.CLI.Core.Helpers.normalise_node(context[:node], :shortnames)
|
2017-02-28 23:16:54 +08:00
|
|
|
stop_rabbitmq_app()
|
2016-06-02 00:46:12 +08:00
|
|
|
refute :rabbit_misc.rpc_call(node, :rabbit, :is_running, [])
|
|
|
|
assert @command.run([], context[:opts])
|
|
|
|
assert :rabbit_misc.rpc_call(node, :rabbit, :is_running, [])
|
|
|
|
end
|
|
|
|
|
2019-04-12 06:27:15 +08:00
|
|
|
test "run: request to a non-existent node returns a badrpc" do
|
|
|
|
opts = %{node: :jake@thedog, timeout: 200}
|
|
|
|
assert match?({:badrpc, _}, @command.run([], opts))
|
2016-06-02 00:46:12 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
test "banner", context do
|
2017-01-24 20:33:48 +08:00
|
|
|
assert @command.banner([], context[:opts]) =~ ~r/Starting node #{get_rabbit_hostname()}/
|
2016-06-02 00:46:12 +08:00
|
|
|
end
|
|
|
|
end
|