1
1
require 'pathname'
2
2
3
- subprojects = %w| elasticsearch-rails elasticsearch-persistence elasticsearch-model |
3
+ subprojects = [ 'elasticsearch-rails' , 'elasticsearch-persistence' ]
4
+ subprojects << 'elasticsearch-model' unless defined? ( JRUBY_VERSION )
4
5
5
6
__current__ = Pathname ( File . expand_path ( '..' , __FILE__ ) )
6
7
@@ -25,15 +26,9 @@ namespace :bundle do
25
26
task :install do
26
27
subprojects . each do |project |
27
28
puts '-' *80
28
- sh "bundle install --gemfile #{ __current__ . join ( project ) } /Gemfile "
29
+ sh "cd #{ __current__ . join ( project ) } && bundle exec rake bundle:install "
29
30
puts
30
31
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"
37
32
end
38
33
39
34
desc "Remove Gemfile.lock in all subprojects"
@@ -60,7 +55,7 @@ namespace :test do
60
55
end
61
56
62
57
desc "Run Elasticsearch (Docker)"
63
- task :setup_elasticsearch do
58
+ task :setup_elasticsearch_docker do
64
59
begin
65
60
sh <<-COMMAND . gsub ( /^\s */ , '' ) . gsub ( /\s {1,}/ , ' ' )
66
61
docker run -d=true \
@@ -70,15 +65,30 @@ namespace :test do
70
65
--env "cluster.routing.allocation.disk.threshold_enabled=false" \
71
66
--publish 9250:9200 \
72
67
--rm \
73
- docker.elastic.co/elasticsearch/elasticsearch:6.4.0
68
+ docker.elastic.co/elasticsearch/elasticsearch:${ELASTICSEARCH_VERSION}
74
69
COMMAND
75
70
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' ] ,
77
72
number_of_nodes : 1 ) . wait_for_green
78
73
rescue
79
74
end
80
75
end
81
76
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
+
82
92
desc "Run integration tests in all subprojects"
83
93
task :integration => :setup_elasticsearch do
84
94
# 1/ elasticsearch-model
@@ -106,8 +116,13 @@ namespace :test do
106
116
107
117
desc "Run all tests in all subprojects"
108
118
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
111
126
end
112
127
113
128
namespace :cluster do
0 commit comments