Skip to content

Commit ecc6481

Browse files
authored
Merge pull request #12882 from rabbitmq/mergify/bp/v4.0.x/pr-12870
rabbitmq_cli: Prepare tests to run against a node with Khepri enabled by default (backport #12870)
2 parents 4feb741 + 93b38fa commit ecc6481

File tree

5 files changed

+47
-17
lines changed

5 files changed

+47
-17
lines changed

deps/rabbitmq_cli/test/ctl/change_cluster_node_type_command_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ defmodule ChangeClusterNodeTypeCommandTest do
6464
case :rabbit_misc.rpc_call(node, :rabbit_khepri, :is_enabled, []) do
6565
true ->
6666
assert match?(
67-
:ok,
67+
{:error, _},
6868
@command.run(["ram"], context[:opts])
6969
)
7070

deps/rabbitmq_cli/test/ctl/force_boot_command_test.exs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,21 @@ defmodule ForceBootCommandTest do
3737
end
3838

3939
test "run: sets a force boot marker file on target node", context do
40-
stop_rabbitmq_app()
41-
on_exit(fn -> start_rabbitmq_app() end)
42-
assert @command.run([], context[:opts]) == :ok
43-
data_dir = :rpc.call(get_rabbit_hostname(), :rabbit, :data_dir, [])
44-
45-
path = Path.join(data_dir, "force_load")
46-
assert File.exists?(path)
47-
File.rm(path)
40+
node = get_rabbit_hostname()
41+
case :rabbit_misc.rpc_call(node, :rabbit_khepri, :is_enabled, []) do
42+
true ->
43+
:ok
44+
45+
false ->
46+
stop_rabbitmq_app()
47+
on_exit(fn -> start_rabbitmq_app() end)
48+
assert @command.run([], context[:opts]) == :ok
49+
data_dir = :rpc.call(node, :rabbit, :data_dir, [])
50+
51+
path = Path.join(data_dir, "force_load")
52+
assert File.exists?(path)
53+
File.rm(path)
54+
end
4855
end
4956

5057
test "run: if RABBITMQ_MNESIA_DIR is defined, creates a force boot marker file" do

deps/rabbitmq_cli/test/ctl/force_reset_command_test.exs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,15 @@ defmodule ForceResetCommandTest do
4444
test "run: reset request to an active node with a running rabbit app fails", context do
4545
add_vhost("some_vhost")
4646
assert vhost_exists?("some_vhost")
47-
assert match?({:error, :mnesia_unexpectedly_running}, @command.run([], context[:opts]))
47+
node = get_rabbit_hostname()
48+
ret = @command.run([], context[:opts])
49+
case :rabbit_misc.rpc_call(node, :rabbit_khepri, :is_enabled, []) do
50+
true ->
51+
assert match?({:error, :rabbitmq_unexpectedly_running}, ret)
52+
53+
false ->
54+
assert match?({:error, :mnesia_unexpectedly_running}, ret)
55+
end
4856
assert vhost_exists?("some_vhost")
4957
end
5058

deps/rabbitmq_cli/test/ctl/reset_command_test.exs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,15 @@ defmodule ResetCommandTest do
4444
test "run: reset request to an active node with a running rabbit app fails", context do
4545
add_vhost("some_vhost")
4646
assert vhost_exists?("some_vhost")
47-
assert match?({:error, :mnesia_unexpectedly_running}, @command.run([], context[:opts]))
47+
node = get_rabbit_hostname()
48+
ret = @command.run([], context[:opts])
49+
case :rabbit_misc.rpc_call(node, :rabbit_khepri, :is_enabled, []) do
50+
true ->
51+
assert match?({:error, :rabbitmq_unexpectedly_running}, ret)
52+
53+
false ->
54+
assert match?({:error, :mnesia_unexpectedly_running}, ret)
55+
end
4856
assert vhost_exists?("some_vhost")
4957
end
5058

deps/rabbitmq_cli/test/diagnostics/schema_info_command_test.exs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,19 @@ defmodule SchemaInfoCommandTest do
6363
end
6464

6565
test "run: can filter info keys", context do
66-
wanted_keys = ~w(name access_mode)
67-
68-
assert match?(
69-
[[name: _, access_mode: _] | _],
70-
run_command_to_list(@command, [wanted_keys, context[:opts]])
71-
)
66+
node = context[:opts][:node]
67+
case :rabbit_misc.rpc_call(node, :rabbit_khepri, :is_enabled, []) do
68+
true ->
69+
:ok
70+
71+
false ->
72+
wanted_keys = ~w(name access_mode)
73+
74+
assert match?(
75+
[[name: _, access_mode: _] | _],
76+
run_command_to_list(@command, [wanted_keys, context[:opts]])
77+
)
78+
end
7279
end
7380

7481
test "banner" do

0 commit comments

Comments
 (0)