Skip to content

Commit 063b260

Browse files
committed
cli
1 parent a916451 commit 063b260

File tree

4 files changed

+33
-10
lines changed

4 files changed

+33
-10
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/diagnostics/schema_info_command_test.exs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,30 +21,35 @@ defmodule SchemaInfoCommandTest do
2121
}
2222
end
2323

24+
@tag :mnesia
2425
test "merge_defaults: adds all keys if none specificed", context do
2526
default_keys = ~w(name cookie active_replicas user_properties)
2627

2728
{keys, _} = @command.merge_defaults([], context[:opts])
2829
assert default_keys == keys
2930
end
3031

32+
@tag :mnesia
3133
test "merge_defaults: includes table headers by default", _context do
3234
{_, opts} = @command.merge_defaults([], %{})
3335
assert opts[:table_headers]
3436
end
3537

38+
@tag :mnesia
3639
test "validate: returns bad_info_key on a single bad arg", context do
3740
assert @command.validate(["quack"], context[:opts]) ==
3841
{:validation_failure, {:bad_info_key, [:quack]}}
3942
end
4043

44+
@tag :mnesia
4145
test "validate: returns multiple bad args return a list of bad info key values", context do
4246
result = @command.validate(["quack", "oink"], context[:opts])
4347
assert match?({:validation_failure, {:bad_info_key, _}}, result)
4448
{_, {_, keys}} = result
4549
assert :lists.sort(keys) == [:oink, :quack]
4650
end
4751

52+
@tag :mnesia
4853
test "validate: return bad_info_key on mix of good and bad args", context do
4954
assert @command.validate(["quack", "cookie"], context[:opts]) ==
5055
{:validation_failure, {:bad_info_key, [:quack]}}
@@ -56,12 +61,14 @@ defmodule SchemaInfoCommandTest do
5661
{:validation_failure, {:bad_info_key, [:oink]}}
5762
end
5863

64+
@tag :mnesia
5965
@tag test_timeout: 0
6066
test "run: timeout causes command to return badrpc", context do
6167
assert run_command_to_list(@command, [["source_name"], context[:opts]]) ==
6268
{:badrpc, :timeout}
6369
end
6470

71+
@tag :mnesia
6572
test "run: can filter info keys", context do
6673
wanted_keys = ~w(name access_mode)
6774

@@ -71,6 +78,7 @@ defmodule SchemaInfoCommandTest do
7178
)
7279
end
7380

81+
@tag :mnesia
7482
test "banner" do
7583
assert String.starts_with?(@command.banner([], %{node: "node@node"}), "Asking node")
7684
end

0 commit comments

Comments
 (0)