Skip to content

Commit

Permalink
Merge pull request #12870 from rabbitmq/fixes-to-cli-tests-related-to…
Browse files Browse the repository at this point in the history
…-khepri

rabbitmq_cli: Prepare tests to run against a node with Khepri enabled by default
  • Loading branch information
dumbbell authored Dec 2, 2024
2 parents 16fa401 + 112ff3f commit 658d5b8
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ defmodule ChangeClusterNodeTypeCommandTest do
case :rabbit_misc.rpc_call(node, :rabbit_khepri, :is_enabled, []) do
true ->
assert match?(
:ok,
{:error, _},
@command.run(["ram"], context[:opts])
)

Expand Down
23 changes: 15 additions & 8 deletions deps/rabbitmq_cli/test/ctl/force_boot_command_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,21 @@ defmodule ForceBootCommandTest do
end

test "run: sets a force boot marker file on target node", context do
stop_rabbitmq_app()
on_exit(fn -> start_rabbitmq_app() end)
assert @command.run([], context[:opts]) == :ok
data_dir = :rpc.call(get_rabbit_hostname(), :rabbit, :data_dir, [])

path = Path.join(data_dir, "force_load")
assert File.exists?(path)
File.rm(path)
node = get_rabbit_hostname()
case :rabbit_misc.rpc_call(node, :rabbit_khepri, :is_enabled, []) do
true ->
:ok

false ->
stop_rabbitmq_app()
on_exit(fn -> start_rabbitmq_app() end)
assert @command.run([], context[:opts]) == :ok
data_dir = :rpc.call(node, :rabbit, :data_dir, [])

path = Path.join(data_dir, "force_load")
assert File.exists?(path)
File.rm(path)
end
end

test "run: if RABBITMQ_MNESIA_DIR is defined, creates a force boot marker file" do
Expand Down
10 changes: 9 additions & 1 deletion deps/rabbitmq_cli/test/ctl/force_reset_command_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,15 @@ defmodule ForceResetCommandTest do
test "run: reset request to an active node with a running rabbit app fails", context do
add_vhost("some_vhost")
assert vhost_exists?("some_vhost")
assert match?({:error, :mnesia_unexpectedly_running}, @command.run([], context[:opts]))
node = get_rabbit_hostname()
ret = @command.run([], context[:opts])
case :rabbit_misc.rpc_call(node, :rabbit_khepri, :is_enabled, []) do
true ->
assert match?({:error, :rabbitmq_unexpectedly_running}, ret)

false ->
assert match?({:error, :mnesia_unexpectedly_running}, ret)
end
assert vhost_exists?("some_vhost")
end

Expand Down
10 changes: 9 additions & 1 deletion deps/rabbitmq_cli/test/ctl/reset_command_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,15 @@ defmodule ResetCommandTest do
test "run: reset request to an active node with a running rabbit app fails", context do
add_vhost("some_vhost")
assert vhost_exists?("some_vhost")
assert match?({:error, :mnesia_unexpectedly_running}, @command.run([], context[:opts]))
node = get_rabbit_hostname()
ret = @command.run([], context[:opts])
case :rabbit_misc.rpc_call(node, :rabbit_khepri, :is_enabled, []) do
true ->
assert match?({:error, :rabbitmq_unexpectedly_running}, ret)

false ->
assert match?({:error, :mnesia_unexpectedly_running}, ret)
end
assert vhost_exists?("some_vhost")
end

Expand Down
19 changes: 13 additions & 6 deletions deps/rabbitmq_cli/test/diagnostics/schema_info_command_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,19 @@ defmodule SchemaInfoCommandTest do
end

test "run: can filter info keys", context do
wanted_keys = ~w(name access_mode)

assert match?(
[[name: _, access_mode: _] | _],
run_command_to_list(@command, [wanted_keys, context[:opts]])
)
node = context[:opts][:node]
case :rabbit_misc.rpc_call(node, :rabbit_khepri, :is_enabled, []) do
true ->
:ok

false ->
wanted_keys = ~w(name access_mode)

assert match?(
[[name: _, access_mode: _] | _],
run_command_to_list(@command, [wanted_keys, context[:opts]])
)
end
end

test "banner" do
Expand Down

0 comments on commit 658d5b8

Please sign in to comment.