Skip to content

Commit b21e84e

Browse files
Merge pull request #12672 from rabbitmq/mergify/bp/v4.0.x/pr-12671
Fixes for test flakes (backport #12671)
2 parents 7d44c74 + 4d194b7 commit b21e84e

File tree

2 files changed

+38
-11
lines changed

2 files changed

+38
-11
lines changed

deps/rabbitmq_cli/test/ctl/set_disk_free_limit_command_test.exs

+36-10
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ defmodule SetDiskFreeLimitCommandTest do
2626
# silences warnings
2727
context[:tag]
2828
on_exit([], fn -> set_disk_free_limit(@default_limit) end)
29+
:rabbit_misc.rpc_call(
30+
get_rabbit_hostname(),
31+
:rabbit_disk_monitor,
32+
:set_enabled,
33+
[:true]
34+
)
2935

3036
{:ok, opts: %{node: get_rabbit_hostname()}}
3137
end
@@ -104,8 +110,12 @@ defmodule SetDiskFreeLimitCommandTest do
104110
test "run: a valid integer input returns an ok and sets the disk free limit", context do
105111
set_disk_free_limit(@default_limit)
106112
assert @command.run([context[:limit]], context[:opts]) == :ok
107-
Process.sleep(500)
108-
assert status()[:disk_free_limit] === context[:limit]
113+
await_condition(
114+
fn ->
115+
status()[:disk_free_limit] === context[:limit]
116+
end,
117+
30000
118+
)
109119

110120
set_disk_free_limit(@default_limit)
111121
end
@@ -115,8 +125,12 @@ defmodule SetDiskFreeLimitCommandTest do
115125
context do
116126
set_disk_free_limit(@default_limit)
117127
assert @command.run([context[:limit]], context[:opts]) == :ok
118-
Process.sleep(500)
119-
assert status()[:disk_free_limit] === round(context[:limit])
128+
await_condition(
129+
fn ->
130+
status()[:disk_free_limit] === round(context[:limit])
131+
end,
132+
30000
133+
)
120134

121135
set_disk_free_limit(@default_limit)
122136
end
@@ -126,8 +140,12 @@ defmodule SetDiskFreeLimitCommandTest do
126140
context do
127141
set_disk_free_limit(@default_limit)
128142
assert @command.run([context[:limit]], context[:opts]) == :ok
129-
Process.sleep(500)
130-
assert status()[:disk_free_limit] === context[:limit] |> Float.floor() |> round
143+
await_condition(
144+
fn ->
145+
status()[:disk_free_limit] === context[:limit] |> Float.floor() |> round
146+
end,
147+
30000
148+
)
131149

132150
set_disk_free_limit(@default_limit)
133151
end
@@ -136,17 +154,25 @@ defmodule SetDiskFreeLimitCommandTest do
136154
test "run: an integer string input returns an ok and sets the disk free limit", context do
137155
set_disk_free_limit(@default_limit)
138156
assert @command.run([context[:limit]], context[:opts]) == :ok
139-
Process.sleep(500)
140-
assert status()[:disk_free_limit] === String.to_integer(context[:limit])
157+
await_condition(
158+
fn ->
159+
status()[:disk_free_limit] === String.to_integer(context[:limit])
160+
end,
161+
30000
162+
)
141163

142164
set_disk_free_limit(@default_limit)
143165
end
144166

145167
@tag limit: "2MB"
146168
test "run: an valid unit string input returns an ok and changes the limit", context do
147169
assert @command.run([context[:limit]], context[:opts]) == :ok
148-
Process.sleep(500)
149-
assert status()[:disk_free_limit] === 2_000_000
170+
await_condition(
171+
fn ->
172+
status()[:disk_free_limit] === 2_000_000
173+
end,
174+
30000
175+
)
150176

151177
set_disk_free_limit(@default_limit)
152178
end

deps/rabbitmq_management/test/clustering_prop_SUITE.erl

+2-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ merge_app_env(Config) ->
4646
{rabbit, [
4747
{collect_statistics, fine},
4848
{collect_statistics_interval,
49-
?COLLECT_INTERVAL}
49+
?COLLECT_INTERVAL},
50+
{core_metrics_gc_interval, 1000}
5051
]}),
5152
rabbit_ct_helpers:merge_app_env(Config1,
5253
{rabbitmq_management, [

0 commit comments

Comments
 (0)