Skip to content

Commit

Permalink
test: ensure consistent Julia environments in live job tests (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
mortenpi authored Feb 5, 2024
1 parent 28e105c commit 129d1c5
Show file tree
Hide file tree
Showing 7 changed files with 132 additions and 52 deletions.
70 changes: 70 additions & 0 deletions test/jobenvs/job-dist/Manifest.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# This file is machine-generated - editing it directly is not advised

julia_version = "1.9.4"
manifest_format = "2.0"
project_hash = "15b8400de0ed6d0aa5f96c6341a036f45951aee0"

[[deps.Dates]]
deps = ["Printf"]
uuid = "ade2ca70-3891-5945-98fb-dc099432e06a"

[[deps.Distributed]]
deps = ["Random", "Serialization", "Sockets"]
uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b"

[[deps.JSON]]
deps = ["Dates", "Mmap", "Parsers", "Unicode"]
git-tree-sha1 = "31e996f0a15c7b280ba9f76636b3ff9e2ae58c9a"
uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
version = "0.21.4"

[[deps.Mmap]]
uuid = "a63ad114-7e13-5084-954f-fe012c677804"

[[deps.Parsers]]
deps = ["Dates", "PrecompileTools", "UUIDs"]
git-tree-sha1 = "8489905bcdbcfac64d1daa51ca07c0d8f0283821"
uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0"
version = "2.8.1"

[[deps.PrecompileTools]]
deps = ["Preferences"]
git-tree-sha1 = "03b4c25b43cb84cee5c90aa9b5ea0a78fd848d2f"
uuid = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
version = "1.2.0"

[[deps.Preferences]]
deps = ["TOML"]
git-tree-sha1 = "00805cd429dcb4870060ff49ef443486c262e38e"
uuid = "21216c6a-2e73-6563-6e65-726566657250"
version = "1.4.1"

[[deps.Printf]]
deps = ["Unicode"]
uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7"

[[deps.Random]]
deps = ["SHA", "Serialization"]
uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"

[[deps.SHA]]
uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce"
version = "0.7.0"

[[deps.Serialization]]
uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"

[[deps.Sockets]]
uuid = "6462fe0b-24de-5631-8697-dd941f90decc"

[[deps.TOML]]
deps = ["Dates"]
uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
version = "1.0.3"

[[deps.UUIDs]]
deps = ["Random", "SHA"]
uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"

[[deps.Unicode]]
uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"
3 changes: 3 additions & 0 deletions test/jobenvs/job-dist/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[deps]
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
10 changes: 10 additions & 0 deletions test/jobenvs/job-dist/script.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using Distributed, JSON
@everywhere using Distributed
@everywhere fn() = (myid(), strip(read(`hostname`, String)))
fs = [i => remotecall(fn, i) for i in workers()]
vs = map(fs) do (i, future)
myid, hostname = fetch(future)
@info "$i: $myid, $hostname"
(; myid, hostname)
end
ENV["RESULTS"] = JSON.json((; vs))
47 changes: 31 additions & 16 deletions test/jobenvs/job1/Manifest.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This file is machine-generated - editing it directly is not advised

julia_version = "1.8.5"
julia_version = "1.9.4"
manifest_format = "2.0"
project_hash = "19ff69f495991858cf34afc4927fe003524460ea"

Expand All @@ -23,9 +23,9 @@ uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"

[[deps.JSON]]
deps = ["Dates", "Mmap", "Parsers", "Unicode"]
git-tree-sha1 = "3c837543ddb02250ef42f4738347454f95079d4e"
git-tree-sha1 = "31e996f0a15c7b280ba9f76636b3ff9e2ae58c9a"
uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
version = "0.21.3"
version = "0.21.4"

[[deps.Markdown]]
deps = ["Base64"]
Expand All @@ -35,36 +35,51 @@ uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"
uuid = "a63ad114-7e13-5084-954f-fe012c677804"

[[deps.OrderedCollections]]
git-tree-sha1 = "85f8e6578bf1f9ee0d11e7bb1b1456435479d47c"
git-tree-sha1 = "dfdf5519f235516220579f949664f1bf44e741c5"
uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
version = "1.4.1"
version = "1.6.3"

[[deps.Parsers]]
deps = ["Dates", "SnoopPrecompile"]
git-tree-sha1 = "478ac6c952fddd4399e71d4779797c538d0ff2bf"
deps = ["Dates", "PrecompileTools", "UUIDs"]
git-tree-sha1 = "8489905bcdbcfac64d1daa51ca07c0d8f0283821"
uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0"
version = "2.5.8"
version = "2.8.1"

[[deps.PrecompileTools]]
deps = ["Preferences"]
git-tree-sha1 = "03b4c25b43cb84cee5c90aa9b5ea0a78fd848d2f"
uuid = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
version = "1.2.0"

[[deps.Preferences]]
deps = ["TOML"]
git-tree-sha1 = "47e5f437cc0e7ef2ce8406ce1e7e24d44915f88d"
git-tree-sha1 = "00805cd429dcb4870060ff49ef443486c262e38e"
uuid = "21216c6a-2e73-6563-6e65-726566657250"
version = "1.3.0"
version = "1.4.1"

[[deps.Printf]]
deps = ["Unicode"]
uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7"

[[deps.SnoopPrecompile]]
deps = ["Preferences"]
git-tree-sha1 = "e760a70afdcd461cf01a575947738d359234665c"
uuid = "66db9d55-30c0-4569-8b51-7e840670fc0c"
version = "1.0.3"
[[deps.Random]]
deps = ["SHA", "Serialization"]
uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"

[[deps.SHA]]
uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce"
version = "0.7.0"

[[deps.Serialization]]
uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"

[[deps.TOML]]
deps = ["Dates"]
uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
version = "1.0.0"
version = "1.0.3"

[[deps.UUIDs]]
deps = ["Random", "SHA"]
uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"

[[deps.Unicode]]
uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"
4 changes: 3 additions & 1 deletion test/jobenvs/job1/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@ DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"

[compat]
DataStructures = "0.17"
# Note: this should be resolved to exactly 0.17.0 in Manifest.toml
# for the tests to pass.
DataStructures = "0.17.0"
JSON = "0.21"
48 changes: 14 additions & 34 deletions test/jobs-live.jl
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ end

@testset "[LIVE] JuliaHub.submit_job / simple" begin
job, _ = submit_test_job(
JuliaHub.script"@info 1+1; sleep(200)";
JuliaHub.script"@info 1+1; sleep(200)"noenv;
ncpu=2, memory=8,
auth, alias="script-simple"
)
Expand Down Expand Up @@ -186,7 +186,7 @@ end
JuliaHub.script"""
ENV["RESULTS"] = "{\\"x\\":42}"
error("fail")
""";
"""noenv;
auth, alias="script-fail", timelimit=JuliaHub.Unlimited(),
)
@test job._json["limit_type"] == "unlimited"
Expand All @@ -203,18 +203,7 @@ end

@testset "[LIVE] JuliaHub.submit_job / distributed" begin
job, _ = submit_test_job(
JuliaHub.script"""
using Distributed, JSON
@everywhere using Distributed
@everywhere fn() = (myid(), strip(read(`hostname`, String)))
fs = [i => remotecall(fn, i) for i in workers()]
vs = map(fs) do (i, future)
myid, hostname = fetch(future)
@info "$i: $myid, $hostname"
(; myid, hostname)
end
ENV["RESULTS"] = JSON.json((; vs))
""";
JuliaHub.appbundle(joinpath(@__DIR__, "jobenvs", "job-dist"), "script.jl");
nnodes=3,
auth, alias="distributed",
)
Expand All @@ -231,18 +220,7 @@ end

@testset "[LIVE] JuliaHub.submit_job / distributed-per-core" begin
job, full_alias = submit_test_job(
JuliaHub.script"""
using Distributed, JSON
@everywhere using Distributed
@everywhere fn() = (myid(), strip(read(`hostname`, String)))
fs = [i => remotecall(fn, i) for i in workers()]
vs = map(fs) do (i, future)
myid, hostname = fetch(future)
@info "$i: $myid, $hostname"
(; myid, hostname)
end
ENV["RESULTS"] = JSON.json((; vs))
""";
JuliaHub.appbundle(joinpath(@__DIR__, "jobenvs", "job-dist"), "script.jl");
ncpu=2, nnodes=3, process_per_node=false,
env=Dict("FOO" => "bar"),
auth, alias="distributed-percore",
Expand Down Expand Up @@ -315,6 +293,11 @@ end
)
job = JuliaHub.wait_job(job)
@test job.status == "Completed"
# Check input and output files
@test length(JuliaHub.job_files(job, :input)) >= 2
@test JuliaHub.job_file(job, :input, "code.jl") isa JuliaHub.JobFile
@test JuliaHub.job_file(job, :input, "appbundle.tar") isa JuliaHub.JobFile
# Test the results values
@test !isempty(job.results)
let results = JSON.parse(job.results)
@test results isa AbstractDict
Expand All @@ -332,21 +315,18 @@ end
ENV["RESULTS_FILE"] = joinpath(@__DIR__, "output.txt")
n = write(ENV["RESULTS_FILE"], "output-txt-content")
@info "Wrote $(n) bytes"
"""; alias="output-file",
"""noenv; alias="output-file",
)
job = JuliaHub.wait_job(job)
@test job.status == "Completed"
# Project.toml, Manifest.toml, code.jl
@test length(JuliaHub.job_files(job, :input)) >= 3
@test JuliaHub.job_file(job, :input, "Project.toml") isa JuliaHub.JobFile
@test JuliaHub.job_file(job, :input, "Manifest.toml") isa JuliaHub.JobFile
@test length(JuliaHub.job_files(job, :input)) >= 1
@test JuliaHub.job_file(job, :input, "code.jl") isa JuliaHub.JobFile
# code.jl
@test length(JuliaHub.job_files(job, :source)) >= 1
@test JuliaHub.job_file(job, :source, "code.jl") isa JuliaHub.JobFile
# Project.toml, Manifest.toml
@test length(JuliaHub.job_files(job, :project)) >= 2
@test JuliaHub.job_file(job, :project, "Project.toml") isa JuliaHub.JobFile
@test length(JuliaHub.job_files(job, :project)) >= 1
@test JuliaHub.job_file(job, :project, "Manifest.toml") isa JuliaHub.JobFile
# output.txt
@test length(JuliaHub.job_files(job, :result)) == 1
Expand All @@ -365,11 +345,11 @@ end
write(joinpath(odir, "bar.txt"), "output-txt-content-2")
@info "Wrote: odir"
ENV["RESULTS_FILE"] = odir
"""; alias="output-file-tarball",
"""noenv; alias="output-file-tarball",
)
job = JuliaHub.wait_job(job)
@test job.status == "Completed"
@test length(JuliaHub.job_files(job, :project)) >= 2
@test length(JuliaHub.job_files(job, :project)) >= 1
result_tarball = only(JuliaHub.job_files(job, :result))
buf = IOBuffer()
JuliaHub.download_job_file(result_tarball, buf)
Expand Down
2 changes: 1 addition & 1 deletion test/jobs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ end
@test isfile(bundle.environment.tarball_path)
@test bundle.code == "test()"
@test bundle.sysimage === true
@test JuliaHub._sysimage_manifest_sha(bundle.environment) == "e066dbebe85bb0a0ed79356a81ddc2223974f784cea3f512cea615a2d5731b0e"
@test JuliaHub._sysimage_manifest_sha(bundle.environment) == "631fc619c1d04e525872df2779fa95a0dc47edd9558af629af88c493daa6300d"

mktempdir() do path
bigfile_path = joinpath(path, "bigfile")
Expand Down

0 comments on commit 129d1c5

Please sign in to comment.