1
1
#! /bin/bash
2
2
set -ex
3
3
4
+ function finish {
5
+ last_result=$?
6
+ set +e
7
+ [[ $last_result -ne 0 ]] && cat /tmp/elasticsearch.log
8
+ }
9
+ trap finish EXIT
10
+
4
11
setup_es () {
5
12
download_url=$1
6
13
curl -sL $download_url > elasticsearch.tar.gz
@@ -10,10 +17,17 @@ setup_es() {
10
17
}
11
18
12
19
start_es () {
13
- es_args=$1
14
- elasticsearch/bin/elasticsearch $es_args > /tmp/elasticsearch.log &
15
- sleep 10
16
- curl http://localhost:9200 && echo " ES is up!" || cat /tmp/elasticsearch.log
20
+ es_args=$@
21
+ elasticsearch/bin/elasticsearch $es_args > /tmp/elasticsearch.log 2> /dev/null &
22
+ count=120
23
+ echo " Waiting for elasticsearch to respond..."
24
+ while ! curl --silent localhost:9200 && [[ $count -ne 0 ]]; do
25
+ count=$(( $count - 1 ))
26
+ [[ $count -eq 0 ]] && return 1
27
+ sleep 1
28
+ done
29
+ echo " Elasticsearch is Up !"
30
+ return 0
17
31
}
18
32
19
33
if [[ " $INTEGRATION " != " true" ]]; then
22
36
if [[ " $ES_VERSION " == 5.* ]]; then
23
37
setup_es https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/$ES_VERSION /elasticsearch-$ES_VERSION .tar.gz
24
38
start_es -Ees.script.inline=true -Ees.script.indexed=true -Ees.script.file=true
25
- bundle exec rspec -fd spec --tag integration --tag version_5x
26
- else
39
+ bundle exec rspec -fd spec --tag integration --tag version_5x --tag integration_2x_plus
40
+ elif [[ " $ES_VERSION " == 2. * ]] ; then
27
41
setup_es https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-$ES_VERSION .tar.gz
28
42
start_es -Des.script.inline=on -Des.script.indexed=on -Des.script.file=on
29
43
bundle exec rspec -fd spec --tag integration --tag ~ version_5x
44
+ else
45
+ setup_es https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-$ES_VERSION .tar.gz
46
+ start_es -Des.script.inline=on -Des.script.indexed=on -Des.script.file=on
47
+ bundle exec rspec -fd spec --tag integration --tag ~ version_5x --tag ~ version_2x_plus
30
48
fi
31
49
fi
0 commit comments