diff --git a/lib/elasticsearch/executable.ex b/lib/elasticsearch/executable.ex index a6e3898..7f05743 100644 --- a/lib/elasticsearch/executable.ex +++ b/lib/elasticsearch/executable.ex @@ -29,7 +29,7 @@ defmodule Elasticsearch.Executable do case System.cmd("lsof", ["-i", ":#{port_number}"]) do {"", _} -> wrap = Application.app_dir(:elasticsearch) <> "/priv/bin/wrap" - port = Port.open({:spawn, "#{wrap} #{executable} --port #{port_number}"}, []) + port = Port.open({:spawn, "#{wrap} #{executable} -E http.port=#{port_number}"}, []) {:os_pid, os_pid} = Port.info(port, :os_pid) IO.puts("[info] Running #{name} with PID #{os_pid} on port #{port_number}") {:ok, port} diff --git a/priv/bin/wrap b/priv/bin/wrap index dd7e28f..dd02d83 100755 --- a/priv/bin/wrap +++ b/priv/bin/wrap @@ -14,7 +14,7 @@ # # http://erlang.2086793.n4.nabble.com/closing-a-port-doesn-t-kill-the-connected-process-td2119170.html -$1 > /dev/null 2>&1 & +$@ > /dev/null 2>&1 & last_pid=$! while read line ; do : diff --git a/test/support/cluster.ex b/test/support/cluster.ex index a1141f9..a8510c1 100644 --- a/test/support/cluster.ex +++ b/test/support/cluster.ex @@ -3,12 +3,14 @@ defmodule Elasticsearch.Test.Cluster do use Elasticsearch.Cluster - def init(_config) do + def init(config) do + url = Map.get(config, :url, "http://localhost:9200") + {:ok, %{ api: Elasticsearch.API.HTTP, json_library: Poison, - url: "http://localhost:9200", + url: url, username: "username", password: "password", indexes: %{ diff --git a/test/test_helper.exs b/test/test_helper.exs index 63e1d76..3a84b52 100644 --- a/test/test_helper.exs +++ b/test/test_helper.exs @@ -1,13 +1,16 @@ ExUnit.start() Elasticsearch.Test.Repo.start_link() +port_number = 9200 +url = "http://localhost:#{port_number}" + unless System.get_env("CI") do Elasticsearch.Executable.start_link( "Elasticsearch", "./vendor/elasticsearch/bin/elasticsearch", - 9200 + port_number ) end -{:ok, _} = Elasticsearch.Test.Cluster.start_link() -{:ok, _} = Elasticsearch.wait_for_boot(Elasticsearch.Test.Cluster, 15) +{:ok, _} = Elasticsearch.Test.Cluster.start_link(%{url: url}) +{:ok, _} = Elasticsearch.wait_for_boot(Elasticsearch.Test.Cluster, 30)