-
Notifications
You must be signed in to change notification settings - Fork 22
/
runtests
executable file
·88 lines (80 loc) · 2.42 KB
/
runtests
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
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/bash
##############################################################################
#
# Copyright (C) Zenoss, Inc. 2018, all rights reserved.
#
# This content is made available according to terms specified in
# License.zenoss under the directory where your Zenoss product is installed.
#
##############################################################################
SOLR_TEST_PORT="8993"
ZK_TEST_PORT="9993" # embedded ZK port is SOLR_TEST_PORT + 1000
start_solr() {
echo "Preparing configuration files..."
mkdir -p /tmp/testing/solr/configsets /tmp/testing/solr/data
cp -rf /opt/solr/server/solr/configsets/zenoss_model/ /tmp/testing/solr/configsets
cp -f /opt/solr/server/solr/solr.xml /tmp/testing/solr/data
cp -f /opt/solr/server/solr/zoo.cfg /tmp/testing/solr/data
echo "name=zenoss_model" > /tmp/testing/solr/configsets/zenoss_model/core.properties
echo "Starting Solr for testing purposes..."
/opt/solr/bin/solr start \
-f \
-p $SOLR_TEST_PORT \
-s /tmp/testing/solr/data \
-v \
-cloud \
-Dsolr.log.muteconsole \
-DzkRun \
-DnumShards=1 \
-Dbootstrap_confdir=/tmp/testing/solr/configsets/zenoss_model/conf \
-Dcollection.configName=zenoss_model \
-Dsolr.jetty.request.header.size=1000000 \
> "/tmp/testing/solr-console.log" \
2>&1 \
&
export SOLR_TEST_PID=$!
echo "SOLR_TEST_PID=$SOLR_TEST_PID"
echo "SOLR_TEST_PORT=$SOLR_TEST_PORT"
echo "Waiting for Solr to start..."
until $(curl -A 'Solr answering healthcheck' -sI http://localhost:$SOLR_TEST_PORT/solr/admin/cores | grep -q 200); do
sleep 5
done
echo "Solr is running"
echo "Creating zenoss_model collection"
/opt/solr/bin/solr create_collection \
-c zenoss_model \
-d /tmp/testing/solr/configsets/zenoss_model/conf \
-n zenoss_model \
-p $SOLR_TEST_PORT 1> "/tmp/testing/solr-console.log" \
2>&1 \
&
until $(/opt/solr/bin/solr healthcheck -c zenoss_model -z localhost:$ZK_TEST_PORT | grep -q "zenoss_model"); do
sleep 5
done
echo "Collection is created"
}
stop_solr() {
echo "Stopping Solr (up to 180 sec)..."
/opt/solr/bin/solr stop -p $SOLR_TEST_PORT 1> /dev/null
}
run_tests() {
echo "Starting runtest.py"
$PYTHON $ZENHOME/bin/runtests.py $@
local exit_code=$?
echo "Tests finished with exit_code=$exit_code"
return $exit_code
}
if [ "$1" == "--no-solr" ]; then
shift
run_tests $@
EXIT_CODE=$?
elif [ "$1" == "--help" ]; then
run_tests $@
EXIT_CODE=$?
else
start_solr
run_tests $@
EXIT_CODE=$?
stop_solr
fi
exit $EXIT_CODE