Mercurial > hg > nginx-tests
changeset 1624:81fd6615358e
Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Tue, 24 Nov 2020 16:11:13 +0000 |
parents | 3fe652bc9dae |
children | a140cab489e8 |
files | grpc.t |
diffstat | 1 files changed, 37 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/grpc.t +++ b/grpc.t @@ -24,7 +24,7 @@ select STDERR; $| = 1; select STDOUT; $| = 1; my $t = Test::Nginx->new()->has(qw/http rewrite http_v2 grpc/) - ->has(qw/upstream_keepalive/)->plan(111); + ->has(qw/upstream_keepalive/)->plan(113); $t->write_file_expand('nginx.conf', <<'EOF'); @@ -514,6 +514,28 @@ is($frame->{flags}, undef, 'discard NO_E (undef, $frame) = grep { $_->{type} eq "HEADERS" } @$frames; is($frame->{flags}, undef, 'discard CANCEL - no trailers'); +# upstream keepalive, grpc error +# receiving END_STREAM followed by RST_STREAM NO_ERROR + +$f->{http_start}('/KeepAlive'); +$f->{data}('Hello'); +$frames = $f->{http_err_rst}(); +($frame) = grep { $_->{type} eq "HEADERS" } @$frames; +ok($frame->{headers}{'grpc-status'}, 'keepalive 3 - grpc error, rst'); + +$frames = $f->{http_start}('/KeepAlive', reuse => 1); +($frame) = grep { $_->{type} eq "HEADERS" } @$frames; + +TODO: { +local $TODO = 'not yet' unless $t->has_version('1.19.5'); + +ok($frame, 'keepalive 3 - connection reused'); + +} + +undef $f; +$f = grpc(); + ############################################################################### sub grpc { @@ -660,6 +682,20 @@ sub grpc { return $s->read(all => [{ fin => 1 }]); }; + $f->{http_err_rst} = sub { + $c->start_chain(); + $c->new_stream({ headers => [ + { name => ':status', value => '200', mode => 0 }, + { name => 'content-type', value => 'application/grpc' }, + { name => 'grpc-status', value => '12', mode => 2 }, + { name => 'grpc-message', value => 'unknown service', + mode => 2 }, + ]}, $sid); + $c->h2_rst($sid, 0); + $c->send_chain(); + + return $s->read(all => [{ fin => 1 }]); + }; $f->{http_err2} = sub { my %extra = @_; $c->new_stream({ body_more => 1, headers => [