Skip to content

Commit

Permalink
Add some debug printing to help when running the tests on a local clu…
Browse files Browse the repository at this point in the history
…ster

Co-authored-by: jbphyswx <[email protected]>
  • Loading branch information
DilumAluthge and jbphyswx committed Dec 31, 2024
1 parent a906072 commit 7e88517
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions test/script.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# We don't use `using Foo` here.
# We either use `using Foo: hello, world`, or we use `import Foo`.
# https://github.com/JuliaLang/julia/pull/42080
using Distributed: addprocs, workers, nworkers, remotecall_fetch
using Distributed: addprocs, workers, nworkers, remotecall_fetch, @everywhere
using SlurmClusterManager: SlurmManager

addprocs(SlurmManager())
Expand All @@ -21,8 +21,19 @@ const hosts = map(workers()) do id
end
sort!(hosts)

# We don't use `@assert` here, for reason described above.
if hosts != ["c1", "c1", "c2", "c2"]
msg = "Test failed: observed_hosts=$(hosts) does not match expected_hosts=[c1, c1, c2, c2]"
error(msg)
const is_ci = parse(Bool, strip(get(ENV, "CI", "false")))

if is_ci
# We don't use `@assert` here, for reason described above.
if hosts != ["c1", "c1", "c2", "c2"]
msg = "Test failed: observed_hosts=$(hosts) does not match expected_hosts=[c1, c1, c2, c2]"
error(msg)
end
else
# The specific hostnames of c1 and c2 are specific to the CI setup.
# We don't expect people to have the same hostnames if they run the test suite locally.
@warn "This is not CI, so we will skip the hostname test"
end

@everywhere import Distributed
@everywhere println("Host $(Distributed.myid()): $(gethostname())") # workers report in

0 comments on commit 7e88517

Please sign in to comment.