Skip to content

Commit

Permalink
Merge pull request #12672 from rabbitmq/mergify/bp/v4.0.x/pr-12671
Browse files Browse the repository at this point in the history
Fixes for test flakes (backport #12671)
  • Loading branch information
michaelklishin authored Nov 6, 2024
2 parents 7d44c74 + 4d194b7 commit b21e84e
Show file tree
Hide file tree
Showing 2 changed files with 38 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
3 changes: 2 additions & 1 deletion deps/rabbitmq_management/test/clustering_prop_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ merge_app_env(Config) ->
{rabbit, [
{collect_statistics, fine},
{collect_statistics_interval,
?COLLECT_INTERVAL}
?COLLECT_INTERVAL},
{core_metrics_gc_interval, 1000}
]}),
rabbit_ct_helpers:merge_app_env(Config1,
{rabbitmq_management, [
Expand Down

0 comments on commit b21e84e

Please sign in to comment.