Skip to content

Commit

Permalink
Merge pull request #12676 from rabbitmq/mergify/bp/v3.13.x/pr-12672
Browse files Browse the repository at this point in the history
Fixes for test flakes (backport #12671) (backport #12672)
  • Loading branch information
michaelklishin authored Nov 6, 2024
2 parents b921008 + 4d985e2 commit 759b730
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 11 deletions.
46 changes: 36 additions & 10 deletions deps/rabbitmq_cli/test/ctl/set_disk_free_limit_command_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ defmodule SetDiskFreeLimitCommandTest do
# silences warnings
context[:tag]
on_exit([], fn -> set_disk_free_limit(@default_limit) end)
:rabbit_misc.rpc_call(
get_rabbit_hostname(),
:rabbit_disk_monitor,
:set_enabled,
[:true]
)

{:ok, opts: %{node: get_rabbit_hostname()}}
end
Expand Down Expand Up @@ -104,8 +110,12 @@ defmodule SetDiskFreeLimitCommandTest do
test "run: a valid integer input returns an ok and sets the disk free limit", context do
set_disk_free_limit(@default_limit)
assert @command.run([context[:limit]], context[:opts]) == :ok
Process.sleep(500)
assert status()[:disk_free_limit] === context[:limit]
await_condition(
fn ->
status()[:disk_free_limit] === context[:limit]
end,
30000
)

set_disk_free_limit(@default_limit)
end
Expand All @@ -115,8 +125,12 @@ defmodule SetDiskFreeLimitCommandTest do
context do
set_disk_free_limit(@default_limit)
assert @command.run([context[:limit]], context[:opts]) == :ok
Process.sleep(500)
assert status()[:disk_free_limit] === round(context[:limit])
await_condition(
fn ->
status()[:disk_free_limit] === round(context[:limit])
end,
30000
)

set_disk_free_limit(@default_limit)
end
Expand All @@ -126,8 +140,12 @@ defmodule SetDiskFreeLimitCommandTest do
context do
set_disk_free_limit(@default_limit)
assert @command.run([context[:limit]], context[:opts]) == :ok
Process.sleep(500)
assert status()[:disk_free_limit] === context[:limit] |> Float.floor() |> round
await_condition(
fn ->
status()[:disk_free_limit] === context[:limit] |> Float.floor() |> round
end,
30000
)

set_disk_free_limit(@default_limit)
end
Expand All @@ -136,17 +154,25 @@ defmodule SetDiskFreeLimitCommandTest do
test "run: an integer string input returns an ok and sets the disk free limit", context do
set_disk_free_limit(@default_limit)
assert @command.run([context[:limit]], context[:opts]) == :ok
Process.sleep(500)
assert status()[:disk_free_limit] === String.to_integer(context[:limit])
await_condition(
fn ->
status()[:disk_free_limit] === String.to_integer(context[:limit])
end,
30000
)

set_disk_free_limit(@default_limit)
end

@tag limit: "2MB"
test "run: an valid unit string input returns an ok and changes the limit", context do
assert @command.run([context[:limit]], context[:opts]) == :ok
Process.sleep(500)
assert status()[:disk_free_limit] === 2_000_000
await_condition(
fn ->
status()[:disk_free_limit] === 2_000_000
end,
30000
)

set_disk_free_limit(@default_limit)
end
Expand Down
6 changes: 5 additions & 1 deletion deps/rabbitmq_management/test/clustering_prop_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ groups() ->
]}
].

-define(COLLECT_INTERVAL, 500).

%% -------------------------------------------------------------------
%% Testsuite setup/teardown.
%% -------------------------------------------------------------------
Expand All @@ -42,7 +44,9 @@ merge_app_env(Config) ->
Config1 = rabbit_ct_helpers:merge_app_env(Config,
{rabbit, [
{collect_statistics, fine},
{collect_statistics_interval, 500}
{collect_statistics_interval,
?COLLECT_INTERVAL},
{core_metrics_gc_interval, 1000}
]}),
rabbit_ct_helpers:merge_app_env(Config1,
{rabbitmq_management, [
Expand Down

0 comments on commit 759b730

Please sign in to comment.