diff proxy_next_upstream.t @ 1632:da1325cb1c39

Tests: added proxy_next_upstream test with "down".
author Sergey Kandaurov <pluknet@nginx.com>
date Wed, 02 Dec 2020 12:16:32 +0000
parents 882267679006
children 5ac6efbe5552
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(7);
+my $t = Test::Nginx->new()->has(qw/http proxy rewrite/)->plan(8);
 
 $t->write_file_expand('nginx.conf', <<'EOF');
 
@@ -45,6 +45,11 @@ http {
         server 127.0.0.1:8082;
     }
 
+    upstream u3 {
+        server 127.0.0.1:8081;
+        server 127.0.0.1:8082 down;
+    }
+
     server {
         listen       127.0.0.1:8080;
         server_name  localhost;
@@ -64,6 +69,11 @@ http {
         location /all/404 {
             return 200 "$upstream_addr\n";
         }
+
+        location /down {
+            proxy_pass http://u3;
+            proxy_next_upstream http_404;
+        }
     }
 
     server {
@@ -133,4 +143,14 @@ like(http_get('/all/rr'),
 	qr/^127.0.0.1:($p1, 127.0.0.1:$p2|$p2, 127.0.0.1:$p1)$/mi,
 	'all tried once');
 
+# make sure backend marked as down doesn't count towards "no live upstreams"
+# after all backends are tried with http_404
+
+TODO: {
+local $TODO = 'not yet' unless $t->has_version('1.19.6');
+
+like(http_get('/down/'), qr/Not Found/, 'all tried with down');
+
+}
+
 ###############################################################################