Mercurial > hg > nginx-tests
comparison grpc.t @ 1699:202d8feedad1
Tests: added grpc test for receiving SETTINGS in grpc filter.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Thu, 03 Jun 2021 19:51:08 +0300 |
parents | 90201294e1b6 |
children | c903c0a3f302 |
comparison
equal
deleted
inserted
replaced
1698:90201294e1b6 | 1699:202d8feedad1 |
---|---|
22 | 22 |
23 select STDERR; $| = 1; | 23 select STDERR; $| = 1; |
24 select STDOUT; $| = 1; | 24 select STDOUT; $| = 1; |
25 | 25 |
26 my $t = Test::Nginx->new()->has(qw/http rewrite http_v2 grpc/) | 26 my $t = Test::Nginx->new()->has(qw/http rewrite http_v2 grpc/) |
27 ->has(qw/upstream_keepalive/)->plan(130); | 27 ->has(qw/upstream_keepalive/)->plan(138); |
28 | 28 |
29 $t->write_file_expand('nginx.conf', <<'EOF'); | 29 $t->write_file_expand('nginx.conf', <<'EOF'); |
30 | 30 |
31 %%TEST_GLOBALS%% | 31 %%TEST_GLOBALS%% |
32 | 32 |
211 cmp_ok($frame->{sid}, '>', $sid, 'keepalive 2 - HEADERS sid next'); | 211 cmp_ok($frame->{sid}, '>', $sid, 'keepalive 2 - HEADERS sid next'); |
212 $f->{data}('Hello'); | 212 $f->{data}('Hello'); |
213 $frames = $f->{http_end}(); | 213 $frames = $f->{http_end}(); |
214 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | 214 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
215 is($frame->{headers}{'x-connection'}, $c, 'keepalive 2 - connection reuse'); | 215 is($frame->{headers}{'x-connection'}, $c, 'keepalive 2 - connection reuse'); |
216 | |
217 undef $f; | |
218 $f = grpc(); | |
219 | |
220 # upstream keepalive | |
221 # grpc filter setting INITIAL_WINDOW_SIZE is inherited in the next stream | |
222 | |
223 $f->{http_start}('/KeepAlive'); | |
224 $f->{data}('Hello'); | |
225 $f->{settings}(0, 1 => 4096); | |
226 $frames = $f->{http_end}(grpc_filter_settings => { 0x4 => 2 }); | |
227 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
228 ok($c = $frame->{headers}{'x-connection'}, 'keepalive 3 - connection'); | |
229 | |
230 $f->{http_start}('/KeepAlive', reuse => 1); | |
231 $frames = $f->{data_len}('Hello', 2); | |
232 ($frame) = grep { $_->{type} eq "DATA" } @$frames; | |
233 is($frame->{data}, 'He', 'grpc filter setting - DATA'); | |
234 is($frame->{length}, 2, 'grpc filter setting - DATA length'); | |
235 is($frame->{flags}, 0, 'grpc filter setting - DATA flags'); | |
236 $f->{settings}(0, 0x4 => 5); | |
237 $frames = $f->{data_len}(undef, 3); | |
238 ($frame) = grep { $_->{type} eq "DATA" } @$frames; | |
239 is($frame->{data}, 'llo', 'setting updated - DATA'); | |
240 is($frame->{length}, 3, 'setting updated - DATA length'); | |
241 is($frame->{flags}, 1, 'setting updated - DATA flags'); | |
242 $frames = $f->{http_end}(); | |
243 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
244 is($frame->{headers}{'x-connection'}, $c, 'keepalive 3 - connection reuse'); | |
216 | 245 |
217 undef $f; | 246 undef $f; |
218 $f = grpc(); | 247 $f = grpc(); |
219 | 248 |
220 # various header compression formats | 249 # various header compression formats |
690 push @$h, { name => 'content-length', value => $extra{cl} } | 719 push @$h, { name => 'content-length', value => $extra{cl} } |
691 if $extra{cl}; | 720 if $extra{cl}; |
692 $c->new_stream({ body_more => 1, headers => $h, %extra }, $sid); | 721 $c->new_stream({ body_more => 1, headers => $h, %extra }, $sid); |
693 $c->h2_body('Hello world', { body_more => 1, | 722 $c->h2_body('Hello world', { body_more => 1, |
694 body_padding => $extra{body_padding} }); | 723 body_padding => $extra{body_padding} }); |
724 $c->h2_settings(0, %{$extra{grpc_filter_settings}}) | |
725 if $extra{grpc_filter_settings}; | |
695 $c->new_stream({ headers => [ | 726 $c->new_stream({ headers => [ |
696 { name => 'grpc-status', value => '0', | 727 { name => 'grpc-status', value => '0', |
697 mode => 2, huff => 1 }, | 728 mode => 2, huff => 1 }, |
698 { name => 'grpc-message', value => '', | 729 { name => 'grpc-message', value => '', |
699 mode => 2, huff => 1 }, | 730 mode => 2, huff => 1 }, |