-
Notifications
You must be signed in to change notification settings - Fork 254
/
Copy pathsleep.t
200 lines (158 loc) · 2.8 KB
/
sleep.t
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
# vi:filetype=
use lib 'lib';
use Test::Nginx::Socket;
plan tests => 2 * blocks();
run_tests();
__DATA__
=== TEST 1: sanity
--- config
location /echo {
echo_sleep 1;
}
--- request
GET /echo
--- response_body
=== TEST 2: fractional delay
--- config
location /echo {
echo_sleep 0.01;
}
--- request
GET /echo
--- response_body
=== TEST 3: leading echo
--- config
location /echo {
echo before...;
echo_sleep 0.01;
}
--- request
GET /echo
--- response_body
before...
=== TEST 4: trailing echo
--- config
location /echo {
echo_sleep 0.01;
echo after...;
}
--- request
GET /echo
--- response_body
after...
=== TEST 5: two echos around sleep
--- config
location /echo {
echo before...;
echo_sleep 0.01;
echo after...;
}
--- request
GET /echo
--- response_body
before...
after...
=== TEST 6: interleaving sleep and echo
--- config
location /echo {
echo 1;
echo_sleep 0.01;
echo 2;
echo_sleep 0.01;
}
--- request
GET /echo
--- response_body
1
2
=== TEST 7: interleaving sleep and echo with echo at the end...
--- config
location /echo {
echo 1;
echo_sleep 0.01;
echo 2;
echo_sleep 0.01;
echo 3;
}
--- request
GET /echo
--- response_body
1
2
3
=== TEST 8: flush before sleep
we didn't really test the actual effect of "echo_flush" here...
merely checks if it croaks if appears.
--- config
location /flush {
echo hi;
echo_flush;
echo_sleep 0.01;
echo trees;
}
--- request
GET /flush
--- response_body
hi
trees
=== TEST 9: flush does not increment opcode pointer itself
--- config
location /flush {
echo hi;
echo_flush;
echo trees;
}
--- request
GET /flush
--- response_body
hi
trees
=== TEST 10: sleep through a proxy
this reveals a bug in v0.19 and the bug is fixed in v0.20.
--- config
location /proxy {
proxy_pass $scheme://127.0.0.1:$server_port/entry';
}
location /entry {
echo_sleep 0.001;
echo done;
}
--- request
GET /proxy
--- response_body_like
done
=== TEST 11: abnormally quit
--- config
location /quit {
echo before;
echo_flush;
echo_sleep 1;
echo after;
}
--- request
GET /quit
--- response_body
before
after
=== TEST 12: two echos around sleep (HEAD)
--- config
location /echo {
echo before...;
echo_sleep 0.01;
echo after...;
}
--- request
HEAD /echo
--- response_body
=== TEST 13: sleep by variable
--- config
location ~ ^/sleep/(.+) {
echo before...;
echo_sleep $1;
echo after...;
}
--- request
GET /sleep/0.01
--- response_body
before...
after...