comparison proxy_non_idempotent.t @ 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 196d33c2bb45
children 97c8280de681
comparison
equal deleted inserted replaced
1315:890516ca898a 1316:d51cc2526066
21 21
22 select STDERR; $| = 1; 22 select STDERR; $| = 1;
23 select STDOUT; $| = 1; 23 select STDOUT; $| = 1;
24 24
25 my $t = Test::Nginx->new()->has(qw/http proxy rewrite upstream_keepalive/) 25 my $t = Test::Nginx->new()->has(qw/http proxy rewrite upstream_keepalive/)
26 ->plan(6); 26 ->plan(8);
27 27
28 $t->write_file_expand('nginx.conf', <<'EOF'); 28 $t->write_file_expand('nginx.conf', <<'EOF');
29 29
30 %%TEST_GLOBALS%% 30 %%TEST_GLOBALS%%
31 31
54 54
55 add_header X-IP $upstream_addr always; 55 add_header X-IP $upstream_addr always;
56 56
57 location / { 57 location / {
58 proxy_pass http://u; 58 proxy_pass http://u;
59 proxy_next_upstream error timeout; 59 proxy_next_upstream error timeout http_404;
60 } 60 }
61 61
62 location /non { 62 location /non {
63 proxy_pass http://u; 63 proxy_pass http://u;
64 proxy_next_upstream error timeout non_idempotent; 64 proxy_next_upstream error timeout non_idempotent;
78 78
79 location / { 79 location / {
80 return 444; 80 return 444;
81 } 81 }
82 82
83 location /404 {
84 return 404 SEE-THIS;
85 }
86
83 location /keepalive/establish { 87 location /keepalive/establish {
84 return 204; 88 return 204;
85 } 89 }
86 } 90 }
87 } 91 }
95 # non-idempotent requests should not be retried by default 99 # non-idempotent requests should not be retried by default
96 # if a request has been sent to a backend 100 # if a request has been sent to a backend
97 101
98 like(http_get('/'), qr/X-IP: (\S+), \1\x0d?$/m, 'get'); 102 like(http_get('/'), qr/X-IP: (\S+), \1\x0d?$/m, 'get');
99 like(http_post('/'), qr/X-IP: (\S+)\x0d?$/m, 'post'); 103 like(http_post('/'), qr/X-IP: (\S+)\x0d?$/m, 'post');
104
105 # non-idempotent requests should not be retried by default,
106 # in particular, not emit builtin error page due to next upstream
107
108 like(http_get('/404'), qr/X-IP: (\S+), \1.*SEE-THIS/s, 'get 404');
109
110 TODO: {
111 local $TODO = 'not yet' unless $t->has_version('1.13.11');
112
113 like(http_post('/404'), qr/X-IP: (\S++)(?! ).*SEE-THIS/s, 'post 404');
114
115 }
100 116
101 # with "proxy_next_upstream non_idempotent" there is no 117 # with "proxy_next_upstream non_idempotent" there is no
102 # difference between idempotent and non-idempotent requests, 118 # difference between idempotent and non-idempotent requests,
103 # non-idempotent requests are retried as usual 119 # non-idempotent requests are retried as usual
104 120