Tests: upstream keepalive_time tests.
diff --git a/upstream_keepalive.t b/upstream_keepalive.t
index 5253bf6..af9b869 100644
--- a/upstream_keepalive.t
+++ b/upstream_keepalive.t
@@ -3,7 +3,7 @@
# (C) Sergey Kandaurov
# (C) Nginx, Inc.
-# Tests for upstream keepalive, keepalive_requests and keepalive_timeout.
+# Tests for upstream keepalive directives.
###############################################################################
@@ -22,7 +22,7 @@
select STDERR; $| = 1;
select STDOUT; $| = 1;
-my $t = Test::Nginx->new()->has(qw/http proxy upstream_keepalive/)->plan(7)
+my $t = Test::Nginx->new()->has(qw/http proxy upstream_keepalive/)
->write_file_expand('nginx.conf', <<'EOF');
%%TEST_GLOBALS%%
@@ -42,6 +42,12 @@
keepalive_timeout 2s;
}
+ upstream time {
+ server 127.0.0.1:8081;
+ keepalive 1;
+ keepalive_time 2s;
+ }
+
server {
listen 127.0.0.1:8080;
server_name localhost;
@@ -52,6 +58,10 @@
location / {
proxy_pass http://backend;
}
+
+ location /time {
+ proxy_pass http://time/;
+ }
}
server {
@@ -67,11 +77,11 @@
EOF
$t->write_file('index.html', 'SEE-THIS');
-$t->run();
+$t->try_run('no keepalive_time')->plan(11);
###############################################################################
-my ($r, $n);
+my ($r, $n, $m);
# keepalive_requests
@@ -82,12 +92,20 @@
like(http_get('/'), qr/X-Connection: (?!$n).*SEE/ms, 'keepalive requests');
http_get('/?close');
-# keepalive_timeout
+# keepalive_timeout, keepalive_time
like($r = http_get('/'), qr/SEE-THIS/, 'request timer');
$r =~ m/X-Connection: (\d+)/; $n = $1;
+like($r = http_get('/time'), qr/SEE-THIS/, 'request time');
+$r =~ m/X-Connection: (\d+)/; $m = $1;
+
like(http_get('/'), qr/X-Connection: $n.*SEE/ms, 'keepalive timer');
+like(http_get('/time'), qr/X-Connection: $m.*SEE/ms, 'keepalive time');
+
select undef, undef, undef, 2.5;
+
like(http_get('/'), qr/X-Connection: (?!$n).*SEE/ms, 'keepalive timeout');
+like(http_get('/time'), qr/X-Connection: $m.*SEE/ms, 'keepalive time last');
+like(http_get('/time'), qr/X-Connection: (?!$m).*SEE/ms, 'keepalive time new');
###############################################################################