-
Notifications
You must be signed in to change notification settings - Fork 3
/
run-smoketests.sh
executable file
·50 lines (41 loc) · 1.39 KB
/
run-smoketests.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
#!/usr/bin/env bash
# (C) Copyright IBM Corp. 2020
#
# SPDX-License-Identifier: Apache-2.0
set -x
passing=0
failing=0
output=""
./src/hri -config-path=test/spec/test_config/valid_config.yml -kafka-properties=security.protocol:sasl_ssl,sasl.mechanism:PLAIN,sasl.username:token,sasl.password:$KAFKA_PASSWORD,ssl.endpoint.identification.algorithm:https >/dev/null &
sleep 1
HRI_WEB_SERVER_STATUS=$(curl -k --write-out "%{http_code}\n" --silent "$HRI_URL/healthcheck" )
if [ $HRI_WEB_SERVER_STATUS -eq 200 ]; then
passing=$((passing+1))
failure='/>'
else
failing=$((failing+1))
HRI_API_ERROR=$(curl "$HRI_URL/healthcheck")
failure="><failure message=\"Expected HRI Web Server healthcheck status to return code 200\" type=\"FAILURE\">$HRI_API_ERROR</failure></testcase>"
fi
PROCESS_ID=$(lsof -iTCP:1323 -sTCP:LISTEN | grep -o '[0-9]\+' | sed 1q)
kill $PROCESS_ID
output="$output\n<testcase classname=\"HRI-API\" name=\"GET Healthcheck\" time=\"0\"${failure}"
echo
echo "----------------"
echo "Final Results"
echo "----------------"
echo "PASSING: $passing"
echo "FAILING: $failing"
total=$(($passing + $failing))
date=`date`
header="<testsuite name=\"Smoke tests\" tests=\"$total\" failures=\"$failing\" errors=\"$failing\" skipped=\"0\" timestamp=\"${date}\" time=\"0\">"
footer="</testsuite>"
filename="smoketests.xml"
cat << EOF > $filename
$header
$output
$footer
EOF
if [ $failing -gt 0 ]; then
exit 1
fi