Skip to content

Commit 986a3e4

Browse files
[CloudTest] Make TCP port wait period configurable (#39)
* [CloudTest] Make TCP port wait period configurable * PR feedback * reduce startupDelay on tests * Bump minio_jll
1 parent 88bea58 commit 986a3e4

File tree

3 files changed

+21
-17
lines changed

3 files changed

+21
-17
lines changed

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "CloudBase"
22
uuid = "85eb1798-d7c4-4918-bb13-c944d38e27ed"
33
authors = ["quinnj <[email protected]>"]
4-
version = "1.4.8"
4+
version = "1.4.9"
55

66
[deps]
77
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
@@ -31,7 +31,7 @@ SHA = "0, 1, 2"
3131
URIs = "1"
3232
azurite_jll = "3"
3333
julia = "1.6"
34-
minio_jll = "1"
34+
minio_jll = "2"
3535

3636
[extras]
3737
JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1"

src/CloudTest.jl

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ using minio_jll
136136
import ..Config, ..findOpenPorts, ...AWS, .._cmd, .._wait_for_port
137137

138138
"""
139-
Minio.with(f; dir, bucket, public, startupDelay, debug)
139+
Minio.with(f; dir, bucket, public, startupDelay, debug, waitForPortTimeout)
140140
141141
Starts a minio server on a random open port, and passes a
142142
[`CloudTest.Config`](@ref) to `f`, which contains the credentials
@@ -152,6 +152,7 @@ keyword arguments include:
152152
can be useful on slower systems to allow time for the server
153153
to fully startup
154154
* `debug`: whether to turn on minio debug logging, defaults to `false`
155+
* `waitForPortTimeout`: Time to wait in seconds for the TCP port of Minio to be ready for connections
155156
"""
156157
function with(f; dir=nothing, kw...)
157158
config, proc = run(; dir, kw...)
@@ -198,7 +199,7 @@ publicPolicy(bucket) = """
198199
# use `with`, not `run`! if you `run`, it returns `conf, p`, where `p` is the server process
199200
# note that existing the Julia process *will not* stop the server process, which can easily
200201
# lead to "dangling" server processes. You can `kill(p)` to stop the server process manually
201-
function run(; dir=nothing, bucket=nothing, public=false, startupDelay=0.25, debug=false, bindIP="127.0.0.1")
202+
function run(; dir=nothing, bucket=nothing, public=false, startupDelay=0.25, debug=false, bindIP="127.0.0.1", waitForPortTimeout=30)
202203
if dir === nothing
203204
dir = mktempdir()
204205
elseif !isdir(dir)
@@ -208,8 +209,8 @@ function run(; dir=nothing, bucket=nothing, public=false, startupDelay=0.25, deb
208209
port, cport = ports
209210
cmd = _cmd(`$(minio_jll.minio()) server $dir --address $(bindIP):$(port) --console-address $(bindIP):$(cport)`)
210211
p = debug ? Base.run(cmd, devnull, stderr, stderr; wait=false) : Base.run(cmd; wait=false)
211-
# Wait for the port to be open for up to 10 seconds
212-
_wait_for_port("127.0.0.1", port, 10)
212+
# Wait for the port to be open
213+
_wait_for_port("127.0.0.1", port, waitForPortTimeout)
213214
return p, port
214215
end
215216
credentials = AWS.Credentials("minioadmin", "minioadmin")
@@ -243,7 +244,7 @@ using NodeJS_16_jll, azurite_jll, Dates
243244
import ..Config, ..findOpenPorts, ...Azure, .._cmd, .._wait_for_port
244245

245246
"""
246-
Azurite.with(f; dir, bucket, public, startupDelay, debug)
247+
Azurite.with(f; dir, bucket, public, startupDelay, debug, waitForPortTimeout)
247248
248249
Starts an azurite server on a random open port, and passes a
249250
[`CloudTest.Config`](@ref) to `f`, which contains the credentials
@@ -259,6 +260,7 @@ keyword arguments include:
259260
can be useful on slower systems to allow time for the server
260261
to fully startup
261262
* `debug`: whether to turn on minio debug logging, defaults to `false`
263+
* `waitForPortTimeout`: Time to wait in seconds for the TCP port of Azurite to be ready for connections
262264
"""
263265
function with(f; dir=nothing, debug::Bool=false, debugLog::Union{Nothing, Ref{String}}=nothing, kw...)
264266
config, proc = run(; dir, debug, kw...)
@@ -307,7 +309,7 @@ publicPolicy() = """
307309
# use `with`, not `run`! if you `run`, it returns `conf, p`, where `p` is the server process
308310
# note that existing the Julia process *will not* stop the server process, which can easily
309311
# lead to "dangling" server processes. You can `kill(p)` to stop the server process manually
310-
function run(; dir=nothing, container=nothing, public=false, startupDelay=3, debug=false, use_ssl=true, skipApiVersionCheck=false)
312+
function run(; dir=nothing, container=nothing, public=false, startupDelay=0.5, debug=false, use_ssl=true, skipApiVersionCheck=false, waitForPortTimeout=30)
311313
if dir === nothing
312314
dir = mktempdir()
313315
elseif !isdir(dir)
@@ -325,8 +327,8 @@ function run(; dir=nothing, container=nothing, public=false, startupDelay=3, deb
325327
skipApiVersionCheck && push!(cmd_args, "--skipApiVersionCheck")
326328
cmd = _cmd(`$(node()) $(azurite) $(cmd_args)`)
327329
p = debug ? Base.run(cmd, devnull, stderr, stderr; wait=false) : Base.run(cmd; wait=false)
328-
# Wait for the port to be open for up to 10 seconds
329-
_wait_for_port("127.0.0.1", port, 10)
330+
# Wait for the port to be open
331+
_wait_for_port("127.0.0.1", port, waitForPortTimeout)
330332
return p, port
331333
end
332334
acct = "devstoreaccount1"
@@ -335,6 +337,8 @@ function run(; dir=nothing, container=nothing, public=false, startupDelay=3, deb
335337
key = "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="
336338
credentials = Azure.Credentials(acct, key)
337339
headers = public ? ["x-ms-blob-public-access" => "container"] : []
340+
# Small delay to ensure the HTTP server is ready even though the TCP port is open
341+
sleep(startupDelay)
338342
resp = Azure.put("$(cont.baseurl)?restype=container", headers; credentials, status_exception=false)
339343
if resp.status != 201
340344
@error resp

test/runtests.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ end
3838

3939
@time @testset "AWS" begin
4040
config = Ref{Any}()
41-
Minio.with(bindIP="127.0.0.1", startupDelay=3) do conf
41+
Minio.with(bindIP="127.0.0.1", startupDelay=0.5, waitForPortTimeout=10) do conf
4242
config[] = conf
4343
credentials, bucket = conf
4444
csv = "a,b,c\n1,2,3\n4,5,$(rand())"
@@ -49,7 +49,7 @@ end
4949
@test !isdir(config[].dir)
5050
@test success(config[].process)
5151
# test public access
52-
Minio.with(bindIP="127.0.0.1", startupDelay=3, public=true) do conf
52+
Minio.with(bindIP="127.0.0.1", startupDelay=0.5, public=true) do conf
5353
credentials, bucket = conf
5454
csv = "a,b,c\n1,2,3\n4,5,$(rand())"
5555
AWS.put("$(bucket.baseurl)test.csv", [], csv; service="s3")
@@ -67,7 +67,7 @@ end
6767
if !x32bit
6868
@time @testset "Azure" begin
6969
config = Ref{Any}()
70-
Azurite.with(startupDelay=3) do conf
70+
Azurite.with(startupDelay=0.5, waitForPortTimeout=10) do conf
7171
config[] = conf
7272
credentials, container = conf
7373
csv = "a,b,c\n1,2,3\n4,5,$(rand())"
@@ -97,7 +97,7 @@ if !x32bit
9797
@test !isdir(config[].dir)
9898
@test success(config[].process)
9999
# test public access
100-
Azurite.with(startupDelay=3, public=true) do conf
100+
Azurite.with(startupDelay=0.5, public=true) do conf
101101
credentials, container = conf
102102
csv = "a,b,c\n1,2,3\n4,5,$(rand())"
103103
# have to supply credentials for put since "public" is only for get
@@ -117,7 +117,7 @@ end
117117
mconfigs = Vector{Any}(undef, 10)
118118
aconfigs = Vector{Any}(undef, 10)
119119
@sync for i = 1:10
120-
@async Minio.with(bindIP="127.0.0.1", startupDelay=3) do conf
120+
@async Minio.with(bindIP="127.0.0.1", startupDelay=0.5) do conf
121121
mconfigs[i] = conf
122122
credentials, bucket = conf
123123
csv = "a,b,c\n1,2,3\n4,5,$(rand())"
@@ -126,7 +126,7 @@ end
126126
@test String(resp.body) == csv
127127
end
128128
if !x32bit
129-
@async Azurite.with(startupDelay=3) do conf
129+
@async Azurite.with(startupDelay=0.5) do conf
130130
aconfigs[i] = conf
131131
credentials, container = conf
132132
csv = "a,b,c\n1,2,3\n4,5,$(rand())"
@@ -212,7 +212,7 @@ end
212212

213213
# metrics hooks
214214
@time @testset "Cloud metrics hooks" begin
215-
Minio.with(bindIP="127.0.0.1", startupDelay=3) do conf
215+
Minio.with(bindIP="127.0.0.1", startupDelay=0.5) do conf
216216
credentials, bucket = conf
217217
prereq_ref = Ref(0)
218218
metrics_ref = Ref{Any}()

0 commit comments

Comments
 (0)