fix port parameter in executable and wrap, make test cluster port configurable

This commit is contained in:
Patrick Carr 2020-05-25 18:38:34 -07:00
parent f05ecf0130
commit 45b31fa881
4 changed files with 12 additions and 7 deletions

View File

@ -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}

View File

@ -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
:

View File

@ -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: %{

View File

@ -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)