diff --git a/src/elastic.jl b/src/elastic.jl index 9d5a3fc..a36b14b 100644 --- a/src/elastic.jl +++ b/src/elastic.jl @@ -137,10 +137,13 @@ end function get_private_ip() if Sys.islinux() - IPv4(strip(read(`hostname --ip-address`, String))) + cmd = `hostname --ip-address` + elseif Sys.isapple() + cmd = `ipconfig getifaddr en0` else - error("addr=:auto is only supported on Linux") + error("addr=:auto is only supported on Linux and Mac") end + IPv4(@show strip(read(cmd, String))) end function get_connect_cmd(em::ElasticManager; absolute_exename=true, same_project=true) diff --git a/test/runtests.jl b/test/runtests.jl index ba5d0c8..1aaa803 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,2 +1,18 @@ -# only package loading for now +using Test using ClusterManagers + +TIMEOUT = 10. + +@testset "ElasticManager" begin + + em = ElasticManager(addr=:auto, port=0) + + # launch worker + run(`sh -c $(ClusterManagers.get_connect_cmd(em))`, wait=false) + + # wait at most TIMEOUT seconds for it to connect + @test :ok == timedwait(TIMEOUT) do + length(em.active) == 1 + end + +end