Skip to content

Commit

Permalink
add ElasticManager test
Browse files Browse the repository at this point in the history
  • Loading branch information
marius311 committed May 13, 2020
1 parent 0d5cb1c commit d7b510d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/elastic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
18 changes: 17 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit d7b510d

Please sign in to comment.