comparison 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
comparison
equal deleted inserted replaced
713:94033cdc2f78 714:ccc9f389e1f8
30 eval { IO::Socket::SSL::SSL_VERIFY_NONE(); }; 30 eval { IO::Socket::SSL::SSL_VERIFY_NONE(); };
31 plan(skip_all => 'IO::Socket::SSL too old') if $@; 31 plan(skip_all => 'IO::Socket::SSL too old') if $@;
32 32
33 my $t = Test::Nginx->new()->has(qw/http http_ssl http_v2 proxy cache/) 33 my $t = Test::Nginx->new()->has(qw/http http_ssl http_v2 proxy cache/)
34 ->has(qw/limit_conn rewrite realip shmem/) 34 ->has(qw/limit_conn rewrite realip shmem/)
35 ->has_daemon('openssl')->plan(196); 35 ->has_daemon('openssl')->plan(202);
36 36
37 # FreeBSD has a bug in not treating zero iovcnt as EINVAL 37 # FreeBSD has a bug in not treating zero iovcnt as EINVAL
38 38
39 $t->todo_alerts() unless $^O eq 'freebsd'; 39 $t->todo_alerts() unless $^O eq 'freebsd';
40 40
186 listen 127.0.0.1:8088 http2; 186 listen 127.0.0.1:8088 http2;
187 server_name localhost; 187 server_name localhost;
188 188
189 http2_max_header_size 64; 189 http2_max_header_size 64;
190 } 190 }
191
192 server {
193 listen 127.0.0.1:8089 http2;
194 server_name localhost;
195
196 http2_recv_timeout 1s;
197 }
198
199 server {
200 listen 127.0.0.1:8090 http2;
201 server_name localhost;
202
203 http2_idle_timeout 1s;
204 }
191 } 205 }
192 206
193 EOF 207 EOF
194 208
195 $t->write_file('openssl.conf', <<EOF); 209 $t->write_file('openssl.conf', <<EOF);
275 ok($frame, 'PING frame'); 289 ok($frame, 'PING frame');
276 is($frame->{value}, 'SEE-THIS', 'PING payload'); 290 is($frame->{value}, 'SEE-THIS', 'PING payload');
277 is($frame->{flags}, 1, 'PING flags ack'); 291 is($frame->{flags}, 1, 'PING flags ack');
278 is($frame->{sid}, 0, 'PING stream'); 292 is($frame->{sid}, 0, 'PING stream');
279 293
294 # timeouts
295
296 push my @sess, new_session(8089);
297 push @sess, new_session(8089);
298 h2_ping($sess[-1], 'SEE-THIS');
299 push @sess, new_session(8090);
300 push @sess, new_session(8090);
301 h2_ping($sess[-1], 'SEE-THIS');
302
303 select undef, undef, undef, 2.1;
304
305 $frames = h2_read(shift @sess, all => [{ type => "GOAWAY" }]);
306 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames;
307 ok($frame, 'recv timeout - new connection GOAWAY');
308 is($frame->{code}, 1, 'recv timeout - new connection code');
309
310 $frames = h2_read(shift @sess, all => [{ type => "GOAWAY" }]);
311 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames;
312 is($frame, undef, 'recv timeout - idle connection GOAWAY');
313
314 $frames = h2_read(shift @sess, all => [{ type => "GOAWAY" }]);
315 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames;
316 is($frame, undef, 'idle timeout - new connection GOAWAY');
317
318 $frames = h2_read(shift @sess, all => [{ type => "GOAWAY" }]);
319 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames;
320 ok($frame, 'idle timeout - idle connection GOAWAY');
321 is($frame->{code}, 0, 'idle timeout - idle connection code');
322
280 # GET 323 # GET
281 324
325 $sess = new_session();
282 my $sid = new_stream($sess); 326 my $sid = new_stream($sess);
283 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]); 327 $frames = h2_read($sess, all => [{ sid => $sid, fin => 1 }]);
284 328
285 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; 329 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
286 ok($frame, 'HEADERS frame'); 330 ok($frame, 'HEADERS frame');