Mercurial > hg > ngx_http_upstream_keepalive
comparison t/proxy.t @ 33:52ca695446d3
Keepalive: more connection validity checks.
Make sure to not cache connections with errors detected, as well as EOF
already read or pending data present. Call ngx_handle_read_event() for
event methods which need it.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Wed, 31 Aug 2011 21:21:14 +0400 |
parents | f3b50effc1d4 |
children |
comparison
equal
deleted
inserted
replaced
32:9aa0d263f2a7 | 33:52ca695446d3 |
---|---|
75 $t->run(); | 75 $t->run(); |
76 open STDERR, ">&", \*OLDERR; | 76 open STDERR, ">&", \*OLDERR; |
77 }; | 77 }; |
78 plan(skip_all => 'no keepalive patches') if $@; | 78 plan(skip_all => 'no keepalive patches') if $@; |
79 | 79 |
80 $t->plan(42); | 80 $t->plan(50); |
81 | 81 |
82 ############################################################################### | 82 ############################################################################### |
83 | 83 |
84 # There are 3 mostly independend modes of upstream operation: | 84 # There are 3 mostly independend modes of upstream operation: |
85 # | 85 # |
196 like(http_get('/inmemory/complex2'), qr/SEE-THIS$n/, | 196 like(http_get('/inmemory/complex2'), qr/SEE-THIS$n/, |
197 'inmemory complex chunked 2'); | 197 'inmemory complex chunked 2'); |
198 | 198 |
199 like(http_get('/inmemory/chunk01'), qr/set: $/, 'inmemory 0 chunk'); | 199 like(http_get('/inmemory/chunk01'), qr/set: $/, 'inmemory 0 chunk'); |
200 like(http_get('/inmemory/chunk02'), qr/set: $/, 'inmemory 0 chunk 2'); | 200 like(http_get('/inmemory/chunk02'), qr/set: $/, 'inmemory 0 chunk 2'); |
201 | |
202 # closed connection tests | |
203 | |
204 like(http_get('/buffered/closed1'), qr/200 OK/, 'buffered closed 1'); | |
205 like(http_get('/buffered/closed2'), qr/200 OK/, 'buffered closed 2'); | |
206 like(http_get('/unbuffered/closed1'), qr/200 OK/, 'unbuffered closed 1'); | |
207 like(http_get('/unbuffered/closed2'), qr/200 OK/, 'unbuffered closed 2'); | |
208 like(http_get('/inmemory/closed1'), qr/200 OK/, 'inmemory closed 1'); | |
209 like(http_get('/inmemory/closed2'), qr/200 OK/, 'inmemory closed 2'); | |
210 | |
211 # check for errors, shouldn't be any | |
212 | |
213 like(`grep -F '[alert]' ${\($t->testdir())}/error.log`, qr/^$/s, 'no alerts'); | |
214 like(`grep -F '[error]' ${\($t->testdir())}/error.log`, qr/^$/s, 'no errors'); | |
201 | 215 |
202 ############################################################################### | 216 ############################################################################### |
203 | 217 |
204 sub http_daemon { | 218 sub http_daemon { |
205 my $server = IO::Socket::INET->new( | 219 my $server = IO::Socket::INET->new( |
314 CRLF; | 328 CRLF; |
315 print $client | 329 print $client |
316 "0" . CRLF . CRLF | 330 "0" . CRLF . CRLF |
317 unless $headers =~ /^HEAD/i; | 331 unless $headers =~ /^HEAD/i; |
318 | 332 |
333 } elsif ($uri =~ m/closed/) { | |
334 print $client | |
335 "HTTP/1.1 200 OK" . CRLF . | |
336 "X-Request: $rcount" . CRLF . | |
337 "X-Connection: $ccount" . CRLF . | |
338 "Connection: close" . CRLF . | |
339 "Content-Length: 12" . CRLF . CRLF . | |
340 "0123456789" . CRLF; | |
341 last; | |
342 | |
319 } else { | 343 } else { |
320 print $client | 344 print $client |
321 "HTTP/1.1 404 Not Found" . CRLF . | 345 "HTTP/1.1 404 Not Found" . CRLF . |
322 "X-Request: $rcount" . CRLF . | 346 "X-Request: $rcount" . CRLF . |
323 "X-Connection: $ccount" . CRLF . | 347 "X-Connection: $ccount" . CRLF . |