forked from ChristopherRabotin/bungiesearch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
runtests.sh
executable file
·76 lines (65 loc) · 2.17 KB
/
runtests.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env bash
# pass in --cluster as an argument to start a cluster instead of a single node
set -e
trap 'jobs -p | xargs kill -9' EXIT
CLUSTER_URL=http://127.0.0.1:9200
ES_PATH=elasticsearch
if [ ${TRAVIS} ]; then
ES_PATH=./elasticsearch-2.3.0/bin/elasticsearch
fi
function has_command() {
type $1 &> /dev/null
}
function is_responding() {
curl --output /dev/null --fail --silent $1
}
function wait_for_cluster() {
echo 'Waiting on elasticsearch to be ready on port 9200'
until is_responding "$CLUSTER_URL/_cluster/health?wait_for_nodes=$1&wait_for_status=green"; do
printf '.'
sleep 1
done
echo
}
if ! is_responding $CLUSTER_URL; then
if ! has_command elasticsearch; then
echo 'No elasticsearch command found and no server running'
echo 'Elasticsearch cluster must be running on port 9200'
exit 1
else
if [ "$1" != "--cluster" ]; then
echo 'Starting single elasticsearch node'
$ES_PATH -D es.index.number_of_replicas=0 &> /dev/null &
wait_for_cluster 1
else
echo 'Starting elasticsearch cluster with 2 nodes'
$ES_PATH \
-D es.cluster.name="mycluster" \
-D es.node.name="mycluster-node2" \
-D es.node.master=true \
-D es.node.data=false \
-D es.index.number_of_replicas=0 \
-D es.network.host=127.0.0.1 \
-D es.foreground=yes \
-D es.discovery.zen.ping.multicast.enabled=false \
-D es.discovery.zen.ping.unicast.hosts=127.0.0.1:9300,127.0.0.1:9301,127.0.0.1:9302 &> /dev/null &
$ES_PATH \
-D es.cluster.name="mycluster" \
-D es.node.name="mycluster-node2" \
-D es.node.master=false \
-D es.node.data=true \
-D es.index.number_of_replicas=0 \
-D es.network.host=127.0.0.1 \
-D es.foreground=yes \
-D es.discovery.zen.ping.multicast.enabled=false \
-D es.discovery.zen.ping.unicast.hosts=127.0.0.1:9300,127.0.0.1:9301,127.0.0.1:9302 &> /dev/null &
wait_for_cluster 2
fi
fi
fi
python -B tests/manage.py test
# only collect coverage in travis ci
if [ ${COVERAGE} ]; then
echo 'Starting to collect coverage...'
coverage run --source=tests tests/manage.py test
fi