@@ -136,7 +136,7 @@ using minio_jll
136136import .. 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
141141Starts 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"""
156157function 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
243244import .. 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
248249Starts 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"""
263265function 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
0 commit comments