Skip to content

Commit 1be6283

Browse files
committed
Use LibSSH v1 for the tests
v1 is threadsafe so the SSH tests don't need to be run single-threaded anymore. The SSH tests spun up a lot of workers so some hardcoded worker IDs elsewhere needed to be fixed.
1 parent d5a4589 commit 1be6283

4 files changed

Lines changed: 25 additions & 31 deletions

File tree

Project.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ ReviseExt = "Revise"
1818
[compat]
1919
Aqua = "0.8"
2020
Distributed = "1"
21-
LibSSH = "0.7"
21+
LibSSH = "1"
2222
LinearAlgebra = "1"
23+
Pkg = "1"
2324
PrecompileTools = "1"
2425
Random = "1"
2526
Revise = "3.7.0"
@@ -34,7 +35,8 @@ Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
3435
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
3536
LibSSH = "00483490-30f8-4353-8aba-35b82f51f4d0"
3637
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
38+
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
3739
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
3840

3941
[targets]
40-
test = ["Aqua", "Distributed", "LibSSH", "LinearAlgebra", "Revise", "Test"]
42+
test = ["Aqua", "Distributed", "LinearAlgebra", "Pkg", "Revise", "Test"]

test/distributed_exec.jl

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -726,13 +726,14 @@ end
726726
wp = WorkerPool(workers())
727727
@test nworkers() == length(unique(pmap(_->myid(), wp, 1:100)))
728728
@test nworkers() == length(unique(remotecall_fetch(wp->pmap(_->myid(), wp, 1:100), id_other, wp)))
729-
wp = WorkerPool(2:3)
730-
@test sort(unique(pmap(_->myid(), wp, 1:100))) == [2,3]
729+
two_workers = sort(workers())[1:2]
730+
wp = WorkerPool(two_workers)
731+
@test sort(unique(pmap(_->myid(), wp, 1:100))) == two_workers
731732
@test fetch(remotecall(myid, wp)) in wp.workers
732733
@test_throws RemoteException fetch(remotecall(error, wp))
733734

734735
# wait on worker pool
735-
wp = WorkerPool(2:2)
736+
wp = WorkerPool(two_workers[1:1])
736737
w = take!(wp)
737738

738739
# local call to _wait
@@ -987,14 +988,14 @@ f16091b = () -> 1
987988

988989
# these will only heisen-fail, since it depends on the gensym counter collisions:
989990
remotecall_fetch(()->eval(:(f16091b = () -> 2)), wid)
990-
@test remotecall_fetch(f16091b, 2) === 1
991+
@test remotecall_fetch(f16091b, wid) === 1
991992
# Global anonymous functions are over-written...
992993
@test remotecall_fetch((myid)->remotecall_fetch(f16091b, myid), wid, myid()) === 1
993994

994995
# ...while local anonymous functions are by definition, local.
995996
let
996997
f16091c = () -> 1
997-
@test remotecall_fetch(f16091c, 2) === 1
998+
@test remotecall_fetch(f16091c, wid) === 1
998999
@test remotecall_fetch(
9991000
myid -> begin
10001001
let
@@ -1032,14 +1033,14 @@ f16091b = () -> 1
10321033
# Deserialization error recovery test
10331034
# locally defined module, but unavailable on workers
10341035
let
1035-
@test_throws RemoteException remotecall_fetch(()->LocalFoo.foo, 2)
1036+
@test_throws RemoteException remotecall_fetch(()->LocalFoo.foo, wrkr1)
10361037

10371038
bad_thunk = ()->NonexistentModule.f()
1038-
@test_throws RemoteException remotecall_fetch(bad_thunk, 2)
1039+
@test_throws RemoteException remotecall_fetch(bad_thunk, wrkr1)
10391040

10401041
# Test that the stream is still usable
1041-
@test remotecall_fetch(()->:test,2) === :test
1042-
ref = remotecall(bad_thunk, 2)
1042+
@test remotecall_fetch(()->:test, wrkr1) === :test
1043+
ref = remotecall(bad_thunk, wrkr1)
10431044
@test_throws RemoteException fetch(ref)
10441045
end
10451046

@@ -1483,7 +1484,7 @@ v2669=10
14831484

14841485
let thrown = false
14851486
try
1486-
remotecall_fetch(sqrt, 2, -1)
1487+
remotecall_fetch(sqrt, workers()[1], -1)
14871488
catch e
14881489
thrown = true
14891490
local b = IOBuffer()

test/runtests.jl

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,10 @@ include(joinpath(Sys.BINDIR, "..", "share", "julia", "test", "testenv.jl"))
1010

1111
cmd = `$test_exename $test_exeflags`
1212

13-
# LibSSH.jl currently only works on unixes, and the latest release currently
14-
# doesn't pass CI on MacOS.
15-
if Sys.islinux()
16-
# Run the SSH tests with a single thread because LibSSH.jl is not thread-safe
17-
sshtestfile = joinpath(@__DIR__, "sshmanager.jl")
18-
if Base.VERSION >= v"1.12-"
19-
# The x,y format for threadpools requires Julia 1.9 or above.
20-
# However, Julia didn't begin starting with 1 interactive thread by default until Julia 1.12
21-
# So we don't need to bother with this on Julia 1.11 and earlier
22-
JULIA_NUM_THREADS = "1,0"
23-
else
24-
JULIA_NUM_THREADS = "1"
25-
end
26-
run(addenv(`$cmd $sshtestfile`, "JULIA_NUM_THREADS" => "1"))
13+
# LibSSH.jl currently only works on unixes and v1.11+, and the latest release
14+
# currently doesn't pass CI on MacOS.
15+
if Sys.islinux() && VERSION >= v"1.11"
16+
include("sshmanager.jl")
2717
else
2818
@warn "Skipping the SSH tests because this platform is not supported"
2919
end

test/sshmanager.jl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
using Test
22
using DistributedNext
3-
import Sockets: getipaddr, listenany
3+
using Sockets: getipaddr, listenany
44

5-
import LibSSH as ssh
6-
import LibSSH.Demo: DemoServer
5+
# We install LibSSH manually because having it in Project.toml won't resolve on
6+
# Julia 1.10.
7+
import Pkg
8+
Pkg.add("LibSSH")
9+
using LibSSH: LibSSH as ssh, DemoServer
710

811

9-
include(joinpath(Sys.BINDIR, "..", "share", "julia", "test", "testenv.jl"))
10-
1112
function test_n_remove_pids(new_pids)
1213
for p in new_pids
1314
w_in_remote = sort(remotecall_fetch(workers, p))

0 commit comments

Comments
 (0)