-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.sh
executable file
·109 lines (101 loc) · 2.23 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/bin/sh
set -e -x
cd "$(dirname "$0")"
for NAME in "socket"
do
cd "example/$NAME"
go build
./$NAME &
PID="$!"
i=1;
while [[ i -le 5 ]] ;
do
OLDPID="$PID"
sleep 1
kill -HUP "$PID"
sleep 2
PID="$(pgrep "$NAME")"
i=$((i+1));
done
[ "$(nc "127.0.0.1" "59081")" = "Hello, socket!" ]
kill -TERM "$PID"
sleep 2
[ -z "$(pgrep "$NAME")" ]
cd "$OLDPWD"
done
for NAME in "httpandsocket"
do
cd "example/$NAME"
go build
./$NAME &
PID="$!"
i=1;
while [[ i -le 5 ]] ;
do
echo "========= ${i} ================"
OLDPID="$PID"
sleep 2
[ "$(nc "127.0.0.1" "59081")" = "Hello, socket!" ]
[ "$(curl "http://127.0.0.1:58081")" = "Hello, http!" ]
kill -HUP "$PID"
sleep 2
PID="$(pgrep "$NAME")"
i=$((i+1));
done;
[ "$(nc "127.0.0.1" "59081")" = "Hello, socket!" ]
[ "$(curl "http://127.0.0.1:58081")" = "Hello, http!" ]
kill -TERM "$PID"
sleep 3
[ -z "$(pgrep "$NAME")" ]
cd "$OLDPWD"
done
for NAME in "http"
do
cd "example/$NAME"
go build
./$NAME &
PID="$!"
i=1;
while [[ i -le 5 ]] ;
do
echo "========= ${i} ================"
OLDPID="$PID"
sleep 2
[ "$(curl "http://127.0.0.1:58081")" = "Hello, http!" ]
kill -HUP "$PID"
sleep 2
PID="$(pgrep "$NAME")"
i=$((i+1));
done;
[ "$(curl "http://127.0.0.1:58081")" = "Hello, http!" ]
kill -TERM "$PID"
sleep 3
[ -z "$(pgrep "$NAME")" ]
cd "$OLDPWD"
done
for NAME in "multihttp"
do
cd "example/$NAME"
go build
./$NAME &
PID="$!"
i=1;
while [[ i -le 5 ]] ;
do
echo "========= ${i} ================"
OLDPID="$PID"
sleep 2
[ "$(curl "http://127.0.0.1:58081")" = "Hello, http!" ]
[ "$(curl "http://127.0.0.1:58082")" = "Hello, http!" ]
kill -HUP "$PID"
sleep 2
PID="$(pgrep "$NAME")"
i=$((i+1));
done;
[ "$(curl "http://127.0.0.1:58081")" = "Hello, http!" ]
[ "$(curl "http://127.0.0.1:58082")" = "Hello, http!" ]
kill -TERM "$PID"
sleep 3
[ -z "$(pgrep "$NAME")" ]
cd "$OLDPWD"
done