# HG changeset patch # User Sergey Kandaurov # Date 1382602875 -14400 # Node ID 3d3c8b5ea8ee2605ef42820c5b5346b31d72ef61 # Parent e102fc6db9462748ba007a30c9a60241e68f1bc2 Tests: improved proxy_next_upstream tests. A new test added to make sure that all bad backends are tried once. diff --git a/proxy_next_upstream.t b/proxy_next_upstream.t --- a/proxy_next_upstream.t +++ b/proxy_next_upstream.t @@ -21,7 +21,7 @@ use Test::Nginx; 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 @@ http { 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 @@ http { 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 @@ http { location /500 { return 500; } + + location /all/ { + return 404; + } } server { @@ -72,6 +92,10 @@ http { location / { return 200 "TEST-OK-IF-YOU-SEE-THIS\n"; } + + location /all/ { + return 404; + } } } @@ -101,4 +125,10 @@ like(http_get('/500'), qr/SEE-THIS/, 're 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'); + ###############################################################################