Mercurial > hg > nginx-tests
comparison grpc.t @ 1370:23e407a72fe9
Tests: upstream keepalive with grpc pending frames.
This is a specific test for the bug fixed in 1.15.4. Note that a similar test
in grpc_ssl.t manifests the bug as a side effect and with certain event methods.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Mon, 03 Sep 2018 21:21:30 +0300 |
parents | 6874b32dc3d2 |
children | 97c8280de681 |
comparison
equal
deleted
inserted
replaced
1369:a37d8526e691 | 1370:23e407a72fe9 |
---|---|
89 } | 89 } |
90 } | 90 } |
91 | 91 |
92 EOF | 92 EOF |
93 | 93 |
94 $t->try_run('no grpc')->plan(100); | 94 $t->try_run('no grpc')->plan(105); |
95 | 95 |
96 ############################################################################### | 96 ############################################################################### |
97 | 97 |
98 my $p = port(8081); | 98 my $p = port(8081); |
99 my $f = grpc(); | 99 my $f = grpc(); |
170 cmp_ok($frame->{sid}, '>', $sid, 'keepalive - HEADERS sid next'); | 170 cmp_ok($frame->{sid}, '>', $sid, 'keepalive - HEADERS sid next'); |
171 $f->{data}('Hello'); | 171 $f->{data}('Hello'); |
172 $frames = $f->{http_end}(); | 172 $frames = $f->{http_end}(); |
173 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | 173 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
174 is($frame->{headers}{'x-connection'}, $c, 'keepalive - connection reuse'); | 174 is($frame->{headers}{'x-connection'}, $c, 'keepalive - connection reuse'); |
175 | |
176 # upstream keepalive | |
177 # pending control frame ack after the response | |
178 | |
179 undef $f; | |
180 $f = grpc(); | |
181 | |
182 $frames = $f->{http_start}('/KeepAlive'); | |
183 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
184 is($frame->{sid}, $sid, 'keepalive 2 - HEADERS sid'); | |
185 $f->{data}('Hello'); | |
186 $f->{settings}(0, 1 => 4096); | |
187 $frames = $f->{http_end}(); | |
188 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
189 ok($c = $frame->{headers}{'x-connection'}, 'keepalive 2 - connection'); | |
190 | |
191 $frames = $f->{http_start}('/KeepAlive', reuse => 1); | |
192 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
193 | |
194 TODO: { | |
195 local $TODO = 'not yet' unless $t->has_version('1.15.4'); | |
196 | |
197 ok($frame, 'upstream keepalive reused'); | |
198 | |
199 } | |
200 | |
201 TODO: { | |
202 todo_skip 'upstream connection failed', 2 unless $frame; | |
203 | |
204 cmp_ok($frame->{sid}, '>', $sid, 'keepalive 2 - HEADERS sid next'); | |
205 $f->{data}('Hello'); | |
206 $frames = $f->{http_end}(); | |
207 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
208 is($frame->{headers}{'x-connection'}, $c, 'keepalive 2 - connection reuse'); | |
209 | |
210 } | |
211 | |
212 undef $f; | |
213 $f = grpc(); | |
175 | 214 |
176 # various header compression formats | 215 # various header compression formats |
177 | 216 |
178 $f->{http_start}('/SayHello'); | 217 $f->{http_start}('/SayHello'); |
179 $f->{data}('Hello'); | 218 $f->{data}('Hello'); |
512 $c->h2_window(shift); | 551 $c->h2_window(shift); |
513 }; | 552 }; |
514 $f->{update_sid} = sub { | 553 $f->{update_sid} = sub { |
515 $c->h2_window(shift, $sid); | 554 $c->h2_window(shift, $sid); |
516 }; | 555 }; |
556 $f->{settings} = sub { | |
557 $c->h2_settings(@_); | |
558 }; | |
517 $f->{http_end} = sub { | 559 $f->{http_end} = sub { |
518 my (%extra) = @_; | 560 my (%extra) = @_; |
519 $c->new_stream({ body_more => 1, %extra, headers => [ | 561 $c->new_stream({ body_more => 1, %extra, headers => [ |
520 { name => ':status', value => '200', | 562 { name => ':status', value => '200', |
521 mode => $extra{mode} || 0 }, | 563 mode => $extra{mode} || 0 }, |