-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest.sh
executable file
·52 lines (38 loc) · 1.04 KB
/
test.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
#!/bin/bash
trap "printf '\n' && trap - SIGTERM && kill -- -$$" SIGINT SIGTERM EXIT
set -x
# example docker:
# CMD="docker run --rm -i -p 9001:9001 <image> --port=9001" ./test.sh
exec 3< <(${CMD="go run . --port=9001"} 2>&1)
read <&3 line
set +x
if [[ $line =~ "Starting instance" ]]; then
echo $line
else
exit 1
fi
RESULT=$(curl -s -H 'User-Agent:' -H 'Header1: header1' -H 'Header2: header2' localhost:9001)
WANT='Instance name: example
Accept: [*/*]
Header1: [header1]
Header2: [header2]
Host: [localhost:9001]'
printf "===\nResult:\n===\n$RESULT\n"; printf "===\nWant:\n===\n$WANT\n===\n";
if [[ "$RESULT" != "$WANT" ]]; then
printf "test failed"; exit 1
else
echo "test passed"
fi
RESULT=$(curl -s -w "%{http_code}\n" "localhost:9001/livenessProbe")
if [[ "$RESULT" != 200 ]]; then
printf "test failed"; exit 1
else
echo "test passed"
fi
RESULT=$(curl -s -w "%{http_code}\n" "localhost:9001/readinessProbe")
if [[ "$RESULT" != 200 ]]; then
printf "test failed"; exit 1
else
echo "test passed"
fi
# Hello World