Skip to content

Commit 8113155

Browse files
authored
Test the "timeout" error path
1 parent cdb3a9e commit 8113155

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

test/error_path_manager_timeout.jl

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
mktempdir() do tmpdir
2+
fake_bindir = joinpath(tmpdir, "bin")
3+
fake_srun = joinpath(tmpdir, "bin", "srun")
4+
mkpath(fake_bindir)
5+
open(fake_srun, "w") do io
6+
println(io, "#!/usr/bin/env bash")
7+
println(io, "set -euf -o pipefail")
8+
# println(io, "set -x")
9+
println(io, "echo [stdout] fake-srun: sleeping for 15 seconds...")
10+
println(io, "echo [stderr] fake-srun: sleeping for 15 seconds... >&2")
11+
println(io, "sleep 15") # Bash sleep for 15-seconds
12+
println(io, "echo [stdout] fake-srun: INTENTIONALLY ERROR-ING")
13+
println(io, "echo [stderr] fake-srun: INTENTIONALLY ERROR-ING >&2")
14+
println(io, "exit 1")
15+
end
16+
chmod(fake_srun, 0o700) # chmod +x
17+
directory_separator = Sys.iswindows() ? ';' : ':'
18+
new_env = Dict{String, String}()
19+
new_env["SLURM_NTASKS"] = "8"
20+
new_env["SLURM_JOB_ID"] = "1234"
21+
if haskey(ENV, "PATH")
22+
old_path = ENV["PATH"]
23+
new_env["PATH"] = fake_bindir * directory_separator * old_path
24+
else
25+
new_env["PATH"] = fake_bindir
26+
end
27+
28+
@info "with old PATH" Sys.which("srun")
29+
withenv(new_env...) do
30+
@info "with new PATH" Sys.which("srun")
31+
# expected_ex = ErrorException("launch_timeout exceeded")
32+
expected_ex = ErrorException("Hello world!")
33+
mgr = SlurmClusterManager.SlurmManager(; launch_timeout = 2.0) # 2.0 seconds
34+
@test_throws expected_ex Distributed.addprocs(mgr)
35+
end
36+
end

0 commit comments

Comments
 (0)