comparison upstream_max_conns.t @ 1394:3c101e516213

Tests: added upstream max_conns tests with hash balancer.
author Sergey Kandaurov <pluknet@nginx.com>
date Wed, 07 Nov 2018 15:07:23 +0300
parents 23cf08e9d2a2
children
comparison
equal deleted inserted replaced
1393:23cf08e9d2a2 1394:3c101e516213
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/http proxy rewrite upstream_least_conn/) 26 my $t = Test::Nginx->new()->has(qw/http proxy rewrite upstream_least_conn/)
27 ->has(qw/upstream_ip_hash/)->plan(14); 27 ->has(qw/upstream_ip_hash upstream_hash/)->plan(16);
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
102 ip_hash; 102 ip_hash;
103 server 127.0.0.1:8081 max_conns=1; 103 server 127.0.0.1:8081 max_conns=1;
104 server 127.0.0.1:8082 max_conns=2; 104 server 127.0.0.1:8082 max_conns=2;
105 } 105 }
106 106
107 upstream u_hash {
108 hash $remote_addr;
109 server 127.0.0.1:8081 max_conns=1;
110 server 127.0.0.1:8082 max_conns=2;
111 }
112 upstream u_chash {
113 hash $remote_addr consistent;
114 server 127.0.0.1:8081 max_conns=1;
115 server 127.0.0.1:8082 max_conns=2;
116 }
117
107 server { 118 server {
108 listen 127.0.0.1:8084; 119 listen 127.0.0.1:8084;
109 server_name localhost; 120 server_name localhost;
110 121
111 location / { 122 location / {
197 'least_conn backup limited'); 208 'least_conn backup limited');
198 209
199 # ip_hash balancer tests 210 # ip_hash balancer tests
200 211
201 is(parallel('/u_ih', 4), "$p1: 1, $p2: 2", 'ip_hash'); 212 is(parallel('/u_ih', 4), "$p1: 1, $p2: 2", 'ip_hash');
213
214 # hash balancer tests
215
216 is(parallel('/u_hash', 4), "$p1: 1, $p2: 2", 'hash');
217 is(parallel('/u_chash', 4), "$p1: 1, $p2: 2", 'hash consistent');
202 218
203 ############################################################################### 219 ###############################################################################
204 220
205 sub peers { 221 sub peers {
206 my ($uri, $count) = @_; 222 my ($uri, $count) = @_;