Mercurial > hg > nginx-tests
comparison 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 |
comparison
equal
deleted
inserted
replaced
1631:62a1667f60f8 | 1632:da1325cb1c39 |
---|---|
19 ############################################################################### | 19 ############################################################################### |
20 | 20 |
21 select STDERR; $| = 1; | 21 select STDERR; $| = 1; |
22 select STDOUT; $| = 1; | 22 select STDOUT; $| = 1; |
23 | 23 |
24 my $t = Test::Nginx->new()->has(qw/http proxy rewrite/)->plan(7); | 24 my $t = Test::Nginx->new()->has(qw/http proxy rewrite/)->plan(8); |
25 | 25 |
26 $t->write_file_expand('nginx.conf', <<'EOF'); | 26 $t->write_file_expand('nginx.conf', <<'EOF'); |
27 | 27 |
28 %%TEST_GLOBALS%% | 28 %%TEST_GLOBALS%% |
29 | 29 |
43 upstream u2 { | 43 upstream u2 { |
44 server 127.0.0.1:8081; | 44 server 127.0.0.1:8081; |
45 server 127.0.0.1:8082; | 45 server 127.0.0.1:8082; |
46 } | 46 } |
47 | 47 |
48 upstream u3 { | |
49 server 127.0.0.1:8081; | |
50 server 127.0.0.1:8082 down; | |
51 } | |
52 | |
48 server { | 53 server { |
49 listen 127.0.0.1:8080; | 54 listen 127.0.0.1:8080; |
50 server_name localhost; | 55 server_name localhost; |
51 | 56 |
52 location / { | 57 location / { |
61 proxy_intercept_errors on; | 66 proxy_intercept_errors on; |
62 } | 67 } |
63 | 68 |
64 location /all/404 { | 69 location /all/404 { |
65 return 200 "$upstream_addr\n"; | 70 return 200 "$upstream_addr\n"; |
71 } | |
72 | |
73 location /down { | |
74 proxy_pass http://u3; | |
75 proxy_next_upstream http_404; | |
66 } | 76 } |
67 } | 77 } |
68 | 78 |
69 server { | 79 server { |
70 listen 127.0.0.1:8081; | 80 listen 127.0.0.1:8081; |
131 | 141 |
132 like(http_get('/all/rr'), | 142 like(http_get('/all/rr'), |
133 qr/^127.0.0.1:($p1, 127.0.0.1:$p2|$p2, 127.0.0.1:$p1)$/mi, | 143 qr/^127.0.0.1:($p1, 127.0.0.1:$p2|$p2, 127.0.0.1:$p1)$/mi, |
134 'all tried once'); | 144 'all tried once'); |
135 | 145 |
146 # make sure backend marked as down doesn't count towards "no live upstreams" | |
147 # after all backends are tried with http_404 | |
148 | |
149 TODO: { | |
150 local $TODO = 'not yet' unless $t->has_version('1.19.6'); | |
151 | |
152 like(http_get('/down/'), qr/Not Found/, 'all tried with down'); | |
153 | |
154 } | |
155 | |
136 ############################################################################### | 156 ############################################################################### |