Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CI] Use docker to launch Elasticsearch in rake task #803

Merged
merged 1 commit into from
Jun 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,15 @@ matrix:
jdk: oraclejdk8
env: TEST_SUITE=unit

- rvm: 2.3.3
- rvm: 2.5.1
jdk: oraclejdk8
env: TEST_SUITE=integration QUIET=y SERVER=start TEST_CLUSTER_LOGS=/tmp/log TEST_CLUSTER_COMMAND=/tmp/elasticsearch-6.3.0/bin/elasticsearch
env: TEST_SUITE=integration QUIET=y

before_install:
- gem update --system --no-rdoc --no-ri
- gem update --system -q
- gem update bundler -q
- gem --version
- gem install bundler -v 1.14.3 --no-rdoc --no-ri
- bundle version
- curl -sS https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.3.0.tar.gz | tar xz -C /tmp

install:
- bundle install
Expand Down
25 changes: 24 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,31 @@ namespace :test do
end
end

desc "Run Elasticsearch (Docker)"
task :setup_elasticsearch do
begin
sh <<-COMMAND.gsub(/^\s*/, '').gsub(/\s{1,}/, ' ')
docker stop $(docker ps -aq);
docker rm $(docker ps -aq);
docker rmi $(docker images -q);
docker run -d=true \
--env "discovery.type=single-node" \
--env "cluster.name=elasticsearch-rails" \
--env "http.port=9200" \
--env "cluster.routing.allocation.disk.threshold_enabled=false" \
--publish 9250:9200 \
--rm \
docker.elastic.co/elasticsearch/elasticsearch:6.3.0
COMMAND
require 'elasticsearch/extensions/test/cluster'
Elasticsearch::Extensions::Test::Cluster::Cluster.new(version: '6.3.0',
number_of_nodes: 1).wait_for_green
rescue
end
end

desc "Run integration tests in all subprojects"
task :integration do
task :integration => :setup_elasticsearch do
# 1/ elasticsearch-model
#
puts '-'*80
Expand Down