-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.sh
More file actions
executable file
·61 lines (54 loc) · 1.6 KB
/
test.sh
File metadata and controls
executable file
·61 lines (54 loc) · 1.6 KB
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
#! /bin/bash
# Small script for testing endpoints. Every endpoint will return JSON response.
function endpointTesting()
{
declare -a endpoints=( "agencyList"
"routeList/sf-muni"
"routeConfig/sf-muni/E"
"predictByStopId/sf-muni/15184"
"predictByStop/sf-muni/E/5184"
"predictByStop/sf-muni/E/5184/useShortTitles"
"predictionsForMultiStops/sf-muni/N|6997"
"predictionsForMultiStops/sf-muni/N|6997/N|3909/useShortTitles"
"schedule/agencyList/E"
"vehicleLocations/sf-muni/E/0"
"stats" )
for i in "${endpoints[@]}"
do
if curl -s --head --request GET http://127.0.0.1:8001/api/v1/$i | grep "json" > /dev/null; then
sleep 0.1
echo "Endpoint "$i "is OK"
else
echo "Endpoint "$i "is NOT OK"
fi
done
}
function gzipTesting()
{
if curl -s -H "Accept-Encoding: gzip, deflate" --head --request GET http://127.0.0.1:8001/api/v1/agencyList | grep "gzip" > /dev/null; then
sleep 0.1
echo "gzip responses is OK"
else
echo "gzip responses is NOT OK"
fi
}
function queryErrors()
{
if curl -s --request GET http://127.0.0.1:8001/api/v1/predictByStop/sf-muni/E/518s4 | grep "Incorrect" > /dev/null; then
sleep 0.1
echo "query errors are handled"
else
echo "query responses are not handled"
fi
}
echo "Checking Endpoints"
echo "=================="
endpointTesting
echo
echo "Checking gzip responses"
echo "======================="
gzipTesting
echo
echo "Checking error handeling in query points of api"
echo "==============================================="
queryErrors