11using Test
22using DistributedNext
3- import Sockets: getipaddr
3+ import Sockets: getipaddr, listenany
44
55import LibSSH as ssh
66import LibSSH. Demo: DemoServer
@@ -26,8 +26,11 @@ function test_n_remove_pids(new_pids)
2626end
2727
2828@testset " SSHManager" begin
29- DemoServer (2222 ; auth_methods= [ssh. AuthMethod_None], allow_auth_none= true , verbose= false , timeout= 3600 ) do
30- sshflags = ` -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o LogLevel=ERROR -p 2222 `
29+ ssh_port, server = listenany (2222 )
30+ close (server)
31+
32+ DemoServer (Int (ssh_port); auth_methods= [ssh. AuthMethod_None], allow_auth_none= true , verbose= false , timeout= 3600 ) do
33+ sshflags = ` -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o LogLevel=ERROR -p $(ssh_port) `
3134 # Issue #9951
3235 hosts= []
3336 localhost_aliases = [" localhost" , string (getipaddr ()), " 127.0.0.1" ]
6669 print (" \n ssh addprocs with tunnel (SSH multiplexing)\n " )
6770 new_pids = addprocs_with_testenv ([(" localhost" , num_workers)]; tunnel= true , multiplex= true , sshflags= sshflags)
6871 @test length (new_pids) == num_workers
69- controlpath = joinpath (ssh_dir, " julia-$(ENV [" USER" ]) @localhost:2222 " )
72+ controlpath = joinpath (ssh_dir, " julia-$(ENV [" USER" ]) @localhost:$(ssh_port) " )
7073 @test issocket (controlpath)
7174 test_n_remove_pids (new_pids)
7275 @test :ok == timedwait (()-> ! issocket (controlpath), 10.0 ; pollint= 0.5 )
8285 h1 = " localhost"
8386 user = ENV [" USER" ]
8487 h2 = " $user @$h1 "
85- h3 = " $h2 :2222 "
88+ h3 = " $h2 :$(ssh_port) "
8689 h4 = " $h3 $(string (getipaddr ())) "
87- h5 = " $h4 :9300"
90+ (bind_port, server) = listenany (9300 )
91+ close (server)
92+ h5 = " $h4 :$(bind_port) "
8893
8994 new_pids = addprocs_with_testenv ([h1, h2, h3, h4, h5]; sshflags= sshflags)
9095 @test length (new_pids) == 5
0 commit comments