Tests: keepalive_time tests.
diff --git a/h2_max_requests.t b/h2_max_requests.t
index c58a5f1..a0c36f6 100644
--- a/h2_max_requests.t
+++ b/h2_max_requests.t
@@ -56,6 +56,15 @@
 
         location / { }
     }
+
+    server {
+        listen       127.0.0.1:8082 http2;
+        server_name  localhost;
+
+        keepalive_time 1s;
+
+        location / { }
+    }
 }
 
 EOF
@@ -66,7 +75,7 @@
 # suppress deprecation warning
 
 open OLDERR, ">&", \*STDERR; close STDERR;
-$t->run()->plan(12);
+$t->try_run('no keepalive_time')->plan(17);
 open STDERR, ">&", \*OLDERR;
 
 ###############################################################################
@@ -141,6 +150,32 @@
 
 }
 
+# keepalive_time
+
+$s = Test::Nginx::HTTP2->new(port(8082));
+$sid = $s->new_stream({ path => '/t.html' });
+$frames = $s->read(all => [{ sid => $sid, fin => 1 }]);
+
+($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
+is($frame->{headers}->{':status'}, 200, 'keepalive time request');
+
+$frames = $s->read(all => [{ type => 'GOAWAY' }], wait => 0.5);
+
+($frame) = grep { $_->{type} eq "GOAWAY" } @$frames;
+is($frame, undef, 'keepalive time - no GOAWAY yet');
+
+select undef, undef, undef, 1.1;
+
+$sid = $s->new_stream({ path => '/t.html' });
+$frames = $s->read(all => [{ sid => $sid, fin => 1 }, { type => 'GOAWAY' }]);
+
+($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
+is($frame->{headers}->{':status'}, 200, 'keepalive time request 2');
+
+($frame) = grep { $_->{type} eq "GOAWAY" } @$frames;
+ok($frame, 'keepalive time limit - GOAWAY');
+is($frame->{last_sid}, $sid, 'keepalive time limit - GOAWAY last stream');
+
 # graceful shutdown in idle state
 
 $s = Test::Nginx::HTTP2->new();
diff --git a/http_keepalive.t b/http_keepalive.t
index a2264ab..4389c1a 100644
--- a/http_keepalive.t
+++ b/http_keepalive.t
@@ -24,7 +24,7 @@
 select STDERR; $| = 1;
 select STDOUT; $| = 1;
 
-my $t = Test::Nginx->new()->has(qw/http/)->plan(16)
+my $t = Test::Nginx->new()->has(qw/http/)
 	->write_file_expand('nginx.conf', <<'EOF');
 
 %%TEST_GLOBALS%%
@@ -55,6 +55,12 @@
             keepalive_timeout   30s;
         }
 
+        location /time {
+            keepalive_requests  100;
+            keepalive_timeout   75s;
+            keepalive_time      1s;
+        }
+
         location /safari {
             keepalive_disable  safari;
         }
@@ -73,10 +79,11 @@
 
 $t->write_file('index.html', '');
 $t->write_file('r', '');
+$t->write_file('time', '');
 $t->write_file('safari', '');
 $t->write_file('none', '');
 $t->write_file('zero', '');
-$t->run();
+$t->try_run('no keepalive_time')->plan(20);
 
 ###############################################################################
 
@@ -110,6 +117,16 @@
 
 like(http_keepalive('/zero'), qr/Connection: close/, 'keepalive timeout 0');
 
+# keepalive_time
+
+$r = http_keepalive('/time', req => 3);
+is(() = $r =~ /(200 OK)/g, 3, 'keepalive time requests');
+unlike($r, qr/Connection: close/, 'keepalive time connection');
+
+$r = http_keepalive('/time', req => 3, sleep => 1.1);
+is(() = $r =~ /(200 OK)/g, 2, 'keepalive time limit requests');
+like($r, qr/Connection: close/, 'keepalive time limit connection');
+
 # cancel keepalive on EOF while discarding body
 
 my $s = http(<<EOF, start => 1);