3
3
using Test, DistributedNext, Random, Serialization, Sockets
4
4
import DistributedNext: launch, manage
5
5
6
+ import LibSSH as ssh
7
+ import LibSSH. Demo: DemoServer
8
+
6
9
@test cluster_cookie () isa String
7
10
8
11
include (joinpath (Sys. BINDIR, " .." , " share" , " julia" , " test" , " testenv.jl" ))
@@ -743,11 +746,9 @@ finally
743
746
DistributedNext. default_worker_pool! (wp_default)
744
747
end
745
748
746
- # The below block of tests are usually run only on local development systems, since:
747
- # - tests which print errors
748
- # - addprocs tests are memory intensive
749
- # - ssh addprocs requires sshd to be running locally with passwordless login enabled.
750
- # The test block is enabled by defining env JULIA_TESTFULL=1
749
+ # The below block of tests are usually run only on local development systems,
750
+ # since they print errors. The test block is enabled by defining env
751
+ # JULIA_TESTFULL=1.
751
752
752
753
DoFullTest = Base. get_bool_env (" JULIA_TESTFULL" , false )
753
754
@@ -772,6 +773,7 @@ if DoFullTest
772
773
end
773
774
@test workers () == all_w
774
775
@test all ([p == remotecall_fetch (myid, p) for p in all_w])
776
+ end
775
777
776
778
if Sys. isunix () # aka have ssh
777
779
function test_n_remove_pids (new_pids)
@@ -791,75 +793,72 @@ if Sys.isunix() # aka have ssh
791
793
remotecall_fetch (rmprocs, 1 , new_pids)
792
794
end
793
795
794
- print (" \n\n Testing SSHManager. A minimum of 4GB of RAM is recommended.\n " )
795
- print (" Please ensure: \n " )
796
- print (" 1) sshd is running locally with passwordless login enabled.\n " )
797
- print (" 2) Env variable USER is defined and is the ssh user.\n " )
798
- print (" 3) Port 9300 is not in use.\n " )
799
-
800
- sshflags = ` -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o LogLevel=ERROR `
801
- # Issue #9951
802
- hosts= []
803
- localhost_aliases = [" localhost" , string (getipaddr ()), " 127.0.0.1" ]
804
- num_workers = parse (Int,(get (ENV , " JULIA_ADDPROCS_NUM" , " 9" )))
805
-
806
- for i in 1 : (num_workers/ length (localhost_aliases))
807
- append! (hosts, localhost_aliases)
808
- end
809
-
810
- print (" \n Testing SSH addprocs with $(length (hosts)) workers...\n " )
811
- new_pids = addprocs_with_testenv (hosts; sshflags= sshflags)
812
- @test length (new_pids) == length (hosts)
813
- test_n_remove_pids (new_pids)
814
-
815
- print (" \n Mixed ssh addprocs with :auto\n " )
816
- new_pids = addprocs_with_testenv ([" localhost" , (" 127.0.0.1" , :auto ), " localhost" ]; sshflags= sshflags)
817
- @test length (new_pids) == (2 + Sys. CPU_THREADS)
818
- test_n_remove_pids (new_pids)
819
-
820
- print (" \n Mixed ssh addprocs with numeric counts\n " )
821
- new_pids = addprocs_with_testenv ([(" localhost" , 2 ), (" 127.0.0.1" , 2 ), " localhost" ]; sshflags= sshflags)
822
- @test length (new_pids) == 5
823
- test_n_remove_pids (new_pids)
824
-
825
- print (" \n ssh addprocs with tunnel\n " )
826
- new_pids = addprocs_with_testenv ([(" localhost" , num_workers)]; tunnel= true , sshflags= sshflags)
827
- @test length (new_pids) == num_workers
828
- test_n_remove_pids (new_pids)
829
-
830
- print (" \n ssh addprocs with tunnel (SSH multiplexing)\n " )
831
- new_pids = addprocs_with_testenv ([(" localhost" , num_workers)]; tunnel= true , multiplex= true , sshflags= sshflags)
832
- @test length (new_pids) == num_workers
833
- controlpath = joinpath (homedir (), " .ssh" , " julia-$(ENV [" USER" ]) @localhost:22" )
834
- @test issocket (controlpath)
835
- test_n_remove_pids (new_pids)
836
- @test :ok == timedwait (()-> ! issocket (controlpath), 10.0 ; pollint= 0.5 )
837
-
838
- print (" \n All supported formats for hostname\n " )
839
- h1 = " localhost"
840
- user = ENV [" USER" ]
841
- h2 = " $user @$h1 "
842
- h3 = " $h2 :22"
843
- h4 = " $h3 $(string (getipaddr ())) "
844
- h5 = " $h4 :9300"
845
-
846
- new_pids = addprocs_with_testenv ([h1, h2, h3, h4, h5]; sshflags= sshflags)
847
- @test length (new_pids) == 5
848
- test_n_remove_pids (new_pids)
849
-
850
- print (" \n keyword arg exename\n " )
851
- for exename in [` $(joinpath (Sys. BINDIR, Base. julia_exename ())) ` , " $(joinpath (Sys. BINDIR, Base. julia_exename ())) " ]
852
- for addp_func in [()-> addprocs_with_testenv ([" localhost" ]; exename= exename, exeflags= test_exeflags, sshflags= sshflags),
853
- ()-> addprocs_with_testenv (1 ; exename= exename, exeflags= test_exeflags)]
854
-
855
- local new_pids = addp_func ()
856
- @test length (new_pids) == 1
857
- test_n_remove_pids (new_pids)
796
+ println (" \n\n Testing SSHManager. A minimum of 4GB of RAM is recommended." )
797
+ println (" Please ensure port 9300 and 2222 are not in use." )
798
+
799
+ DemoServer (2222 ; auth_methods= [ssh. AuthMethod_None], allow_auth_none= true , verbose= false , timeout= 3600 ) do
800
+ sshflags = ` -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o LogLevel=ERROR -p 2222 `
801
+ # Issue #9951
802
+ hosts= []
803
+ localhost_aliases = [" localhost" , string (getipaddr ()), " 127.0.0.1" ]
804
+ num_workers = parse (Int,(get (ENV , " JULIA_ADDPROCS_NUM" , " 9" )))
805
+
806
+ for i in 1 : (num_workers/ length (localhost_aliases))
807
+ append! (hosts, localhost_aliases)
858
808
end
859
- end
860
809
810
+ print (" \n Testing SSH addprocs with $(length (hosts)) workers...\n " )
811
+ new_pids = addprocs_with_testenv (hosts; sshflags= sshflags)
812
+ @test length (new_pids) == length (hosts)
813
+ test_n_remove_pids (new_pids)
814
+
815
+ print (" \n Mixed ssh addprocs with :auto\n " )
816
+ new_pids = addprocs_with_testenv ([" localhost" , (" 127.0.0.1" , :auto ), " localhost" ]; sshflags= sshflags)
817
+ @test length (new_pids) == (2 + Sys. CPU_THREADS)
818
+ test_n_remove_pids (new_pids)
819
+
820
+ print (" \n Mixed ssh addprocs with numeric counts\n " )
821
+ new_pids = addprocs_with_testenv ([(" localhost" , 2 ), (" 127.0.0.1" , 2 ), " localhost" ]; sshflags= sshflags)
822
+ @test length (new_pids) == 5
823
+ test_n_remove_pids (new_pids)
824
+
825
+ print (" \n ssh addprocs with tunnel\n " )
826
+ new_pids = addprocs_with_testenv ([(" localhost" , num_workers)]; tunnel= true , sshflags= sshflags)
827
+ @test length (new_pids) == num_workers
828
+ test_n_remove_pids (new_pids)
829
+
830
+ print (" \n ssh addprocs with tunnel (SSH multiplexing)\n " )
831
+ new_pids = addprocs_with_testenv ([(" localhost" , num_workers)]; tunnel= true , multiplex= true , sshflags= sshflags)
832
+ @test length (new_pids) == num_workers
833
+ controlpath = joinpath (homedir (), " .ssh" , " julia-$(ENV [" USER" ]) @localhost:2222" )
834
+ @test issocket (controlpath)
835
+ test_n_remove_pids (new_pids)
836
+ @test :ok == timedwait (()-> ! issocket (controlpath), 10.0 ; pollint= 0.5 )
837
+
838
+ print (" \n All supported formats for hostname\n " )
839
+ h1 = " localhost"
840
+ user = ENV [" USER" ]
841
+ h2 = " $user @$h1 "
842
+ h3 = " $h2 :2222"
843
+ h4 = " $h3 $(string (getipaddr ())) "
844
+ h5 = " $h4 :9300"
845
+
846
+ new_pids = addprocs_with_testenv ([h1, h2, h3, h4, h5]; sshflags= sshflags)
847
+ @test length (new_pids) == 5
848
+ test_n_remove_pids (new_pids)
849
+
850
+ print (" \n keyword arg exename\n " )
851
+ for exename in [` $(joinpath (Sys. BINDIR, Base. julia_exename ())) ` , " $(joinpath (Sys. BINDIR, Base. julia_exename ())) " ]
852
+ for addp_func in [()-> addprocs_with_testenv ([" localhost" ]; exename= exename, exeflags= test_exeflags, sshflags= sshflags),
853
+ ()-> addprocs_with_testenv (1 ; exename= exename, exeflags= test_exeflags)]
854
+
855
+ local new_pids = addp_func ()
856
+ @test length (new_pids) == 1
857
+ test_n_remove_pids (new_pids)
858
+ end
859
+ end
860
+ end
861
861
end # unix-only
862
- end # full-test
863
862
864
863
let t = @task 42
865
864
schedule (t, ErrorException (" " ), error= true )
0 commit comments