changeset 1316:d51cc2526066

Tests: added ngx_http_upstream_test_next() cases.
author Sergey Kandaurov <pluknet@nginx.com>
date Tue, 03 Apr 2018 15:52:09 +0300
parents 890516ca898a
children a05f377bf0ca
files proxy_non_idempotent.t
diffstat 1 files changed, 18 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/proxy_non_idempotent.t
+++ b/proxy_non_idempotent.t
@@ -23,7 +23,7 @@ select STDERR; $| = 1;
 select STDOUT; $| = 1;
 
 my $t = Test::Nginx->new()->has(qw/http proxy rewrite upstream_keepalive/)
-	->plan(6);
+	->plan(8);
 
 $t->write_file_expand('nginx.conf', <<'EOF');
 
@@ -56,7 +56,7 @@ http {
 
         location / {
             proxy_pass http://u;
-            proxy_next_upstream error timeout;
+            proxy_next_upstream error timeout http_404;
         }
 
         location /non {
@@ -80,6 +80,10 @@ http {
             return 444;
         }
 
+        location /404 {
+            return 404 SEE-THIS;
+        }
+
         location /keepalive/establish {
             return 204;
         }
@@ -98,6 +102,18 @@ EOF
 like(http_get('/'), qr/X-IP: (\S+), \1\x0d?$/m, 'get');
 like(http_post('/'), qr/X-IP: (\S+)\x0d?$/m, 'post');
 
+# non-idempotent requests should not be retried by default,
+# in particular, not emit builtin error page due to next upstream
+
+like(http_get('/404'), qr/X-IP: (\S+), \1.*SEE-THIS/s, 'get 404');
+
+TODO: {
+local $TODO = 'not yet' unless $t->has_version('1.13.11');
+
+like(http_post('/404'), qr/X-IP: (\S++)(?! ).*SEE-THIS/s, 'post 404');
+
+}
+
 # with "proxy_next_upstream non_idempotent" there is no
 # difference between idempotent and non-idempotent requests,
 # non-idempotent requests are retried as usual