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
+++ 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');
+
 ###############################################################################