# HG changeset patch # User Sergey Kandaurov # Date 1443213039 -10800 # Node ID ccc9f389e1f82a5f637a1501fef3408db66ffeb8 # Parent 94033cdc2f78f5dbeabc4bdde7c1e90c8f0c4940 Tests: HTTP/2 connection timeout tests. diff --git a/h2.t b/h2.t --- a/h2.t +++ b/h2.t @@ -32,7 +32,7 @@ plan(skip_all => 'IO::Socket::SSL too ol 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 @@ http { 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->{value}, 'SEE-THIS', 'PING pa 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 }]);