Mercurial > hg > nginx-tests
changeset 351:3d3c8b5ea8ee
Tests: improved proxy_next_upstream tests.
A new test added to make sure that all bad backends are tried once.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Thu, 24 Oct 2013 12:21:15 +0400 |
parents | e102fc6db946 |
children | 145c37f27c5a |
files | proxy_next_upstream.t |
diffstat | 1 files changed, 31 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/proxy_next_upstream.t Fri Oct 18 19:49:15 2013 +0400 +++ b/proxy_next_upstream.t Thu Oct 24 12:21:15 2013 +0400 @@ -21,7 +21,7 @@ select STDERR; $| = 1; select STDOUT; $| = 1; -my $t = Test::Nginx->new()->has(qw/http proxy rewrite/)->plan(6); +my $t = Test::Nginx->new()->has(qw/http proxy rewrite/)->plan(7); $t->write_file_expand('nginx.conf', <<'EOF'); @@ -40,6 +40,11 @@ server 127.0.0.1:8082; } + upstream u2 { + server 127.0.0.1:8081; + server 127.0.0.1:8082; + } + server { listen 127.0.0.1:8080; server_name localhost; @@ -48,6 +53,17 @@ proxy_pass http://u; proxy_next_upstream http_500 http_404; } + + location /all/ { + proxy_pass http://u2; + proxy_next_upstream http_500 http_404; + error_page 404 /all/404; + proxy_intercept_errors on; + } + + location /all/404 { + return 200 "$upstream_addr\n"; + } } server { @@ -63,6 +79,10 @@ location /500 { return 500; } + + location /all/ { + return 404; + } } server { @@ -72,6 +92,10 @@ location / { return 200 "TEST-OK-IF-YOU-SEE-THIS\n"; } + + location /all/ { + return 404; + } } } @@ -101,4 +125,10 @@ unlike(http_get('/ok') . http_get('/ok'), qr/AND-THIS/, 'down after 500'); +# make sure all backends are tried once + +like(http_get('/all/rr'), + qr/^127.0.0.1:808(1, 127.0.0.1:8082|2, 127.0.0.1:8081)$/mi, + 'all tried once'); + ###############################################################################