From 8482766d479a0d41b3e7d1e754e096293fa30955 Mon Sep 17 00:00:00 2001 From: bryanhuntesl <31992054+bryanhuntesl@users.noreply.github.com> Date: Sat, 6 Oct 2018 17:44:52 +0100 Subject: [PATCH] use docker-compose to common test against elastic in travis (#76) Waits for docker-compose to start elasticsearch in the background and executes common test suite --- .travis.yml | 5 ++++- README.md | 16 +++++++++++----- docker-compose-kibana.yml | 8 ++++++++ docker-compose.yml | 13 +++++++++++++ 4 files changed, 36 insertions(+), 6 deletions(-) create mode 100644 docker-compose-kibana.yml create mode 100644 docker-compose.yml diff --git a/.travis.yml b/.travis.yml index e579fae..e86ae2c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,8 +6,11 @@ otp_release: - 19.3 - 18.3 +before_install: + - docker-compose -f docker-compose.yml up -d + - until curl --silent -XGET --fail http://localhost:9200; do printf '.'; sleep 1; done before_script: "rebar3 update" -script: "rebar3 dialyzer" +script: "rebar3 ct && rebar3 dialyzer" cache: directories: - $HOME/.cache/rebar3/ diff --git a/README.md b/README.md index e8cb59a..496695b 100644 --- a/README.md +++ b/README.md @@ -9,13 +9,13 @@ Build and Run Start a rebar3 shell ```shell -$ rebar3 shell +rebar3 shell ``` Create an index : ```erlang -(erlastic@127.0.0.1)1> erlastic_search:create_index(<<"index_name">>). +erlastic_search:create_index(<<"index_name">>). ``` ``` {ok, [{<<"ok">>,true},{<<"acknowledged">>,true}]} @@ -81,16 +81,22 @@ erlastic_search:search(<<"index_name">>, <<"type">>, <<"key1:value1">>). Testing ------- -First start a local Elasticsearch: +In another terminal use docker-compose to start an Elasticsearch instance : ```bash -$ bin/elasticsearch +docker-compose up +``` + +For convenience, you can also start a Kibana instance for analysis/visualization : + +```bash +docker-compose -f docker-compose.yml -f docker-compose-kibana.yml up ``` Run Common Test: ```bash -$ rebar3 ct +rebar3 ct ``` Using another JSON library than `jsx` diff --git a/docker-compose-kibana.yml b/docker-compose-kibana.yml new file mode 100644 index 0000000..448ff28 --- /dev/null +++ b/docker-compose-kibana.yml @@ -0,0 +1,8 @@ +version: '3' +services: + kibana: + image: kibana:5.0 + links: + - elasticsearch + ports: + - 5601:5601 diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..9fb7e4e --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,13 @@ +version: '3' +services: + elasticsearch: + image: elasticsearch:5.3.2-alpine + ports: + - 9200:9200 + volumes: + - elasticsearch-data:/usr/share/elasticsearch/data + environment: + ES_JAVA_OPTS: "-Xms500m -Xmx500m" +volumes: + elasticsearch-data: {} +