Start ElasticSearch in Wercker

130 views Asked by At

We have a Ruby project where we are using Wercker as Continuous Integration.

We need to start an Elastic Search service in order to run some integration tests.

Locally, we added the Elastic configuration to the docker file and everything runs smoothly:

services:
  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:6.5.1
    container_name: elasticsearch
    environment:
      - discovery.type=single-node
    ports:
      - "9200:9200"
      - "9300:9300"

In The Wercker.yml file, we tried several things, but we cannot reach the elastic service. Our wercker.yml contains:

services:
  - id: elasticsearch:6.5.1
    env:
      ports:
        - "9200:9200"
        - "9300:9300"

We have this king of error when trying to use Elastic in our tests:

Errno::EADDRNOTAVAIL: Failed to open TCP connection to localhost:9200 (Cannot assign requested address - connect(2) for "localhost" port 9200)

Do you have any idea of what we are missing?

1

There are 1 answers

0
GaspardP On BEST ANSWER

So, we found a solution:

In wercker.yml

services:
  - id: elasticsearch:6.5.1
    cmd: "/elasticsearch/bin/elasticsearch -Ediscovery.type=single-node"

And we added a step to check the connection:

build:
  steps:
    - script:
        name: Test elasticsearch connection
        code: curl http://elasticsearch:9200