Skip to content

Commit b3ec9a0

Browse files
committed
Test suite: Only run the c1,c2 hostname test in CI
1 parent 83fe844 commit b3ec9a0

File tree

1 file changed

+39
-5
lines changed

1 file changed

+39
-5
lines changed

test/script.jl

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,34 @@
33
# We don't use `using Foo` here.
44
# We either use `using Foo: hello, world`, or we use `import Foo`.
55
# https://github.com/JuliaLang/julia/pull/42080
6-
using Distributed: addprocs, workers, nworkers, remotecall_fetch
6+
using Distributed: addprocs, workers, nworkers, remotecall_fetch, @everywhere
77
using SlurmClusterManager: SlurmManager
88

99
addprocs(SlurmManager())
1010

11+
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
12+
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
13+
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
14+
15+
# To run tests outside of CI, set e.g.
16+
# `export JULIA_SLURMCLUSTERMANAGER_IS_CI=false`
17+
# in your Bash session before you launch the Slurm job.
18+
function is_ci()
19+
name = "JULIA_SLURMCLUSTERMANAGER_IS_CI"
20+
21+
# We intentionally default to true.
22+
# This allows things to work in our CI (which is inside of Docker).
23+
default_value = "true"
24+
25+
value_str = strip(get(ENV, name, default_value))
26+
value_b = parse(Bool, value_str)
27+
return value_b
28+
end
29+
30+
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
31+
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
32+
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
33+
1134
# We intentionally do not use `@assert` here.
1235
# In a future minor release of Julia, `@assert`s may be disabled by default.
1336
const SLURM_NTASKS = parse(Int, ENV["SLURM_NTASKS"])
@@ -22,8 +45,19 @@ end
2245
sort!(hosts)
2346
println("List of hosts: ", hosts)
2447

25-
# We don't use `@assert` here, for reason described above.
26-
if hosts != ["c1", "c1", "c2", "c2"]
27-
msg = "Test failed: observed_hosts=$(hosts) does not match expected_hosts=[c1, c1, c2, c2]"
28-
error(msg)
48+
if is_ci()
49+
@info "This is CI, so we will perform the hostname test"
50+
51+
# We don't use `@assert` here, for reason described above.
52+
if hosts != ["c1", "c1", "c2", "c2"]
53+
msg = "Test failed: observed_hosts=$(hosts) does not match expected_hosts=[c1, c1, c2, c2]"
54+
error(msg)
55+
end
56+
else
57+
@warn "This is not CI, so we will skip the hostname test"
2958
end
59+
60+
@everywhere import Distributed
61+
62+
# Workers report in:
63+
@everywhere println("Host $(Distributed.myid()): $(gethostname())")

0 commit comments

Comments
 (0)