-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhealthcheck.sh
38 lines (32 loc) · 996 Bytes
/
healthcheck.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
#!/bin/bash
# Random difficulty, Random Map, Random areas
DIFFICULTY=$(shuf -i 0-2 -n 1)
MAP_ID=$(shuf -i 0-4294967295 -n 1)
AREA_IDS=$(shuf -i 1-136 -n 5)
# Create session
SESSION_JSON=$(cat << EOF | curl --fail -d @- http://localhost:8080/sessions/
{
"difficulty" : $DIFFICULTY,
"mapid" : $MAP_ID
}
EOF
)
# Isolate Session ID and test it
SESSION_ID=$(echo $SESSION_JSON | jq -r .id)
if [ -z $SESSION_ID ]; then
s6-svc -ruwr /var/run/s6/services/d2mapapi
exit 1
fi
# Request data for the test areas
for AREA_ID in $AREA_IDS ; do
# Pull the map data for this area
AREA_JSON=$(curl -s --fail http://localhost:8080/sessions/$SESSION_ID/areas/$AREA_ID)
# Isolate the level origin and test it
LEVEL_ORIGIN=$(echo $AREA_JSON | jq -r ".levelOrigin")
if [ -z $LEVEL_ORIGIN ]; then
s6-svc -ruwr /var/run/s6/services/d2mapapi
exit 1
fi
done
# Close session
curl -s --fail -X DELETE http://localhost:8080/sessions/$SESSION_ID || s6-svc -ruwr /var/run/s6/services/d2mapapi