comparison upstream_max_conns.t @ 1391:62f06d8dfc63

Tests: ported upstream max_conns tests to stream, reduced diffs.
author Sergey Kandaurov <pluknet@nginx.com>
date Wed, 07 Nov 2018 14:49:34 +0300
parents 766bcbb632ee
children 23cf08e9d2a2
comparison
equal deleted inserted replaced
1390:2c0955286894 1391:62f06d8dfc63
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() 26 my $t = Test::Nginx->new()->has(qw/http proxy rewrite upstream_least_conn/)
27 ->has(qw/http proxy rewrite upstream_least_conn upstream_ip_hash/); 27 ->has(qw/upstream_ip_hash/)->plan(14);
28 28
29 $t->write_file_expand('nginx.conf', <<'EOF'); 29 $t->write_file_expand('nginx.conf', <<'EOF');
30 30
31 %%TEST_GLOBALS%% 31 %%TEST_GLOBALS%%
32 32
130 } 130 }
131 } 131 }
132 132
133 EOF 133 EOF
134 134
135
136 $t->run_daemon(\&http_daemon, port(8081), port(8082), port(8085)); 135 $t->run_daemon(\&http_daemon, port(8081), port(8082), port(8085));
137 $t->run()->plan(14); 136 $t->run();
138 137
139 $t->waitforsocket('127.0.0.1:' . port(8081)); 138 $t->waitforsocket('127.0.0.1:' . port(8081));
140 $t->waitforsocket('127.0.0.1:' . port(8082)); 139 $t->waitforsocket('127.0.0.1:' . port(8082));
141 $t->waitforsocket('127.0.0.1:' . port(8085)); 140 $t->waitforsocket('127.0.0.1:' . port(8085));
142 141
146 145
147 # two peers without max_conns 146 # two peers without max_conns
148 147
149 is(parallel('/u_unlim?delay=0', 4), "$p1: 2, $p2: 2", 'unlimited'); 148 is(parallel('/u_unlim?delay=0', 4), "$p1: 2, $p2: 2", 'unlimited');
150 149
151 # simple test with limited peer
152
153 is(parallel('/u_lim', 4), "$p1: 3", 'single');
154
155 # reopen connection to test connection subtraction 150 # reopen connection to test connection subtraction
156 151
157 my @s = http_get_multi('/u_lim', 1, 1.1); 152 my @s = http_get_multi('/u_lim', 2, 1.1);
158 http_get('/u_lim/close'); 153 http_get('/u_lim/close');
159 push @s, http_get_multi('/u_lim', 1, 1.1); 154 push @s, http_get_multi('/u_lim', 1, 1.1);
160 http_get('/closeall'); 155 http_get('/closeall');
161 156
162 is(http_end_multi(\@s), "$p1: 2", 'conn subtraction'); 157 is(http_end_multi(\@s), "$p1: 3", 'conn subtraction');
158
159 # simple test with limited peer
160
161 is(parallel('/u_lim', 4), "$p1: 3", 'single');
163 162
164 # limited peer with backup peer 163 # limited peer with backup peer
165 164
166 is(peers('/u_backup', 6), "$p1 $p1 $p2 $p2 $p2 $p2", 'backup'); 165 is(peers('/u_backup', 6), "$p1 $p1 $p2 $p2 $p2 $p2", 'backup');
167 166