Mercurial > hg > nginx-tests
comparison proxy.t @ 1079:cbc8641a204e
Tests: fixed "proxy connect timeout" http tests.
Previously, proxy connection hadn't been established before delay so
proxy_connect_timeout had no chances to break connection. Now used backend
with delay greater than proxy_connect_timeout value.
author | Andrey Zelenkov <zelenkov@nginx.com> |
---|---|
date | Mon, 21 Nov 2016 02:07:21 +0300 |
parents | e4d5e7afb6e0 |
children | 41690e007ad8 |
comparison
equal
deleted
inserted
replaced
1078:36437be7b3f4 | 1079:cbc8641a204e |
---|---|
54 location /var { | 54 location /var { |
55 proxy_pass http://$arg_b; | 55 proxy_pass http://$arg_b; |
56 proxy_read_timeout 1s; | 56 proxy_read_timeout 1s; |
57 proxy_connect_timeout 2s; | 57 proxy_connect_timeout 2s; |
58 } | 58 } |
59 | |
60 location /timeout { | |
61 proxy_pass http://127.0.0.1:8081; | |
62 proxy_connect_timeout 2s; | |
63 } | |
59 } | 64 } |
60 } | 65 } |
61 | 66 |
62 EOF | 67 EOF |
63 | 68 |
87 | 92 |
88 } | 93 } |
89 | 94 |
90 } | 95 } |
91 | 96 |
92 my $s = http('', start => 1); | 97 like(http_get('/timeout'), qr/200 OK/, 'proxy connect timeout'); |
93 | |
94 sleep 3; | |
95 | |
96 like(http_get('/', socket => $s), qr/200 OK/, 'proxy connect timeout'); | |
97 | 98 |
98 ############################################################################### | 99 ############################################################################### |
99 | 100 |
100 sub http_daemon { | 101 sub http_daemon { |
101 my $server = IO::Socket::INET->new( | 102 my $server = IO::Socket::INET->new( |
140 EOF | 141 EOF |
141 | 142 |
142 select undef, undef, undef, 0.1; | 143 select undef, undef, undef, 0.1; |
143 print $client 'AND-THIS'; | 144 print $client 'AND-THIS'; |
144 | 145 |
146 } elsif ($uri eq '/timeout') { | |
147 sleep 3; | |
148 | |
149 print $client <<"EOF"; | |
150 HTTP/1.1 200 OK | |
151 Connection: close | |
152 | |
153 EOF | |
154 | |
145 } else { | 155 } else { |
146 | 156 |
147 print $client <<"EOF"; | 157 print $client <<"EOF"; |
148 HTTP/1.1 404 Not Found | 158 HTTP/1.1 404 Not Found |
149 Connection: close | 159 Connection: close |