generated from CDCgov/template
-
Notifications
You must be signed in to change notification settings - Fork 6
/
e2e-execute.sh
executable file
·56 lines (44 loc) · 1.14 KB
/
e2e-execute.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
#!/usr/bin/env bash
set -e
shadowJar() {
echo "Running shadowJar..."
./gradlew --no-daemon clean shadowJar
}
start_api() {
pushd ./app/
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SUB_DIR="build/libs"
JAR_NAME="app-all.jar"
echo 'Starting API'
REPORT_STREAM_URL_PREFIX= java -jar "${DIR}"/"${SUB_DIR}"/"${JAR_NAME}" > /dev/null &
export API_PID="${!}"
echo "API starting at PID ${API_PID}"
popd
}
wait_for_api() {
attempt_counter=0
max_attempts=20
until curl --output /dev/null --silent --head --fail http://localhost:8080/health; do
if [ "${attempt_counter}" -eq "${max_attempts}" ];then
echo 'Done waiting for API to respond'
exit 1
fi
attempt_counter=$(($attempt_counter+1))
echo 'Waiting for API to respond'
sleep 5
done
echo 'API is responding'
}
run_tests() {
echo 'Running the end-to-end tests'
./gradlew --no-daemon e2e:clean e2e:test
}
cleanup() {
echo "Killing API at PID ${API_PID}"
kill "${API_PID}"
}
trap cleanup EXIT # Run the cleanup function on exit
shadowJar
start_api
wait_for_api
run_tests