Skip to content

Commit

Permalink
use docker-compose to common test against elastic in travis (#76)
Browse files Browse the repository at this point in the history
Waits for docker-compose to start elasticsearch in the background and executes common test suite
  • Loading branch information
bryanhuntesl authored Oct 6, 2018
1 parent c350f81 commit 8482766
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 6 deletions.
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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}]}
Expand Down Expand Up @@ -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`
Expand Down
8 changes: 8 additions & 0 deletions docker-compose-kibana.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: '3'
services:
kibana:
image: kibana:5.0
links:
- elasticsearch
ports:
- 5601:5601
13 changes: 13 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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: {}

0 comments on commit 8482766

Please sign in to comment.