Mercurial > hg > nginx-tests
changeset 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 | 7787498b3ceb |
files | stream_upstream_max_conns.t upstream_max_conns.t |
diffstat | 2 files changed, 44 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/stream_upstream_max_conns.t Wed Nov 07 14:49:43 2018 +0300 +++ b/stream_upstream_max_conns.t Wed Nov 07 15:07:23 2018 +0300 @@ -25,7 +25,7 @@ select STDOUT; $| = 1; my $t = Test::Nginx->new()->has(qw/stream stream_upstream_least_conn/) - ->plan(12); + ->has(qw/stream_upstream_hash/)->plan(14); $t->write_file_expand('nginx.conf', <<'EOF'); @@ -89,6 +89,17 @@ server 127.0.0.1:8082 backup max_conns=3; } + upstream u_hash { + hash $remote_addr; + server 127.0.0.1:8081 max_conns=1; + server 127.0.0.1:8082 max_conns=2; + } + upstream u_chash { + hash $remote_addr consistent; + server 127.0.0.1:8081 max_conns=1; + server 127.0.0.1:8082 max_conns=2; + } + server { listen 127.0.0.1:8086; proxy_pass u_unlim; @@ -143,6 +154,16 @@ listen 127.0.0.1:8096; proxy_pass u_lc_backup_lim; } + + server { + listen 127.0.0.1:8097; + proxy_pass u_hash; + } + + server { + listen 127.0.0.1:8098; + proxy_pass u_chash; + } } EOF @@ -207,6 +228,11 @@ is(peers(8096, '/u_lc_backup_lim', 6), "$p1 $p1 $p2 $p2 $p2 ", 'least_conn backup limited'); +# hash balancer tests + +is(parallel(8097, '/u_hash', 4), "$p1: 1, $p2: 2", 'hash'); +is(parallel(8098, '/u_chash', 4), "$p1: 1, $p2: 2", 'hash consistent'); + ############################################################################### sub peers {
--- a/upstream_max_conns.t Wed Nov 07 14:49:43 2018 +0300 +++ b/upstream_max_conns.t Wed Nov 07 15:07:23 2018 +0300 @@ -24,7 +24,7 @@ select STDOUT; $| = 1; my $t = Test::Nginx->new()->has(qw/http proxy rewrite upstream_least_conn/) - ->has(qw/upstream_ip_hash/)->plan(14); + ->has(qw/upstream_ip_hash upstream_hash/)->plan(16); $t->write_file_expand('nginx.conf', <<'EOF'); @@ -104,6 +104,17 @@ server 127.0.0.1:8082 max_conns=2; } + upstream u_hash { + hash $remote_addr; + server 127.0.0.1:8081 max_conns=1; + server 127.0.0.1:8082 max_conns=2; + } + upstream u_chash { + hash $remote_addr consistent; + server 127.0.0.1:8081 max_conns=1; + server 127.0.0.1:8082 max_conns=2; + } + server { listen 127.0.0.1:8084; server_name localhost; @@ -200,6 +211,11 @@ is(parallel('/u_ih', 4), "$p1: 1, $p2: 2", 'ip_hash'); +# hash balancer tests + +is(parallel('/u_hash', 4), "$p1: 1, $p2: 2", 'hash'); +is(parallel('/u_chash', 4), "$p1: 1, $p2: 2", 'hash consistent'); + ############################################################################### sub peers {