|
18 | 18 | @testset "SlurmClusterManager.jl" begin
|
19 | 19 | # test that slurm is available
|
20 | 20 | @test !(Sys.which("sinfo") === nothing)
|
21 |
| - |
| 21 | + |
22 | 22 | # submit job
|
23 | 23 | # project should point to top level dir so that SlurmClusterManager is available to script.jl
|
24 | 24 | project_path = abspath(joinpath(@__DIR__, ".."))
|
25 |
| - println("project_path = $project_path") |
| 25 | + @info "" project_path |
26 | 26 | jobid = withenv("JULIA_PROJECT"=>project_path) do
|
27 | 27 | strip(read(`sbatch --export=ALL --parsable -n 4 -o test.out script.jl`, String))
|
28 | 28 | end
|
29 |
| - println("jobid = $jobid") |
30 |
| - |
| 29 | + @info "" jobid |
| 30 | + |
31 | 31 | # get job state from jobid
|
32 | 32 | getjobstate = jobid -> begin
|
33 | 33 | cmd = Cmd(`scontrol show jobid=$jobid`, ignorestatus=true)
|
34 | 34 | info = read(cmd, String)
|
35 | 35 | state = match(r"JobState=(\S*)", info)
|
36 | 36 | return state === nothing ? nothing : state.captures[1]
|
37 | 37 | end
|
38 |
| - |
| 38 | + |
39 | 39 | # wait for job to complete
|
40 | 40 | status = timedwait(60.0, pollint=1.0) do
|
41 | 41 | state = getjobstate(jobid)
|
42 | 42 | state == nothing && return false
|
43 |
| - println("jobstate = $state") |
| 43 | + @info "jobstate=$(state)" |
44 | 44 | return state == "COMPLETED" || state == "FAILED"
|
45 | 45 | end
|
46 |
| - |
| 46 | + |
47 | 47 | state = getjobstate(jobid)
|
48 |
| - |
| 48 | + |
49 | 49 | # check that job finished running within timelimit (either completed or failed)
|
50 | 50 | @test status == :ok
|
51 | 51 | @test state == "COMPLETED"
|
52 |
| - |
| 52 | + |
53 | 53 | # print job output
|
54 | 54 | output = read("test.out", String)
|
55 |
| - println("script output:") |
| 55 | + println("# BEGIN script output") |
56 | 56 | println(output)
|
| 57 | + println("# END script output") |
57 | 58 |
|
58 | 59 | end # testset "SlurmClusterManager.jl"
|
0 commit comments