Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test suite: Increase the timeout to 10 minutes; also, allow customizing the timeout with JULIA_SLURMCLUSTERMANAGER_TEST_TIMEOUT_SECONDS #39

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,41 +18,45 @@ end
@testset "SlurmClusterManager.jl" begin
# test that slurm is available
@test !(Sys.which("sinfo") === nothing)

# submit job
# project should point to top level dir so that SlurmClusterManager is available to script.jl
project_path = abspath(joinpath(@__DIR__, ".."))
println("project_path = $project_path")
@info "" project_path
jobid = withenv("JULIA_PROJECT"=>project_path) do
strip(read(`sbatch --export=ALL --parsable -n 4 -o test.out script.jl`, String))
end
println("jobid = $jobid")
@info "" jobid

# get job state from jobid
getjobstate = jobid -> begin
cmd = Cmd(`scontrol show jobid=$jobid`, ignorestatus=true)
info = read(cmd, String)
state = match(r"JobState=(\S*)", info)
return state === nothing ? nothing : state.captures[1]
end

# wait for job to complete
status = timedwait(60.0, pollint=1.0) do
default_timeout_seconds = 600 # 10 minutes
timeout_seconds = parse(Float64, strip(get(ENV, "JULIA_SLURMCLUSTERMANAGER_TEST_TIMEOUT_SECONDS", "$(default_timeout_seconds)")))
pollint = 1.0 # 1 second
status = timedwait(timeout_seconds, pollint=pollint) do
state = getjobstate(jobid)
state == nothing && return false
println("jobstate = $state")
@info "jobstate=$(state)"
return state == "COMPLETED" || state == "FAILED"
end

state = getjobstate(jobid)

# check that job finished running within timelimit (either completed or failed)
@test status == :ok
@test state == "COMPLETED"

# print job output
output = read("test.out", String)
println("script output:")
println("# BEGIN script output")
println(output)
println("# END script output")

end # testset "SlurmClusterManager.jl"
Loading