Mercurial > hg > nginx-tests
comparison h2.t @ 984:892737e9fd31
Tests: added HTTP/2 GOAWAY test for connection with active stream.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Mon, 18 Jul 2016 17:58:19 +0300 |
parents | 882267679006 |
children | eb49d29d5447 |
comparison
equal
deleted
inserted
replaced
983:daf3fb13a80d | 984:892737e9fd31 |
---|---|
23 ############################################################################### | 23 ############################################################################### |
24 | 24 |
25 select STDERR; $| = 1; | 25 select STDERR; $| = 1; |
26 select STDOUT; $| = 1; | 26 select STDOUT; $| = 1; |
27 | 27 |
28 my $t = Test::Nginx->new()->has(qw/http http_v2 proxy rewrite/)->plan(137); | 28 my $t = Test::Nginx->new()->has(qw/http http_v2 proxy rewrite/)->plan(138); |
29 | 29 |
30 # Some systems return EINVAL on zero writev iovcnt per POSIX, while others not | 30 # Some systems return EINVAL on zero writev iovcnt per POSIX, while others not |
31 | 31 |
32 $t->todo_alerts() if $^O eq 'darwin' or $^O eq 'netbsd'; | 32 $t->todo_alerts() if $^O eq 'darwin' or $^O eq 'netbsd'; |
33 | 33 |
133 | 133 |
134 server { | 134 server { |
135 listen 127.0.0.1:8086 http2; | 135 listen 127.0.0.1:8086 http2; |
136 server_name localhost; | 136 server_name localhost; |
137 | 137 |
138 send_timeout 1s; | 138 send_timeout 2s; |
139 } | 139 } |
140 | 140 |
141 server { | 141 server { |
142 listen 127.0.0.1:8087 http2; | 142 listen 127.0.0.1:8087 http2; |
143 server_name localhost; | 143 server_name localhost; |
832 $s = Test::Nginx::HTTP2->new(port(8086)); | 832 $s = Test::Nginx::HTTP2->new(port(8086)); |
833 $sid = $s->new_stream({ path => '/tbig.html' }); | 833 $sid = $s->new_stream({ path => '/tbig.html' }); |
834 $s->h2_window(2**30, $sid); | 834 $s->h2_window(2**30, $sid); |
835 $s->h2_window(2**30); | 835 $s->h2_window(2**30); |
836 | 836 |
837 select undef, undef, undef, 2.1; | 837 select undef, undef, undef, 2.5; |
838 | 838 |
839 $s->h2_ping('SEE-THIS'); | 839 $s->h2_ping('SEE-THIS'); |
840 | 840 |
841 $frames = $s->read(all => [{ type => 'PING' }]); | 841 $frames = $s->read(all => [{ type => 'PING' }]); |
842 ok(!grep ({ $_->{type} eq "PING" } @$frames), 'large response - send timeout'); | 842 ok(!grep ({ $_->{type} eq "PING" } @$frames), 'large response - send timeout'); |
1064 $frames = $s->read(all => [{ type => 'PING' }]); | 1064 $frames = $s->read(all => [{ type => 'PING' }]); |
1065 | 1065 |
1066 ($frame) = grep { $_->{type} eq "PING" } @$frames; | 1066 ($frame) = grep { $_->{type} eq "PING" } @$frames; |
1067 is($frame->{value}, 'SEE-THIS', 'unknown frame type'); | 1067 is($frame->{value}, 'SEE-THIS', 'unknown frame type'); |
1068 | 1068 |
1069 # GOAWAY - force closing a connection by server | 1069 # GOAWAY - force closing a connection by server with idle or active streams |
1070 | 1070 |
1071 $sid = $s->new_stream(); | 1071 $sid = $s->new_stream(); |
1072 $s->read(all => [{ sid => $sid, fin => 1 }]); | 1072 $s->read(all => [{ sid => $sid, fin => 1 }]); |
1073 | |
1074 my $active = Test::Nginx::HTTP2->new(port(8086)); | |
1075 $active->new_stream({ path => '/tbig.html' }); | |
1073 | 1076 |
1074 # graceful shutdown with stream waiting on HEADERS payload | 1077 # graceful shutdown with stream waiting on HEADERS payload |
1075 | 1078 |
1076 my $grace = Test::Nginx::HTTP2->new(port(8084)); | 1079 my $grace = Test::Nginx::HTTP2->new(port(8084)); |
1077 $grace->new_stream({ split => [ 9 ], abort => 1 }); | 1080 $grace->new_stream({ split => [ 9 ], abort => 1 }); |
1098 undef $grace4; | 1101 undef $grace4; |
1099 | 1102 |
1100 $t->stop(); | 1103 $t->stop(); |
1101 | 1104 |
1102 $frames = $s->read(all => [{ type => 'GOAWAY' }]); | 1105 $frames = $s->read(all => [{ type => 'GOAWAY' }]); |
1103 | 1106 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; |
1104 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; | 1107 ok($frame, 'GOAWAY on connection close - idle stream'); |
1105 ok($frame, 'GOAWAY on connection close'); | 1108 |
1109 TODO: { | |
1110 local $TODO = 'not yet'; | |
1111 | |
1112 $frames = $active->read(all => [{ type => 'GOAWAY' }]); | |
1113 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; | |
1114 ok($frame, 'GOAWAY on connection close - active stream'); | |
1115 | |
1116 } | |
1106 | 1117 |
1107 ############################################################################### | 1118 ############################################################################### |
1108 | 1119 |
1109 sub gunzip_like { | 1120 sub gunzip_like { |
1110 my ($in, $re, $name) = @_; | 1121 my ($in, $re, $name) = @_; |