Tests: added proxy_next_upstream test with "down".
diff --git a/proxy_next_upstream.t b/proxy_next_upstream.t
index 6d6da11..a11f007 100644
--- a/proxy_next_upstream.t
+++ b/proxy_next_upstream.t
@@ -21,7 +21,7 @@
select STDERR; $| = 1;
select STDOUT; $| = 1;
-my $t = Test::Nginx->new()->has(qw/http proxy rewrite/)->plan(7);
+my $t = Test::Nginx->new()->has(qw/http proxy rewrite/)->plan(8);
$t->write_file_expand('nginx.conf', <<'EOF');
@@ -45,6 +45,11 @@
server 127.0.0.1:8082;
}
+ upstream u3 {
+ server 127.0.0.1:8081;
+ server 127.0.0.1:8082 down;
+ }
+
server {
listen 127.0.0.1:8080;
server_name localhost;
@@ -64,6 +69,11 @@
location /all/404 {
return 200 "$upstream_addr\n";
}
+
+ location /down {
+ proxy_pass http://u3;
+ proxy_next_upstream http_404;
+ }
}
server {
@@ -133,4 +143,14 @@
qr/^127.0.0.1:($p1, 127.0.0.1:$p2|$p2, 127.0.0.1:$p1)$/mi,
'all tried once');
+# make sure backend marked as down doesn't count towards "no live upstreams"
+# after all backends are tried with http_404
+
+TODO: {
+local $TODO = 'not yet' unless $t->has_version('1.19.6');
+
+like(http_get('/down/'), qr/Not Found/, 'all tried with down');
+
+}
+
###############################################################################
diff --git a/stream_proxy_next_upstream.t b/stream_proxy_next_upstream.t
index 3323527..12fbad5 100644
--- a/stream_proxy_next_upstream.t
+++ b/stream_proxy_next_upstream.t
@@ -23,7 +23,7 @@
select STDERR; $| = 1;
select STDOUT; $| = 1;
-my $t = Test::Nginx->new()->has(qw/stream/)->plan(3);
+my $t = Test::Nginx->new()->has(qw/stream/)->plan(5);
$t->write_file_expand('nginx.conf', <<'EOF');
@@ -48,6 +48,11 @@
server 127.0.0.1:8085 backup;
}
+ upstream u3 {
+ server 127.0.0.1:8083;
+ server 127.0.0.1:8085 down;
+ }
+
proxy_connect_timeout 2;
server {
@@ -68,6 +73,15 @@
proxy_next_upstream on;
proxy_next_upstream_tries 2;
}
+
+ log_format test "$upstream_addr";
+
+ server {
+ listen 127.0.0.1:8086;
+ proxy_pass u3;
+ proxy_next_upstream on;
+ access_log %%TESTDIR%%/test.log test;
+ }
}
EOF
@@ -84,6 +98,20 @@
is(stream('127.0.0.1:' . port(8082))->io('.'), '', 'next tries');
+# make sure backend marked as down doesn't count towards "no live upstreams"
+
+is(stream('127.0.0.1:' . port(8086))->io('.'), '', 'next down');
+
+$t->stop();
+
+TODO: {
+local $TODO = 'not yet' unless $t->has_version('1.19.6');
+
+is($t->read_file('test.log'), '127.0.0.1:' . port(8083) . "\n",
+ 'next down log');
+
+}
+
###############################################################################
sub stream_daemon {