Skip to content

Commit d4e3544

Browse files
Merge pull request #6300 from rabbitmq/mergify/bp/v3.10.x/pr-6297
CLI: improve isolation of set_disk_free_limit tests (backport #6295) (backport #6297)
2 parents 3db1cc5 + 8dfab86 commit d4e3544

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

deps/rabbitmq_cli/lib/rabbitmq/cli/formatters/formatter_helpers.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
defmodule RabbitMQ.CLI.Formatters.FormatterHelpers do
88
import RabbitCommon.Records
9-
use Bitwise
9+
import Bitwise
1010

1111
@type error :: {:error, term()} | {:error, integer(), String.t() | [String.t()]}
1212

deps/rabbitmq_cli/test/ctl/set_disk_free_limit_command_test.exs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,34 +102,53 @@ defmodule SetDiskFreeLimitCommandTest do
102102

103103
@tag limit: 2_097_152
104104
test "run: a valid integer input returns an ok and sets the disk free limit", context do
105+
set_disk_free_limit(@default_limit)
105106
assert @command.run([context[:limit]], context[:opts]) == :ok
107+
Process.sleep(500)
106108
assert status()[:disk_free_limit] === context[:limit]
109+
110+
set_disk_free_limit(@default_limit)
107111
end
108112

109113
@tag limit: 2_097_152.0
110114
test "run: a valid non-fractional float input returns an ok and sets the disk free limit",
111115
context do
116+
set_disk_free_limit(@default_limit)
112117
assert @command.run([context[:limit]], context[:opts]) == :ok
118+
Process.sleep(500)
113119
assert status()[:disk_free_limit] === round(context[:limit])
120+
121+
set_disk_free_limit(@default_limit)
114122
end
115123

116124
@tag limit: 2_097_152.9
117125
test "run: a valid fractional float input returns an ok and sets the disk free limit",
118126
context do
127+
set_disk_free_limit(@default_limit)
119128
assert @command.run([context[:limit]], context[:opts]) == :ok
129+
Process.sleep(500)
120130
assert status()[:disk_free_limit] === context[:limit] |> Float.floor() |> round
131+
132+
set_disk_free_limit(@default_limit)
121133
end
122134

123135
@tag limit: "2097152"
124136
test "run: an integer string input returns an ok and sets the disk free limit", context do
137+
set_disk_free_limit(@default_limit)
125138
assert @command.run([context[:limit]], context[:opts]) == :ok
139+
Process.sleep(500)
126140
assert status()[:disk_free_limit] === String.to_integer(context[:limit])
141+
142+
set_disk_free_limit(@default_limit)
127143
end
128144

129145
@tag limit: "2MB"
130146
test "run: an valid unit string input returns an ok and changes the limit", context do
131147
assert @command.run([context[:limit]], context[:opts]) == :ok
148+
Process.sleep(500)
132149
assert status()[:disk_free_limit] === 2_000_000
150+
151+
set_disk_free_limit(@default_limit)
133152
end
134153

135154
## ------------------------ run relative command -------------------------------------------

0 commit comments

Comments
 (0)