Mercurial > hg > nginx-tests
changeset 1703:8b7ab9245916
Tests: mirror_proxy.t speedup.
The failing "mirror delay" test doesn't have to wait for a hung connection.
The hang is anyway manifested with a socket leak alert. This eliminates an
unnecessary read timeout delay in the client and allows to enable the test
on win32. Additionally, in the mirror_request_body test, disabled passing
Content-Length to backend to avoid wasting time waiting for an absent body.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Fri, 18 Jun 2021 20:02:00 +0300 |
parents | f0a02a429a59 |
children | 4b808861a318 |
files | mirror_proxy.t |
diffstat | 1 files changed, 27 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/mirror_proxy.t Fri Jun 18 03:54:36 2021 +0300 +++ b/mirror_proxy.t Fri Jun 18 20:02:00 2021 +0300 @@ -12,6 +12,8 @@ use Test::More; +use IO::Select; + BEGIN { use FindBin; chdir($FindBin::Bin); } use lib 'lib'; @@ -59,6 +61,12 @@ proxy_pass http://127.0.0.1:8082; limit_req zone=slow burst=1; } + + location /mirror/off { + internal; + proxy_pass http://127.0.0.1:8082; + proxy_set_header Content-Length ""; + } } server { @@ -67,7 +75,6 @@ server_name localhost; location / { - client_body_timeout 1s; proxy_pass http://127.0.0.1:$server_port/return204; access_log %%TESTDIR%%/test.log test; add_header X-Body $request_body; @@ -90,19 +97,10 @@ # delayed subrequest should not affect main request processing nor stuck itself -SKIP: { -skip 'hang on win32', 1 if $^O eq 'MSWin32' and !$ENV{TEST_NGINX_UNSAFE}; - -TODO: { -local $TODO = 'not yet'; +my $s = http_post('/delay?1', start => 1); +like(read_keepalive($s), qr/X-Body: 1234567890\x0d?$/m, 'mirror delay'); -like(http_post('/delay?1'), qr/X-Body: 1234567890\x0d?$/m, 'mirror delay'); - -} - -} - -$t->todo_alerts() unless $^O eq 'MSWin32'; +$t->todo_alerts(); $t->stop(); my $log = $t->read_file('test.log'); @@ -114,9 +112,9 @@ ############################################################################### sub http_post { - my ($url) = @_; + my ($url, %extra) = @_; - http(<<EOF); + http(<<EOF, %extra); POST $url HTTP/1.0 Host: localhost Content-Length: 10 @@ -125,4 +123,18 @@ EOF } +sub read_keepalive { + my ($s) = @_; + my $data = ''; + + while (IO::Select->new($s)->can_read(3)) { + sysread($s, my $buffer, 4096) or last; + $data .= $buffer; + last if $data =~ /^\x0d\x0a/ms; + } + + log_in($data); + return $data; +} + ###############################################################################