[nginx-tests] Tests: added proxy_next_upstream test with no next...

Maxim Dounin mdounin at mdounin.ru
Sat Jan 31 06:37:23 UTC 2026


details:   http://freenginx.org/hg/nginx-tests/rev/dd9752c3750a
branches:  
changeset: 2040:dd9752c3750a
user:      Maxim Dounin <mdounin at mdounin.ru>
date:      Sat Jan 31 09:27:23 2026 +0300
description:
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.

diffstat:

 proxy_next_upstream.t |  26 +++++++++++++++++++++++++-
 1 files changed, 25 insertions(+), 1 deletions(-)

diffs (55 lines):

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