Mercurial > hg > nginx-tests
diff h2.t @ 714:ccc9f389e1f8
Tests: HTTP/2 connection timeout tests.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Fri, 25 Sep 2015 23:30:39 +0300 |
parents | 649af6069976 |
children | 9ee52e137f3d |
line wrap: on
line diff
--- a/h2.t Thu Sep 24 23:34:11 2015 +0300 +++ b/h2.t Fri Sep 25 23:30:39 2015 +0300 @@ -32,7 +32,7 @@ my $t = Test::Nginx->new()->has(qw/http http_ssl http_v2 proxy cache/) ->has(qw/limit_conn rewrite realip shmem/) - ->has_daemon('openssl')->plan(196); + ->has_daemon('openssl')->plan(202); # FreeBSD has a bug in not treating zero iovcnt as EINVAL @@ -188,6 +188,20 @@ http2_max_header_size 64; } + + server { + listen 127.0.0.1:8089 http2; + server_name localhost; + + http2_recv_timeout 1s; + } + + server { + listen 127.0.0.1:8090 http2; + server_name localhost; + + http2_idle_timeout 1s; + } } EOF @@ -277,8 +291,38 @@ is($frame->{flags}, 1, 'PING flags ack'); is($frame->{sid}, 0, 'PING stream'); +# timeouts + +push my @sess, new_session(8089); +push @sess, new_session(8089); +h2_ping($sess[-1], 'SEE-THIS'); +push @sess, new_session(8090); +push @sess, new_session(8090); +h2_ping($sess[-1], 'SEE-THIS'); + +select undef, undef, undef, 2.1; + +$frames = h2_read(shift @sess, all => [{ type => "GOAWAY" }]); +($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; +ok($frame, 'recv timeout - new connection GOAWAY'); +is($frame->{code}, 1, 'recv timeout - new connection code'); + +$frames = h2_read(shift @sess, all => [{ type => "GOAWAY" }]); +($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; +is($frame, undef, 'recv timeout - idle connection GOAWAY'); + +$frames = h2_read(shift @sess, all => [{ type => "GOAWAY" }]); +($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; +is($frame, undef, 'idle timeout - new connection GOAWAY'); + +$frames = h2_read(shift @sess, all => [{ type => "GOAWAY" }]); +($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; +ok($frame, 'idle timeout - idle connection GOAWAY'); +is($frame->{code}, 0, 'idle timeout - idle connection code'); + # GET +$sess = new_session(); my $sid = new_stream($sess); $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);