Update tests

This commit is contained in:
Michael Klishin 2023-01-12 15:54:16 -06:00 committed by Luke Bakken
parent 9d69a4b325
commit c3c4665970
No known key found for this signature in database
GPG Key ID: D99DE30E43EAE440
1 changed files with 6 additions and 4 deletions

View File

@ -20,12 +20,13 @@ defmodule CheckPortConnectivityCommandTest do
{:ok,
opts: %{
node: get_rabbit_hostname(),
address: nil,
timeout: context[:test_timeout] || 30000
}}
end
test "merge_defaults: provides a default timeout" do
assert @command.merge_defaults([], %{}) == {[], %{timeout: 30000}}
assert @command.merge_defaults([], %{}) == {[], %{address: nil, timeout: 30000}}
end
test "validate: treats positional arguments as a failure" do
@ -40,11 +41,12 @@ defmodule CheckPortConnectivityCommandTest do
test "run: targeting an unreachable node throws a badrpc", context do
assert match?(
{:badrpc, _},
@command.run([], Map.merge(context[:opts], %{node: :jake@thedog}))
@command.run([], Map.merge(context[:opts], %{node: :jake@thedog, address: nil}))
)
end
test "run: tries to connect to every inferred active listener", context do
test "run: without --address tries to connect to every inferred active listener using hostname resolution",
context do
assert match?({true, _}, @command.run([], context[:opts]))
end
@ -53,7 +55,7 @@ defmodule CheckPortConnectivityCommandTest do
end
# note: it's run/2 that filters out non-local alarms
test "output: when target node has a local alarm in effect, returns a failure", context do
test "output: when check failed to connect to a port, returns a failure", context do
failure =
{:listener, :rabbit@mercurio, :lolz, 'mercurio', {0, 0, 0, 0, 0, 0, 0, 0}, 7_761_613,
[backlog: 128, nodelay: true]}