@@ -26,6 +26,12 @@ defmodule SetDiskFreeLimitCommandTest do
26
26
# silences warnings
27
27
context [ :tag ]
28
28
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
+ )
29
35
30
36
{ :ok , opts: % { node: get_rabbit_hostname ( ) } }
31
37
end
@@ -104,8 +110,12 @@ defmodule SetDiskFreeLimitCommandTest do
104
110
test "run: a valid integer input returns an ok and sets the disk free limit" , context do
105
111
set_disk_free_limit ( @ default_limit )
106
112
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
+ )
109
119
110
120
set_disk_free_limit ( @ default_limit )
111
121
end
@@ -115,8 +125,12 @@ defmodule SetDiskFreeLimitCommandTest do
115
125
context do
116
126
set_disk_free_limit ( @ default_limit )
117
127
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
+ )
120
134
121
135
set_disk_free_limit ( @ default_limit )
122
136
end
@@ -126,8 +140,12 @@ defmodule SetDiskFreeLimitCommandTest do
126
140
context do
127
141
set_disk_free_limit ( @ default_limit )
128
142
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
+ )
131
149
132
150
set_disk_free_limit ( @ default_limit )
133
151
end
@@ -136,17 +154,25 @@ defmodule SetDiskFreeLimitCommandTest do
136
154
test "run: an integer string input returns an ok and sets the disk free limit" , context do
137
155
set_disk_free_limit ( @ default_limit )
138
156
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
+ )
141
163
142
164
set_disk_free_limit ( @ default_limit )
143
165
end
144
166
145
167
@ tag limit: "2MB"
146
168
test "run: an valid unit string input returns an ok and changes the limit" , context do
147
169
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
+ )
150
176
151
177
set_disk_free_limit ( @ default_limit )
152
178
end
0 commit comments