Skip to content

Commit 759b730

Browse files
Merge pull request #12676 from rabbitmq/mergify/bp/v3.13.x/pr-12672
Fixes for test flakes (backport #12671) (backport #12672)
2 parents b921008 + 4d985e2 commit 759b730

File tree

2 files changed

+41
-11
lines changed

2 files changed

+41
-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

+5-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ groups() ->
3434
]}
3535
].
3636

37+
-define(COLLECT_INTERVAL, 500).
38+
3739
%% -------------------------------------------------------------------
3840
%% Testsuite setup/teardown.
3941
%% -------------------------------------------------------------------
@@ -42,7 +44,9 @@ merge_app_env(Config) ->
4244
Config1 = rabbit_ct_helpers:merge_app_env(Config,
4345
{rabbit, [
4446
{collect_statistics, fine},
45-
{collect_statistics_interval, 500}
47+
{collect_statistics_interval,
48+
?COLLECT_INTERVAL},
49+
{core_metrics_gc_interval, 1000}
4650
]}),
4751
rabbit_ct_helpers:merge_app_env(Config1,
4852
{rabbitmq_management, [

0 commit comments

Comments
 (0)