[PATCH] Tests: added proxy_next_upstream test with no next upstream

Maxim Dounin mdounin at mdounin.ru
Sun Jan 11 23:20:54 UTC 2026


# HG changeset patch
# User Maxim Dounin <mdounin at mdounin.ru>
# Date 1768172277 -10800
#      Mon Jan 12 01:57:57 2026 +0300
# Node ID 8d1b070ec8e78817f64e48beec007e85ed77012e
# Parent  b51387cf0ef442b073a9cb93dc4c604001bdcd26
Tests: added proxy_next_upstream test with no next upstream.

Previously, peer failures were not reported to the balancer if an error
response listed in proxy_next_upstream was received, but switching to
the next upstream server was not possible.

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(8);
+my $t = Test::Nginx->new()->has(qw/http proxy rewrite/)->plan(11);
 
 $t->write_file_expand('nginx.conf', <<'EOF');
 
@@ -50,6 +50,11 @@ http {
         server 127.0.0.1:8082 down;
     }
 
+    upstream u4 {
+        server 127.0.0.1:8081;
+        server 127.0.0.1:8082;
+    }
+
     server {
         listen       127.0.0.1:8080;
         server_name  localhost;
@@ -74,6 +79,12 @@ http {
             proxy_pass http://u3;
             proxy_next_upstream http_404;
         }
+
+        location /nonext {
+            proxy_pass http://u4/500;
+            proxy_next_upstream http_500;
+            proxy_next_upstream_tries 1;
+        }
     }
 
     server {
@@ -148,4 +159,17 @@ like(http_get('/all/rr'),
 
 like(http_get('/down/'), qr/Not Found/, 'all tried with down');
 
+# make sure backend is switched off with http_500
+# if switching to next upstream is not possible
+
+like(http_get('/nonext'), qr/500 Internal|SEE-THIS/, 'request nonext');
+like(http_get('/nonext'), qr/500 Internal|SEE-THIS/, 'request nonext second');
+
+TODO: {
+local $TODO = 'not yet' unless $t->has_version('1.29.5');
+
+like(http_get('/nonext'), qr/SEE-THIS/, 'down after nonext');
+
+}
+
 ###############################################################################



More information about the nginx-devel mailing list