I’ve followed these instructions to install Elasticsearch.
Within a Rails app I’m starting a Test::Cluster to use within rspec tests.
#rails_helper.rb
require 'elasticsearch/extensions/test/cluster'
config.before :all, elasticsearch: true do
# Start elasticsearch cluster before test run
Elasticsearch::Extensions::Test::Cluster.start(
port: 9250,
nodes: 1,
timeout: 120
) unless Elasticsearch::Extensions::Test::Cluster.running?(on: 9250)
end
config.after :suite do
# Stop elasticsearch cluster after test run
Elasticsearch::Extensions::Test::Cluster.stop(port: 9250, nodes: 1) if Elasticsearch::Extensions::Test::Cluster.running?(on: 9250)
end
Everything works fine when testing locally, but when I push to CircleCI the build fails with
An error occurred in an `after(:suite)` hook.
Failure/Error: Elasticsearch::Extensions::Test::Cluster.stop(port: 9250, nodes: 1) if Elasticsearch::Extensions::Test::Cluster.running?(on: 9250)
Errno::ENOENT:
No such file or directory - Cannot find Elasticsearch launch script from [elasticsearch] -- did you pass a correct path?
As far as I can tell, I am configuring the build correctly to use Elasticsearch
#circle.yml
machine:
services:
- elasticsearch
or
#circle.yml
dependencies:
cache_directories:
- elasticsearch-5.1.1 # relative to the build directory
post:
- if [[ ! -e elasticsearch-5.1.1 ]]; then wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.1.1.tar.gz && tar -xvf elasticsearch-5.1.1.tar.gz; fi
- elasticsearch-5.1.1/bin/elasticsearch: {background: true}
- sleep 10 && wget --waitretry=5 --retry-connrefused -v http://127.0.0.1:9200/
What is the correct way to install Elasticsearch on CicleCi?