forked from cryostatio/cryostat-legacy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrepeated-integration-tests.bash
executable file
·70 lines (59 loc) · 1.67 KB
/
repeated-integration-tests.bash
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
#!/bin/bash
set -o pipefail
failures=0
numeric='^[0-9]+$'
if [[ "$1" =~ $numeric ]]; then
runs="$1"
else
runs=1
fi
POD_NAME="$(xpath -q -e 'project/properties/cryostat.itest.podName/text()' pom.xml)"
CONTAINER_NAME="$(xpath -q -e 'project/properties/cryostat.itest.containerName/text()' pom.xml)"
function cleanup() {
if podman pod exists "${POD_NAME}"; then
mvn exec:exec@destroy-pod
fi
}
trap cleanup EXIT
cleanup
STARTFLAGS=(
"exec:exec@create-pod"
"exec:exec@start-jfr-datasource"
"exec:exec@start-grafana"
"exec:exec@start-cryostat"
"exec:exec@wait-for-cryostat"
"exec:exec@wait-for-jfr-datasource"
"exec:exec@wait-for-grafana"
"failsafe:integration-test"
"failsafe:verify"
)
STOPFLAGS=(
"exec:exec@destroy-pod"
)
if command -v ansi2txt >/dev/null; then
STARTFLAGS+=("-Dstyle.color=always")
STOPFLAGS+=("-Dstyle.color=always")
PIPECLEANER=ansi2txt
else
PIPECLEANER=cat
fi
DIR="$(dirname "$(readlink -f "$0")")"
runcount=0
while [ "${runcount}" -lt "${runs}" ]; do
timestamp="$(date -Iminutes)"
client_logfile="$DIR/target/${POD_NAME}-${timestamp}.client.log"
server_logfile="$DIR/target/${POD_NAME}-${timestamp}.server.log"
mvn "${STARTFLAGS[@]}" |& tee -a >($PIPECLEANER >> "${client_logfile}")
if [ "$?" -ne 0 ]; then
failures=$((failures+1))
fi
runcount=$((runcount+1))
podman pod logs -c "${CONTAINER_NAME}" "${POD_NAME}" &>> "${server_logfile}"
mvn "${STOPFLAGS[@]}" |& tee -a >($PIPECLEANER >> "${client_logfile}")
done
echo
echo "########################"
echo "Test runs completed"
echo "Failures: ${failures}"
echo "Runs: ${runcount}/${runs}"
exit ${failures}