Skip to content

Commit 45b31fa

Browse files
committed
fix port parameter in executable and wrap, make test cluster port configurable
1 parent f05ecf0 commit 45b31fa

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

lib/elasticsearch/executable.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ defmodule Elasticsearch.Executable do
2929
case System.cmd("lsof", ["-i", ":#{port_number}"]) do
3030
{"", _} ->
3131
wrap = Application.app_dir(:elasticsearch) <> "/priv/bin/wrap"
32-
port = Port.open({:spawn, "#{wrap} #{executable} --port #{port_number}"}, [])
32+
port = Port.open({:spawn, "#{wrap} #{executable} -E http.port=#{port_number}"}, [])
3333
{:os_pid, os_pid} = Port.info(port, :os_pid)
3434
IO.puts("[info] Running #{name} with PID #{os_pid} on port #{port_number}")
3535
{:ok, port}

priv/bin/wrap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#
1515
# http://erlang.2086793.n4.nabble.com/closing-a-port-doesn-t-kill-the-connected-process-td2119170.html
1616

17-
$1 > /dev/null 2>&1 &
17+
$@ > /dev/null 2>&1 &
1818
last_pid=$!
1919
while read line ; do
2020
:

test/support/cluster.ex

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ defmodule Elasticsearch.Test.Cluster do
33

44
use Elasticsearch.Cluster
55

6-
def init(_config) do
6+
def init(config) do
7+
url = Map.get(config, :url, "http://localhost:9200")
8+
79
{:ok,
810
%{
911
api: Elasticsearch.API.HTTP,
1012
json_library: Poison,
11-
url: "http://localhost:9200",
13+
url: url,
1214
username: "username",
1315
password: "password",
1416
indexes: %{

test/test_helper.exs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
ExUnit.start()
22
Elasticsearch.Test.Repo.start_link()
33

4+
port_number = 9200
5+
url = "http://localhost:#{port_number}"
6+
47
unless System.get_env("CI") do
58
Elasticsearch.Executable.start_link(
69
"Elasticsearch",
710
"./vendor/elasticsearch/bin/elasticsearch",
8-
9200
11+
port_number
912
)
1013
end
1114

12-
{:ok, _} = Elasticsearch.Test.Cluster.start_link()
13-
{:ok, _} = Elasticsearch.wait_for_boot(Elasticsearch.Test.Cluster, 15)
15+
{:ok, _} = Elasticsearch.Test.Cluster.start_link(%{url: url})
16+
{:ok, _} = Elasticsearch.wait_for_boot(Elasticsearch.Test.Cluster, 30)

0 commit comments

Comments
 (0)