comparison stream_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 f3ba4c74de31
children 5ac6efbe5552
comparison
equal deleted inserted replaced
1631:62a1667f60f8 1632:da1325cb1c39
21 ############################################################################### 21 ###############################################################################
22 22
23 select STDERR; $| = 1; 23 select STDERR; $| = 1;
24 select STDOUT; $| = 1; 24 select STDOUT; $| = 1;
25 25
26 my $t = Test::Nginx->new()->has(qw/stream/)->plan(3); 26 my $t = Test::Nginx->new()->has(qw/stream/)->plan(5);
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
46 upstream u2 { 46 upstream u2 {
47 server 127.0.0.1:8083; 47 server 127.0.0.1:8083;
48 server 127.0.0.1:8085 backup; 48 server 127.0.0.1:8085 backup;
49 } 49 }
50 50
51 upstream u3 {
52 server 127.0.0.1:8083;
53 server 127.0.0.1:8085 down;
54 }
55
51 proxy_connect_timeout 2; 56 proxy_connect_timeout 2;
52 57
53 server { 58 server {
54 listen 127.0.0.1:8080; 59 listen 127.0.0.1:8080;
55 proxy_pass u; 60 proxy_pass u;
66 listen 127.0.0.1:8082; 71 listen 127.0.0.1:8082;
67 proxy_pass u; 72 proxy_pass u;
68 proxy_next_upstream on; 73 proxy_next_upstream on;
69 proxy_next_upstream_tries 2; 74 proxy_next_upstream_tries 2;
70 } 75 }
76
77 log_format test "$upstream_addr";
78
79 server {
80 listen 127.0.0.1:8086;
81 proxy_pass u3;
82 proxy_next_upstream on;
83 access_log %%TESTDIR%%/test.log test;
84 }
71 } 85 }
72 86
73 EOF 87 EOF
74 88
75 $t->run_daemon(\&stream_daemon); 89 $t->run_daemon(\&stream_daemon);
81 is(stream('127.0.0.1:' . port(8081))->io('.'), 'SEE-THIS', 'next on'); 95 is(stream('127.0.0.1:' . port(8081))->io('.'), 'SEE-THIS', 'next on');
82 96
83 # make sure backup is not tried 97 # make sure backup is not tried
84 98
85 is(stream('127.0.0.1:' . port(8082))->io('.'), '', 'next tries'); 99 is(stream('127.0.0.1:' . port(8082))->io('.'), '', 'next tries');
100
101 # make sure backend marked as down doesn't count towards "no live upstreams"
102
103 is(stream('127.0.0.1:' . port(8086))->io('.'), '', 'next down');
104
105 $t->stop();
106
107 TODO: {
108 local $TODO = 'not yet' unless $t->has_version('1.19.6');
109
110 is($t->read_file('test.log'), '127.0.0.1:' . port(8083) . "\n",
111 'next down log');
112
113 }
86 114
87 ############################################################################### 115 ###############################################################################
88 116
89 sub stream_daemon { 117 sub stream_daemon {
90 my $server = IO::Socket::INET->new( 118 my $server = IO::Socket::INET->new(