-
Notifications
You must be signed in to change notification settings - Fork 13
/
test_backend.sh
executable file
·74 lines (69 loc) · 2.1 KB
/
test_backend.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
#!/bin/bash -xue
cd `dirname $0`
WITH_SPHYNX='false'
INTERACTIVE='false'
while getopts 'si' flag; do
case "${flag}" in
s) WITH_SPHYNX='true' ;;
i) INTERACTIVE='true' ;;
esac
done
export WITH_SPHYNX=$WITH_SPHYNX
if $WITH_SPHYNX; then
# Start Sphynx.
TMP=$(mktemp -d)
SPHYNX_PID_FILE=${TMP}/sphynx_pid
export SPHYNX_PORT=$[ 9400 + RANDOM % 100 ]
export SPHYNX_CERT_DIR=$TMP/sphynx_cert
export ORDERED_SPHYNX_DATA_DIR=$TMP/ordered_sphynx_data
export UNORDERED_SPHYNX_DATA_DIR=$TMP/unordered_sphynx_data
export KITE_ALLOW_PYTHON=yes
export KITE_ALLOW_R=yes
# Some randomization gives different results depending on the
# thread count. Fix it for the unit tests.
export NETWORKIT_THREADS=4
if [ -f $SPHYNX_PID_FILE ]; then
kill `cat $SPHYNX_PID_FILE` || true
fi
mkdir -p ${SPHYNX_CERT_DIR}
openssl req -x509 -sha256 -newkey rsa:4096 \
-keyout "${SPHYNX_CERT_DIR}/private-key.pem" \
-out "${SPHYNX_CERT_DIR}/cert.pem" -days 365 -nodes \
-subj "/C=/ST=/L=/O=Lynx Analytics/OU=Org/CN=localhost"
cd sphynx
.build/lynxkite-sphynx/lynxkite-sphynx &
cd -
$(dirname $0)/tools/wait_for_port.sh $SPHYNX_PORT
echo "Sphynx running on port $SPHYNX_PORT"
echo $! > $SPHYNX_PID_FILE
function kill_sphynx {
echo "Shutting down Sphynx."
SPHYNX_PID=`cat ${SPHYNX_PID_FILE}`
kill $SPHYNX_PID
while kill -0 $SPHYNX_PID 2> /dev/null; do sleep 1; done
rm -rf "$TMP"
}
trap kill_sphynx EXIT ERR
fi
mkdir -p logs
rm -f logs/test-*
if $INTERACTIVE; then
sbt
else
if $WITH_SPHYNX; then
sbt 'testOnly -- -l "SparkOnly RequiresDocker"'
else
sbt 'testOnly -- -l "SphynxOnly RequiresDocker"'
fi
fi
# We'll check if the logfile contains 'future failed' lines; these
# indicate errors that the test framework cannot catch. In case such
# lines occur, we rename the file logs/test-xxxxxx to logs/failed-xxxxxx
# so that the next invocation of test_backend.sh will not delete it.
thelogfile=logs/test-*
echo logfile: $thelogfile
if grep "future failed" -A1 logs/test-*; then
failedlog=`echo $thelogfile | sed s:logs/test:logs/failed:`
mv $thelogfile $failedlog
exit 1
fi