Tests: added upstream max_conns tests with hash balancer.
diff --git a/stream_upstream_max_conns.t b/stream_upstream_max_conns.t
index d2ebb8e..173dfec 100644
--- a/stream_upstream_max_conns.t
+++ b/stream_upstream_max_conns.t
@@ -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 {
diff --git a/upstream_max_conns.t b/upstream_max_conns.t
index f4d4f82..5c9318c 100644
--- a/upstream_max_conns.t
+++ b/upstream_max_conns.t
@@ -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 {