Mercurial > hg > nginx-tests
changeset 824:9caacdb56b53
Tests: added test for resolver timeout after aborted request.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Wed, 27 Jan 2016 13:58:19 +0300 |
parents | 9623d353f066 |
children | ff8c68cd2be4 |
files | http_resolver.t |
diffstat | 1 files changed, 23 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/http_resolver.t Wed Jan 27 13:56:40 2016 +0300 +++ b/http_resolver.t Wed Jan 27 13:58:19 2016 +0300 @@ -65,6 +65,11 @@ location /invalid { proxy_pass http://$host:8080/backend; } + location /long { + resolver 127.0.0.1:8081; + resolver_timeout 4s; + proxy_pass http://$host:8080/backend; + } location /resend { resolver 127.0.0.1:8081; resolver_timeout 8s; @@ -91,7 +96,7 @@ $t->run_daemon(\&dns_daemon, 8082, $t); $t->run_daemon(\&dns_daemon, 8089, $t); -$t->run()->plan(34); +$t->run()->plan(35); $t->waitforfile($t->testdir . '/8081'); $t->waitforfile($t->testdir . '/8082'); @@ -240,6 +245,19 @@ like(http_host_header('fe_id.example.net', '/'), qr/502 Bad/, 'format error'); +# several requests waiting on same name query +# 1st request aborts before name is resolved +# 2nd request completes on resolver timeout + +$s = http_host_header('timeout.example.net', '/long', start => 1); +$s2 = http_host_header('timeout.example.net', '/long', start => 1); + +select undef, undef, undef, 1.1; + +close $s; + +like(http_end($s2), qr/502 Bad/, 'timeout after aborted request'); + ############################################################################### sub http_host_header { @@ -370,6 +388,10 @@ push @rdata, pack("n3N nCa5n", 0xc00c, CNAME, IN, $ttl, 8, 5, 'alias', 0xc012); + } elsif ($name eq 'timeout.example.net') { + select undef, undef, undef, 2.1; + return; + } elsif ($name eq 'cname_a.example.net') { push @rdata, pack("n3N nCa5n", 0xc00c, CNAME, IN, $ttl, 8, 5, 'alias', 0xc014);