11require 'pathname'
22
3- subprojects = %w| elasticsearch-rails elasticsearch-persistence elasticsearch-model |
3+ subprojects = [ 'elasticsearch-rails' , 'elasticsearch-persistence' ]
4+ subprojects << 'elasticsearch-model' unless defined? ( JRUBY_VERSION )
45
56__current__ = Pathname ( File . expand_path ( '..' , __FILE__ ) )
67
@@ -25,15 +26,9 @@ namespace :bundle do
2526 task :install do
2627 subprojects . each do |project |
2728 puts '-' *80
28- sh "bundle install --gemfile #{ __current__ . join ( project ) } /Gemfile "
29+ sh "cd #{ __current__ . join ( project ) } && bundle exec rake bundle:install "
2930 puts
3031 end
31- puts '-' *80
32- sh "bundle install --gemfile #{ __current__ . join ( 'elasticsearch-model/gemfiles' ) } /3.0.gemfile"
33- puts '-' *80
34- sh "bundle install --gemfile #{ __current__ . join ( 'elasticsearch-model/gemfiles' ) } /4.0.gemfile"
35- puts '-' *80
36- sh "bundle install --gemfile #{ __current__ . join ( 'elasticsearch-model/gemfiles' ) } /5.0.gemfile"
3732 end
3833
3934 desc "Remove Gemfile.lock in all subprojects"
@@ -60,7 +55,7 @@ namespace :test do
6055 end
6156
6257 desc "Run Elasticsearch (Docker)"
63- task :setup_elasticsearch do
58+ task :setup_elasticsearch_docker do
6459 begin
6560 sh <<-COMMAND . gsub ( /^\s */ , '' ) . gsub ( /\s {1,}/ , ' ' )
6661 docker run -d=true \
@@ -70,15 +65,30 @@ namespace :test do
7065 --env "cluster.routing.allocation.disk.threshold_enabled=false" \
7166 --publish 9250:9200 \
7267 --rm \
73- docker.elastic.co/elasticsearch/elasticsearch:6.4.0
68+ docker.elastic.co/elasticsearch/elasticsearch:${ELASTICSEARCH_VERSION}
7469 COMMAND
7570 require 'elasticsearch/extensions/test/cluster'
76- Elasticsearch ::Extensions ::Test ::Cluster ::Cluster . new ( version : '6.4.0' ,
71+ Elasticsearch ::Extensions ::Test ::Cluster ::Cluster . new ( version : ENV [ 'ELASTICSEARCH_VERSION' ] ,
7772 number_of_nodes : 1 ) . wait_for_green
7873 rescue
7974 end
8075 end
8176
77+ desc "Setup MongoDB (Docker)"
78+ task :setup_mongodb_docker do
79+ begin
80+ if ENV [ 'MONGODB_VERSION' ]
81+ sh <<-COMMAND . gsub ( /^\s */ , '' ) . gsub ( /\s {1,}/ , ' ' )
82+ wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-${MONGODB_VERSION}.tgz -O /tmp/mongodb.tgz &&
83+ tar -xvf /tmp/mongodb.tgz &&
84+ mkdir /tmp/data &&
85+ ${PWD}/mongodb-linux-x86_64-${MONGODB_VERSION}/bin/mongod --setParameter enableTestCommands=1 --dbpath /tmp/data --bind_ip 127.0.0.1 --auth &> /dev/null &
86+ COMMAND
87+ end
88+ rescue
89+ end
90+ end
91+
8292 desc "Run integration tests in all subprojects"
8393 task :integration => :setup_elasticsearch do
8494 # 1/ elasticsearch-model
@@ -106,8 +116,13 @@ namespace :test do
106116
107117 desc "Run all tests in all subprojects"
108118 task :all do
109- Rake ::Task [ 'test:unit' ] . invoke
110- Rake ::Task [ 'test:integration' ] . invoke
119+ subprojects . each do |project |
120+ puts '-' *80
121+ sh "cd #{ project } && " +
122+ "unset BUNDLE_GEMFILE && " +
123+ "bundle exec rake test:all"
124+ puts "\n "
125+ end
111126 end
112127
113128 namespace :cluster do
0 commit comments