annotate grpc.t @ 1653:259dfb223f9a

Tests: compatibility with http2_max_header/field_size removal. Tests are adjusted to equally fit in limits set by both old and new ways: http2_max_header_size / http2_max_field_size and large_client_header_buffers.
author Sergey Kandaurov <pluknet@nginx.com>
date Wed, 10 Feb 2021 15:13:22 +0300
parents 62a1667f60f8
children 0fae67763be5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1303
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1 #!/usr/bin/perl
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3 # (C) Sergey Kandaurov
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
4 # (C) Nginx, Inc.
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
5
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
6 # Tests for grpc backend.
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
7
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
8 ###############################################################################
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
9
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
10 use warnings;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
11 use strict;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
12
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
13 use Test::More;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
14
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
15 BEGIN { use FindBin; chdir($FindBin::Bin); }
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
16
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
17 use lib 'lib';
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
18 use Test::Nginx;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
19 use Test::Nginx::HTTP2;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
20
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
21 ###############################################################################
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
22
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
23 select STDERR; $| = 1;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
24 select STDOUT; $| = 1;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
25
1312
6f95c0ed2335 Tests: removed proxy prerequisite from grpc tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1303
diff changeset
26 my $t = Test::Nginx->new()->has(qw/http rewrite http_v2 grpc/)
1624
81fd6615358e Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1623
diff changeset
27 ->has(qw/upstream_keepalive/)->plan(113);
1303
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
28
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
29 $t->write_file_expand('nginx.conf', <<'EOF');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
30
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
31 %%TEST_GLOBALS%%
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
32
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
33 daemon off;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
34
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
35 events {
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
36 }
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
37
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
38 http {
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
39 %%TEST_GLOBALS_HTTP%%
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
40
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
41 upstream u {
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
42 server 127.0.0.1:8081;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
43 keepalive 1;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
44 }
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
45
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
46 server {
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
47 listen 127.0.0.1:8080 http2;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
48 server_name localhost;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
49
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
50 http2_max_field_size 128k;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
51 http2_max_header_size 128k;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
52 http2_body_preread_size 128k;
1653
259dfb223f9a Tests: compatibility with http2_max_header/field_size removal.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1631
diff changeset
53 large_client_header_buffers 4 32k;
1303
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
54
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
55 location / {
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
56 grpc_pass grpc://127.0.0.1:8081;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
57
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
58 if ($arg_if) {
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
59 # nothing
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
60 }
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
61
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
62 limit_except GET {
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
63 # nothing
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
64 }
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
65 }
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
66
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
67 location /KeepAlive {
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
68 grpc_pass u;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
69 }
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
70
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
71 location /LongHeader {
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
72 grpc_pass 127.0.0.1:8081;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
73 grpc_set_header X-LongHeader $arg_h;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
74 }
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
75
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
76 location /LongField {
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
77 grpc_pass 127.0.0.1:8081;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
78 grpc_buffer_size 65k;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
79 }
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
80
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
81 location /SetHost {
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
82 grpc_pass 127.0.0.1:8081;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
83 grpc_set_header Host custom;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
84 }
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
85
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
86 location /SetArgs {
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
87 grpc_pass 127.0.0.1:8081;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
88 set $args $arg_c;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
89 }
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
90 }
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
91 }
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
92
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
93 EOF
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
94
1653
259dfb223f9a Tests: compatibility with http2_max_header/field_size removal.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1631
diff changeset
95 # suppress deprecation warning
259dfb223f9a Tests: compatibility with http2_max_header/field_size removal.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1631
diff changeset
96
259dfb223f9a Tests: compatibility with http2_max_header/field_size removal.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1631
diff changeset
97 open OLDERR, ">&", \*STDERR; close STDERR;
1381
97c8280de681 Tests: removed TODO and try_run() checks for legacy versions.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1370
diff changeset
98 $t->run();
1653
259dfb223f9a Tests: compatibility with http2_max_header/field_size removal.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1631
diff changeset
99 open STDERR, ">&", \*OLDERR;
1303
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
100
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
101 ###############################################################################
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
102
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
103 my $p = port(8081);
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
104 my $f = grpc();
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
105
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
106 my $frames = $f->{http_start}('/SayHello');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
107 my ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
108 is($frame->{flags}, 4, 'request - HEADERS flags');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
109 ok((my $sid = $frame->{sid}) % 2, 'request - HEADERS sid odd');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
110 is($frame->{headers}{':method'}, 'POST', 'request - method');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
111 is($frame->{headers}{':scheme'}, 'http', 'request - scheme');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
112 is($frame->{headers}{':path'}, '/SayHello', 'request - path');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
113 is($frame->{headers}{':authority'}, "127.0.0.1:$p", 'request - authority');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
114 is($frame->{headers}{'content-type'}, 'application/grpc',
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
115 'request - content type');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
116 is($frame->{headers}{te}, 'trailers', 'request - te');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
117
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
118 $frames = $f->{data}('Hello');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
119 ($frame) = grep { $_->{type} eq "SETTINGS" } @$frames;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
120 is($frame->{flags}, 1, 'request - SETTINGS ack');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
121 is($frame->{sid}, 0, 'request - SETTINGS sid');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
122 is($frame->{length}, 0, 'request - SETTINGS length');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
123
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
124 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
125 is($frame->{data}, 'Hello', 'request - DATA');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
126 is($frame->{length}, 5, 'request - DATA length');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
127 is($frame->{flags}, 1, 'request - DATA flags');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
128 is($frame->{sid}, $sid, 'request - DATA sid match');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
129
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
130 $frames = $f->{http_end}();
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
131 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
132 is($frame->{flags}, 4, 'response - HEADERS flags');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
133 is($frame->{sid}, 1, 'response - HEADERS sid');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
134 is($frame->{headers}{':status'}, '200', 'response - status');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
135 is($frame->{headers}{'content-type'}, 'application/grpc',
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
136 'response - content type');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
137 ok($frame->{headers}{server}, 'response - server');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
138 ok($frame->{headers}{date}, 'response - date');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
139 ok(my $c = $frame->{headers}{'x-connection'}, 'response - connection');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
140
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
141 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
142 is($frame->{data}, 'Hello world', 'response - DATA');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
143 is($frame->{length}, 11, 'response - DATA length');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
144 is($frame->{flags}, 0, 'response - DATA flags');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
145 is($frame->{sid}, 1, 'response - DATA sid');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
146
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
147 (undef, $frame) = grep { $_->{type} eq "HEADERS" } @$frames;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
148 is($frame->{flags}, 5, 'response - trailers flags');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
149 is($frame->{sid}, 1, 'response - trailers sid');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
150 is($frame->{headers}{'grpc-message'}, '', 'response - trailers message');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
151 is($frame->{headers}{'grpc-status'}, '0', 'response - trailers status');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
152
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
153 # next request is on a new backend connection, no sid incremented
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
154
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
155 $frames = $f->{http_start}('/SayHello');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
156 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
157 is($frame->{sid}, $sid, 'request 2 - HEADERS sid again');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
158 $f->{data}('Hello');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
159 $frames = $f->{http_end}();
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
160 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
161 cmp_ok($frame->{headers}{'x-connection'}, '>', $c, 'response 2 - connection');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
162
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
163 # upstream keepalive
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
164
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
165 $frames = $f->{http_start}('/KeepAlive');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
166 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
167 is($frame->{sid}, $sid, 'keepalive - HEADERS sid');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
168 $f->{data}('Hello');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
169 $frames = $f->{http_end}();
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
170 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
171 ok($c = $frame->{headers}{'x-connection'}, 'keepalive - connection');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
172
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
173 $frames = $f->{http_start}('/KeepAlive', reuse => 1);
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
174 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
175 cmp_ok($frame->{sid}, '>', $sid, 'keepalive - HEADERS sid next');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
176 $f->{data}('Hello');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
177 $frames = $f->{http_end}();
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
178 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
179 is($frame->{headers}{'x-connection'}, $c, 'keepalive - connection reuse');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
180
1370
23e407a72fe9 Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1362
diff changeset
181 # upstream keepalive
23e407a72fe9 Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1362
diff changeset
182 # pending control frame ack after the response
23e407a72fe9 Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1362
diff changeset
183
23e407a72fe9 Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1362
diff changeset
184 undef $f;
23e407a72fe9 Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1362
diff changeset
185 $f = grpc();
23e407a72fe9 Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1362
diff changeset
186
23e407a72fe9 Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1362
diff changeset
187 $frames = $f->{http_start}('/KeepAlive');
23e407a72fe9 Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1362
diff changeset
188 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
23e407a72fe9 Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1362
diff changeset
189 is($frame->{sid}, $sid, 'keepalive 2 - HEADERS sid');
23e407a72fe9 Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1362
diff changeset
190 $f->{data}('Hello');
23e407a72fe9 Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1362
diff changeset
191 $f->{settings}(0, 1 => 4096);
23e407a72fe9 Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1362
diff changeset
192 $frames = $f->{http_end}();
23e407a72fe9 Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1362
diff changeset
193 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
23e407a72fe9 Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1362
diff changeset
194 ok($c = $frame->{headers}{'x-connection'}, 'keepalive 2 - connection');
23e407a72fe9 Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1362
diff changeset
195
23e407a72fe9 Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1362
diff changeset
196 $frames = $f->{http_start}('/KeepAlive', reuse => 1);
23e407a72fe9 Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1362
diff changeset
197 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
23e407a72fe9 Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1362
diff changeset
198 ok($frame, 'upstream keepalive reused');
23e407a72fe9 Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1362
diff changeset
199
23e407a72fe9 Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1362
diff changeset
200 cmp_ok($frame->{sid}, '>', $sid, 'keepalive 2 - HEADERS sid next');
23e407a72fe9 Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1362
diff changeset
201 $f->{data}('Hello');
23e407a72fe9 Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1362
diff changeset
202 $frames = $f->{http_end}();
23e407a72fe9 Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1362
diff changeset
203 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
23e407a72fe9 Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1362
diff changeset
204 is($frame->{headers}{'x-connection'}, $c, 'keepalive 2 - connection reuse');
23e407a72fe9 Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1362
diff changeset
205
23e407a72fe9 Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1362
diff changeset
206 undef $f;
23e407a72fe9 Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1362
diff changeset
207 $f = grpc();
23e407a72fe9 Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1362
diff changeset
208
1303
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
209 # various header compression formats
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
210
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
211 $f->{http_start}('/SayHello');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
212 $f->{data}('Hello');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
213 $frames = $f->{http_end}(mode => 3);
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
214 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
215 is($frame->{headers}{':status'}, '200', 'without indexing');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
216 is($frame->{headers}{'content-type'}, 'application/grpc',
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
217 'without indexing 2');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
218
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
219 $f->{http_start}('/SayHello');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
220 $f->{data}('Hello');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
221 $frames = $f->{http_end}(mode => 4);
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
222 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
223 is($frame->{headers}{':status'}, '200', 'without indexing new');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
224 is($frame->{headers}{'content-type'}, 'application/grpc',
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
225 'without indexing new 2');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
226
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
227 $f->{http_start}('/SayHello');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
228 $f->{data}('Hello');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
229 $frames = $f->{http_end}(mode => 5);
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
230 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
231 is($frame->{headers}{':status'}, '200', 'never indexed');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
232 is($frame->{headers}{'content-type'}, 'application/grpc',
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
233 'never indexed 2');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
234
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
235 $f->{http_start}('/SayHello');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
236 $f->{data}('Hello');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
237 $frames = $f->{http_end}(mode => 6);
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
238 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
239 is($frame->{headers}{':status'}, '200', 'never indexed new');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
240 is($frame->{headers}{'content-type'}, 'application/grpc',
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
241 'never indexed new 2');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
242
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
243 # padding & priority
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
244
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
245 $f->{http_start}('/SayHello');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
246 $f->{data}('Hello');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
247 $frames = $f->{http_end}(padding => 7);
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
248 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
249 is($frame->{headers}{':status'}, '200', 'padding');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
250
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
251 $f->{http_start}('/SayHello');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
252 $f->{data}('Hello');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
253 $frames = $f->{http_end}(prio => 137, dep => 0x01020304);
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
254 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
255 is($frame->{headers}{':status'}, '200', 'priority');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
256
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
257 $f->{http_start}('/SayHello');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
258 $f->{data}('Hello');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
259 $frames = $f->{http_end}(padding => 7, prio => 137, dep => 0x01020304);
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
260 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
261 is($frame->{headers}{':status'}, '200', 'padding priority');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
262
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
263 SKIP: {
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
264 skip 'long test', 1 unless $ENV{TEST_NGINX_UNSAFE};
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
265
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
266 $f->{http_start}('/SaySplit');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
267 $f->{data}('Hello');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
268 $frames = $f->{http_end}(padding => 7, prio => 137, dep => 0x01020304,
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
269 split => [(map{1}(1..20)), 30], split_delay => 0.1);
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
270 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
271 is($frame->{headers}{':status'}, '200', 'padding priority split');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
272
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
273 }
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
274
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
275 # grpc error, no empty data frame expected
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
276
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
277 $f->{http_start}('/SayHello');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
278 $f->{data}('Hello');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
279 $frames = $f->{http_err}();
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
280 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
281 is($frame->{flags}, 5, 'grpc error - HEADERS flags');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
282 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
283 ok(!$frame, 'grpc error - no DATA frame');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
284
1583
8aede7babd9a Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1564
diff changeset
285 # malformed response body length not equal to content-length
8aede7babd9a Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1564
diff changeset
286
8aede7babd9a Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1564
diff changeset
287 TODO: {
8aede7babd9a Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1564
diff changeset
288 local $TODO = 'not yet' unless $t->has_version('1.19.1');
8aede7babd9a Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1564
diff changeset
289
8aede7babd9a Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1564
diff changeset
290 $f->{http_start}('/SayHello');
8aede7babd9a Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1564
diff changeset
291 $f->{data}('Hello');
8aede7babd9a Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1564
diff changeset
292 $frames = $f->{http_err2}(cl => 42);
8aede7babd9a Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1564
diff changeset
293 ($frame) = grep { $_->{type} eq "RST_STREAM" } @$frames;
8aede7babd9a Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1564
diff changeset
294 ok($frame, 'response body less than content-length');
8aede7babd9a Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1564
diff changeset
295
8aede7babd9a Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1564
diff changeset
296 $f->{http_start}('/SayHello');
8aede7babd9a Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1564
diff changeset
297 $f->{data}('Hello');
8aede7babd9a Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1564
diff changeset
298 $frames = $f->{http_err2}(cl => 8);
8aede7babd9a Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1564
diff changeset
299 ($frame) = grep { $_->{type} eq "RST_STREAM" } @$frames;
8aede7babd9a Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1564
diff changeset
300 ok($frame, 'response body more than content-length');
8aede7babd9a Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1564
diff changeset
301
8aede7babd9a Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1564
diff changeset
302 }
8aede7babd9a Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1564
diff changeset
303
1303
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
304 # continuation from backend, expect parts assembled
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
305
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
306 $f->{http_start}('/SayHello');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
307 $f->{data}('Hello');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
308 $frames = $f->{continuation}();
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
309 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
310 is($frame->{flags}, 4, 'continuation - HEADERS flags');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
311 is($frame->{headers}{':status'}, '200', 'continuation - status');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
312 is($frame->{headers}{'content-type'}, 'application/grpc',
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
313 'continuation - content type');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
314
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
315 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
316 is($frame->{data}, 'Hello world', 'continuation - DATA');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
317 is($frame->{length}, 11, 'continuation - DATA length');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
318 is($frame->{flags}, 0, 'continuation - DATA flags');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
319
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
320 (undef, $frame) = grep { $_->{type} eq "HEADERS" } @$frames;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
321 is($frame->{flags}, 5, 'continuation - trailers flags');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
322 is($frame->{headers}{'grpc-message'}, '', 'continuation - trailers message');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
323 is($frame->{headers}{'grpc-status'}, '0', 'continuation - trailers status');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
324
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
325 # continuation from backend, header split
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
326
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
327 $f->{http_start}('/SayHello');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
328 $f->{data}('Hello');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
329 $frames = $f->{http_end}(mode => 6, continuation => [map { 1 } (1 .. 42)]);
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
330 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
331 is($frame->{headers}{':status'}, '200', 'continuation - header split');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
332
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
333 # continuation to backend
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
334
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
335 $frames = $f->{http_start}('/LongHeader?h=' . ('Z' x 31337));
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
336 @$frames = grep { $_->{type} =~ "HEADERS|CONTINUATION" } @$frames;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
337 is(@$frames, 4, 'continuation - frames');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
338
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
339 $frame = shift @$frames;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
340 is($frame->{type}, 'HEADERS', 'continuation - HEADERS');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
341 is($frame->{length}, 16384, 'continuation - HEADERS length');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
342 is($frame->{flags}, 1, 'continuation - HEADERS flags');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
343 ok($frame->{sid}, 'continuation - HEADERS sid');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
344
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
345 $frame = shift @$frames;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
346 is($frame->{type}, 'CONTINUATION', 'continuation - CONTINUATION');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
347 is($frame->{length}, 16384, 'continuation - CONTINUATION length');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
348 is($frame->{flags}, 0, 'continuation - CONTINUATION flags');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
349 ok($frame->{sid}, 'continuation - CONTINUATION sid');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
350
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
351 $frame = shift @$frames;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
352 is($frame->{type}, 'CONTINUATION', 'continuation - CONTINUATION 2');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
353 is($frame->{length}, 16384, 'continuation - CONTINUATION 2 length');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
354 is($frame->{flags}, 0, 'continuation - CONTINUATION 2 flags');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
355
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
356 $frame = shift @$frames;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
357 is($frame->{type}, 'CONTINUATION', 'continuation - CONTINUATION n');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
358 cmp_ok($frame->{length}, '<', 16384, 'continuation - CONTINUATION n length');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
359 is($frame->{flags}, 4, 'continuation - CONTINUATION n flags');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
360 is($frame->{headers}{':path'}, '/LongHeader?h=' . 'Z' x 31337,
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
361 'continuation - path');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
362 is($frame->{headers}{'x-longheader'}, 'Z' x 31337, 'continuation - header');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
363
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
364 $f->{http_end}();
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
365
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
366 # long header field
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
367
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
368 $f->{http_start}('/LongField');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
369 $f->{data}('Hello');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
370 $frames = $f->{field_len}(2**7);
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
371 ($frame) = grep { $_->{flags} & 0x4 } @$frames;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
372 is($frame->{headers}{'x' x 2**7}, 'y' x 2**7, 'long header field 1');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
373
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
374 $f->{http_start}('/LongField');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
375 $f->{data}('Hello');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
376 $frames = $f->{field_len}(2**8);
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
377 ($frame) = grep { $_->{flags} & 0x4 } @$frames;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
378 is($frame->{headers}{'x' x 2**8}, 'y' x 2**8, 'long header field 2');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
379
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
380 $f->{http_start}('/LongField');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
381 $f->{data}('Hello');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
382 $frames = $f->{field_len}(2**15);
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
383 ($frame) = grep { $_->{flags} & 0x4 } @$frames;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
384 is($frame->{headers}{'x' x 2**15}, 'y' x 2**15, 'long header field 3');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
385
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
386 # flow control
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
387
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
388 $f->{http_start}('/FlowControl');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
389 $frames = $f->{data_len}(('Hello' x 13000) . ('x' x 550), 65535);
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
390 my $sum = eval join '+', map { $_->{type} eq "DATA" && $_->{length} } @$frames;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
391 is($sum, 65535, 'flow control - iws length');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
392
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
393 $f->{update}(10);
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
394 $f->{update_sid}(10);
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
395
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
396 $frames = $f->{data_len}(undef, 10);
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
397 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
398 is($frame->{length}, 10, 'flow control - update length');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
399 is($frame->{flags}, 0, 'flow control - update flags');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
400
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
401 $f->{update_sid}(10);
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
402 $f->{update}(10);
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
403
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
404 $frames = $f->{data_len}(undef, 5);
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
405 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
406 is($frame->{length}, 5, 'flow control - rest length');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
407 is($frame->{flags}, 1, 'flow control - rest flags');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
408
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
409 $f->{http_end}();
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
410
1318
6de2a27af2d3 Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents: 1312
diff changeset
411 # preserve output
6de2a27af2d3 Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents: 1312
diff changeset
412
6de2a27af2d3 Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents: 1312
diff changeset
413 $f->{http_start}('/Preserve');
6de2a27af2d3 Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents: 1312
diff changeset
414 $f->{data}('Hello');
6de2a27af2d3 Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents: 1312
diff changeset
415 $frames = $f->{http_pres}();
6de2a27af2d3 Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents: 1312
diff changeset
416 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
6de2a27af2d3 Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents: 1312
diff changeset
417 is($frame->{flags}, 4, 'preserve - HEADERS');
6de2a27af2d3 Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents: 1312
diff changeset
418
6de2a27af2d3 Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents: 1312
diff changeset
419 my @data = grep { $_->{type} eq "DATA" } @$frames;
6de2a27af2d3 Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents: 1312
diff changeset
420 $sum = eval join '+', map { $_->{length} } @data;
1319
3b30e97acdcb Tests: made grpc preserve output test pass on win32 and Solaris.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1318
diff changeset
421 is($sum, 20480, 'preserve - DATA');
1318
6de2a27af2d3 Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents: 1312
diff changeset
422
6de2a27af2d3 Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents: 1312
diff changeset
423 (undef, $frame) = grep { $_->{type} eq "HEADERS" } @$frames;
6de2a27af2d3 Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents: 1312
diff changeset
424 is($frame->{flags}, 5, 'preserve - trailers');
6de2a27af2d3 Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents: 1312
diff changeset
425
1303
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
426 # DATA padding
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
427
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
428 $f->{http_start}('/SayPadding');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
429 $f->{data}('Hello');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
430 $frames = $f->{http_end}(body_padding => 42);
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
431 ($frame) = grep { $_->{type} eq "DATA" } @$frames;
1362
6874b32dc3d2 Tests: renamed some grpc.t tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1321
diff changeset
432 is($frame->{data}, 'Hello world', 'DATA padding');
6874b32dc3d2 Tests: renamed some grpc.t tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1321
diff changeset
433 is($frame->{length}, 11, 'DATA padding - length');
6874b32dc3d2 Tests: renamed some grpc.t tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1321
diff changeset
434 is($frame->{flags}, 0, 'DATA padding - flags');
1303
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
435
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
436 # :authority inheritance
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
437
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
438 $frames = $f->{http_start}('/SayHello?if=1');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
439 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
440 is($frame->{headers}{':authority'}, "127.0.0.1:$p", 'authority in if');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
441 $f->{data}('Hello');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
442 $f->{http_end}();
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
443
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
444 # misc tests
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
445
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
446 $frames = $f->{http_start}('/SetHost');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
447 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
448 ok(!$frame->{headers}{':authority'}, 'set host - authority');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
449 is($frame->{headers}{'host'}, 'custom', 'set host - host');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
450 $f->{data}('Hello');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
451 $f->{http_end}();
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
452
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
453 $frames = $f->{http_start}('/SetArgs?f');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
454 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
455 is($frame->{headers}{':path'}, '/SetArgs', 'set args');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
456 $f->{data}('Hello');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
457 $f->{http_end}();
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
458
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
459 $frames = $f->{http_start}('/SetArgs?c=1');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
460 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
461 is($frame->{headers}{':path'}, '/SetArgs?1', 'set args len');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
462 $f->{data}('Hello');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
463 $f->{http_end}();
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
464
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
465 $frames = $f->{http_start}('/SetArgs esc');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
466 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
467 is($frame->{headers}{':path'}, '/SetArgs%20esc', 'uri escape');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
468 $f->{data}('Hello');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
469 $f->{http_end}();
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
470
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
471 $frames = $f->{http_start}('/');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
472 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
473 is($frame->{headers}{':path'}, '/', 'root index');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
474 $f->{data}('Hello');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
475 $f->{http_end}();
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
476
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
477 $frames = $f->{http_start}('/', method => 'GET');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
478 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
479 is($frame->{headers}{':method'}, 'GET', 'method get');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
480 $f->{data}('Hello');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
481 $f->{http_end}();
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
482
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
483 $frames = $f->{http_start}('/', method => 'HEAD');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
484 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
485 is($frame->{headers}{':method'}, 'HEAD', 'method head');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
486 $f->{data}('Hello');
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
487 $f->{http_end}();
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
488
1564
fe938b5daf80 Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1535
diff changeset
489 TODO: {
fe938b5daf80 Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1535
diff changeset
490 local $TODO = 'not yet' unless $t->has_version('1.19.0');
fe938b5daf80 Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1535
diff changeset
491
fe938b5daf80 Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1535
diff changeset
492 # receiving END_STREAM followed by WINDOW_UPDATE on incomplete request body
fe938b5daf80 Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1535
diff changeset
493
fe938b5daf80 Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1535
diff changeset
494 $f->{http_start}('/Discard_WU');
fe938b5daf80 Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1535
diff changeset
495 $frames = $f->{discard}();
fe938b5daf80 Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1535
diff changeset
496 (undef, $frame) = grep { $_->{type} eq "HEADERS" } @$frames;
fe938b5daf80 Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1535
diff changeset
497 is($frame->{flags}, 5, 'discard WINDOW_UPDATE - trailers');
fe938b5daf80 Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1535
diff changeset
498
fe938b5daf80 Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1535
diff changeset
499 # receiving END_STREAM followed by RST_STREAM NO_ERROR
fe938b5daf80 Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1535
diff changeset
500
fe938b5daf80 Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1535
diff changeset
501 $f->{http_start}('/Discard_NE');
fe938b5daf80 Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1535
diff changeset
502 $frames = $f->{discard}();
fe938b5daf80 Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1535
diff changeset
503 (undef, $frame) = grep { $_->{type} eq "HEADERS" } @$frames;
fe938b5daf80 Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1535
diff changeset
504 is($frame->{flags}, 5, 'discard NO_ERROR - trailers');
fe938b5daf80 Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1535
diff changeset
505
fe938b5daf80 Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1535
diff changeset
506 }
fe938b5daf80 Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1535
diff changeset
507
fe938b5daf80 Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1535
diff changeset
508 # receiving END_STREAM followed by several RST_STREAM NO_ERROR
fe938b5daf80 Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1535
diff changeset
509
fe938b5daf80 Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1535
diff changeset
510 $f->{http_start}('/Discard_NE3');
fe938b5daf80 Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1535
diff changeset
511 $frames = $f->{discard}();
fe938b5daf80 Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1535
diff changeset
512 (undef, $frame) = grep { $_->{type} eq "HEADERS" } @$frames;
fe938b5daf80 Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1535
diff changeset
513 is($frame->{flags}, undef, 'discard NO_ERROR many - no trailers');
fe938b5daf80 Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1535
diff changeset
514
fe938b5daf80 Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1535
diff changeset
515 # receiving END_STREAM followed by RST_STREAM CANCEL
fe938b5daf80 Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1535
diff changeset
516
fe938b5daf80 Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1535
diff changeset
517 $f->{http_start}('/Discard_CNL');
fe938b5daf80 Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1535
diff changeset
518 $frames = $f->{discard}();
fe938b5daf80 Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1535
diff changeset
519 (undef, $frame) = grep { $_->{type} eq "HEADERS" } @$frames;
fe938b5daf80 Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1535
diff changeset
520 is($frame->{flags}, undef, 'discard CANCEL - no trailers');
fe938b5daf80 Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1535
diff changeset
521
1631
62a1667f60f8 Tests: fixed grpc.t after previous change.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1624
diff changeset
522 undef $f;
62a1667f60f8 Tests: fixed grpc.t after previous change.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1624
diff changeset
523 $f = grpc();
62a1667f60f8 Tests: fixed grpc.t after previous change.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1624
diff changeset
524
1624
81fd6615358e Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1623
diff changeset
525 # upstream keepalive, grpc error
81fd6615358e Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1623
diff changeset
526 # receiving END_STREAM followed by RST_STREAM NO_ERROR
81fd6615358e Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1623
diff changeset
527
81fd6615358e Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1623
diff changeset
528 $f->{http_start}('/KeepAlive');
81fd6615358e Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1623
diff changeset
529 $f->{data}('Hello');
81fd6615358e Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1623
diff changeset
530 $frames = $f->{http_err_rst}();
81fd6615358e Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1623
diff changeset
531 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
81fd6615358e Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1623
diff changeset
532 ok($frame->{headers}{'grpc-status'}, 'keepalive 3 - grpc error, rst');
81fd6615358e Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1623
diff changeset
533
81fd6615358e Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1623
diff changeset
534 $frames = $f->{http_start}('/KeepAlive', reuse => 1);
81fd6615358e Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1623
diff changeset
535 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
81fd6615358e Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1623
diff changeset
536
81fd6615358e Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1623
diff changeset
537 TODO: {
81fd6615358e Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1623
diff changeset
538 local $TODO = 'not yet' unless $t->has_version('1.19.5');
81fd6615358e Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1623
diff changeset
539
81fd6615358e Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1623
diff changeset
540 ok($frame, 'keepalive 3 - connection reused');
81fd6615358e Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1623
diff changeset
541
81fd6615358e Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1623
diff changeset
542 }
81fd6615358e Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1623
diff changeset
543
81fd6615358e Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1623
diff changeset
544 undef $f;
81fd6615358e Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1623
diff changeset
545 $f = grpc();
81fd6615358e Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1623
diff changeset
546
1303
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
547 ###############################################################################
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
548
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
549 sub grpc {
1318
6de2a27af2d3 Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents: 1312
diff changeset
550 my ($server, $client, $f, $s, $c, $sid, $csid, $uri);
1303
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
551 my $n = 0;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
552
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
553 $server = IO::Socket::INET->new(
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
554 Proto => 'tcp',
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
555 LocalHost => '127.0.0.1',
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
556 LocalPort => $p,
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
557 Listen => 5,
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
558 Reuse => 1
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
559 )
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
560 or die "Can't create listening socket: $!\n";
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
561
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
562 $f->{http_start} = sub {
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
563 ($uri, my %extra) = @_;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
564 my $body_more = 1 if $uri !~ /LongHeader/;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
565 my $meth = $extra{method} || 'POST';
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
566 $s = Test::Nginx::HTTP2->new() if !defined $s;
1318
6de2a27af2d3 Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents: 1312
diff changeset
567 $csid = $s->new_stream({ body_more => $body_more, headers => [
1303
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
568 { name => ':method', value => $meth, mode => !!$meth },
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
569 { name => ':scheme', value => 'http', mode => 0 },
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
570 { name => ':path', value => $uri, },
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
571 { name => ':authority', value => 'localhost' },
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
572 { name => 'content-type', value => 'application/grpc' },
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
573 { name => 'te', value => 'trailers', mode => 2 }]});
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
574
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
575 if (!$extra{reuse}) {
1321
351b95be742b Tests: fixed grpc tests hang in accept() on internal nginx error.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1319
diff changeset
576 eval {
351b95be742b Tests: fixed grpc tests hang in accept() on internal nginx error.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1319
diff changeset
577 local $SIG{ALRM} = sub { die "timeout\n" };
351b95be742b Tests: fixed grpc tests hang in accept() on internal nginx error.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1319
diff changeset
578 alarm(5);
351b95be742b Tests: fixed grpc tests hang in accept() on internal nginx error.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1319
diff changeset
579
351b95be742b Tests: fixed grpc tests hang in accept() on internal nginx error.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1319
diff changeset
580 $client = $server->accept() or return;
351b95be742b Tests: fixed grpc tests hang in accept() on internal nginx error.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1319
diff changeset
581
351b95be742b Tests: fixed grpc tests hang in accept() on internal nginx error.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1319
diff changeset
582 alarm(0);
351b95be742b Tests: fixed grpc tests hang in accept() on internal nginx error.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1319
diff changeset
583 };
351b95be742b Tests: fixed grpc tests hang in accept() on internal nginx error.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1319
diff changeset
584 alarm(0);
351b95be742b Tests: fixed grpc tests hang in accept() on internal nginx error.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1319
diff changeset
585 if ($@) {
351b95be742b Tests: fixed grpc tests hang in accept() on internal nginx error.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1319
diff changeset
586 log_in("died: $@");
351b95be742b Tests: fixed grpc tests hang in accept() on internal nginx error.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1319
diff changeset
587 return undef;
351b95be742b Tests: fixed grpc tests hang in accept() on internal nginx error.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1319
diff changeset
588 }
351b95be742b Tests: fixed grpc tests hang in accept() on internal nginx error.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1319
diff changeset
589
1303
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
590 log2c("(new connection $client)");
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
591 $n++;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
592
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
593 $client->sysread(my $buf, 24) == 24 or return; # preface
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
594
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
595 $c = Test::Nginx::HTTP2->new(1, socket => $client,
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
596 pure => 1, preface => "") or return;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
597 }
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
598
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
599 my $frames = $c->read(all => [{ fin => 4 }]);
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
600
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
601 if (!$extra{reuse}) {
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
602 $c->h2_settings(0);
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
603 $c->h2_settings(1);
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
604 }
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
605
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
606 my ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
607 $sid = $frame->{sid};
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
608 return $frames;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
609 };
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
610 $f->{data} = sub {
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
611 my ($body, %extra) = @_;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
612 $s->h2_body($body, { %extra });
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
613 return $c->read(all => [{ sid => $sid,
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
614 length => length($body) }]);
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
615 };
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
616 $f->{data_len} = sub {
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
617 my ($body, $len) = @_;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
618 $s->h2_body($body) if defined $body;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
619 return $c->read(all => [{ sid => $sid, length => $len }]);
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
620 };
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
621 $f->{update} = sub {
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
622 $c->h2_window(shift);
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
623 };
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
624 $f->{update_sid} = sub {
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
625 $c->h2_window(shift, $sid);
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
626 };
1370
23e407a72fe9 Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1362
diff changeset
627 $f->{settings} = sub {
23e407a72fe9 Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1362
diff changeset
628 $c->h2_settings(@_);
23e407a72fe9 Tests: upstream keepalive with grpc pending frames.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1362
diff changeset
629 };
1303
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
630 $f->{http_end} = sub {
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
631 my (%extra) = @_;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
632 $c->new_stream({ body_more => 1, %extra, headers => [
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
633 { name => ':status', value => '200',
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
634 mode => $extra{mode} || 0 },
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
635 { name => 'content-type', value => 'application/grpc',
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
636 mode => $extra{mode} || 1, huff => 1 },
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
637 { name => 'x-connection', value => $n,
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
638 mode => 2, huff => 1 },
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
639 ]}, $sid);
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
640 $c->h2_body('Hello world', { body_more => 1,
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
641 body_padding => $extra{body_padding} });
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
642 $c->new_stream({ headers => [
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
643 { name => 'grpc-status', value => '0',
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
644 mode => 2, huff => 1 },
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
645 { name => 'grpc-message', value => '',
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
646 mode => 2, huff => 1 },
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
647 ]}, $sid);
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
648
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
649 return $s->read(all => [{ fin => 1 }]);
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
650 };
1318
6de2a27af2d3 Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents: 1312
diff changeset
651 $f->{http_pres} = sub {
6de2a27af2d3 Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents: 1312
diff changeset
652 my (%extra) = @_;
1319
3b30e97acdcb Tests: made grpc preserve output test pass on win32 and Solaris.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1318
diff changeset
653 $s->h2_settings(0, 0x4 => 8192);
1318
6de2a27af2d3 Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents: 1312
diff changeset
654 $c->new_stream({ body_more => 1, %extra, headers => [
6de2a27af2d3 Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents: 1312
diff changeset
655 { name => ':status', value => '200',
6de2a27af2d3 Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents: 1312
diff changeset
656 mode => $extra{mode} || 0 },
6de2a27af2d3 Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents: 1312
diff changeset
657 { name => 'content-type', value => 'application/grpc',
6de2a27af2d3 Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents: 1312
diff changeset
658 mode => $extra{mode} || 1, huff => 1 },
6de2a27af2d3 Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents: 1312
diff changeset
659 { name => 'x-connection', value => $n,
6de2a27af2d3 Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents: 1312
diff changeset
660 mode => 2, huff => 1 },
6de2a27af2d3 Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents: 1312
diff changeset
661 ]}, $sid);
6de2a27af2d3 Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents: 1312
diff changeset
662 for (1 .. 20) {
1319
3b30e97acdcb Tests: made grpc preserve output test pass on win32 and Solaris.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1318
diff changeset
663 $c->h2_body(sprintf('Hello %02d', $_) x 128, {
1318
6de2a27af2d3 Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents: 1312
diff changeset
664 body_more => 1,
6de2a27af2d3 Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents: 1312
diff changeset
665 body_padding => $extra{body_padding} });
6de2a27af2d3 Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents: 1312
diff changeset
666 $c->h2_ping("PING");
6de2a27af2d3 Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents: 1312
diff changeset
667 }
6de2a27af2d3 Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents: 1312
diff changeset
668 # reopen window
6de2a27af2d3 Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents: 1312
diff changeset
669 $s->h2_window(2**24);
6de2a27af2d3 Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents: 1312
diff changeset
670 $s->h2_window(2**24, $csid);
6de2a27af2d3 Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents: 1312
diff changeset
671 $c->new_stream({ headers => [
6de2a27af2d3 Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents: 1312
diff changeset
672 { name => 'grpc-status', value => '0',
6de2a27af2d3 Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents: 1312
diff changeset
673 mode => 2, huff => 1 },
6de2a27af2d3 Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents: 1312
diff changeset
674 { name => 'grpc-message', value => '',
6de2a27af2d3 Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents: 1312
diff changeset
675 mode => 2, huff => 1 },
6de2a27af2d3 Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents: 1312
diff changeset
676 ]}, $sid);
6de2a27af2d3 Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents: 1312
diff changeset
677
1319
3b30e97acdcb Tests: made grpc preserve output test pass on win32 and Solaris.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1318
diff changeset
678 return $s->read(all => [{ sid => $csid, fin => 1 }]);
1318
6de2a27af2d3 Tests: grpc preserve output tests added (ticket #1519).
Sergey Kandaurov <pluknet@nginx.com>
parents: 1312
diff changeset
679 };
1303
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
680 $f->{http_err} = sub {
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
681 $c->new_stream({ headers => [
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
682 { name => ':status', value => '200', mode => 0 },
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
683 { name => 'content-type', value => 'application/grpc',
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
684 mode => 1, huff => 1 },
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
685 { name => 'grpc-status', value => '12',
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
686 mode => 2, huff => 1 },
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
687 { name => 'grpc-message', value => 'unknown service',
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
688 mode => 2, huff => 1 },
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
689 ]}, $sid);
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
690
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
691 return $s->read(all => [{ fin => 1 }]);
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
692 };
1624
81fd6615358e Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1623
diff changeset
693 $f->{http_err_rst} = sub {
81fd6615358e Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1623
diff changeset
694 $c->start_chain();
81fd6615358e Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1623
diff changeset
695 $c->new_stream({ headers => [
81fd6615358e Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1623
diff changeset
696 { name => ':status', value => '200', mode => 0 },
81fd6615358e Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1623
diff changeset
697 { name => 'content-type', value => 'application/grpc' },
81fd6615358e Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1623
diff changeset
698 { name => 'grpc-status', value => '12', mode => 2 },
81fd6615358e Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1623
diff changeset
699 { name => 'grpc-message', value => 'unknown service',
81fd6615358e Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1623
diff changeset
700 mode => 2 },
81fd6615358e Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1623
diff changeset
701 ]}, $sid);
81fd6615358e Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1623
diff changeset
702 $c->h2_rst($sid, 0);
81fd6615358e Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1623
diff changeset
703 $c->send_chain();
81fd6615358e Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1623
diff changeset
704
81fd6615358e Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1623
diff changeset
705 return $s->read(all => [{ fin => 1 }]);
81fd6615358e Tests: added test for "grpc error" followed by RST_STREAM NO_ERROR.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1623
diff changeset
706 };
1583
8aede7babd9a Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1564
diff changeset
707 $f->{http_err2} = sub {
8aede7babd9a Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1564
diff changeset
708 my %extra = @_;
8aede7babd9a Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1564
diff changeset
709 $c->new_stream({ body_more => 1, headers => [
8aede7babd9a Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1564
diff changeset
710 { name => ':status', value => '200', mode => 0 },
8aede7babd9a Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1564
diff changeset
711 { name => 'content-type', value => 'application/grpc',
8aede7babd9a Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1564
diff changeset
712 mode => 1, huff => 1 },
8aede7babd9a Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1564
diff changeset
713 { name => 'content-length', value => $extra{cl},
8aede7babd9a Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1564
diff changeset
714 mode => 1, huff => 1 },
8aede7babd9a Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1564
diff changeset
715 ]}, $sid);
8aede7babd9a Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1564
diff changeset
716 $c->h2_body('Hello world',
8aede7babd9a Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1564
diff changeset
717 { body_more => 1, body_split => [5] });
8aede7babd9a Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1564
diff changeset
718 $c->new_stream({ headers => [
8aede7babd9a Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1564
diff changeset
719 { name => 'grpc-status', value => '0',
8aede7babd9a Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1564
diff changeset
720 mode => 2, huff => 1 },
8aede7babd9a Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1564
diff changeset
721 { name => 'grpc-message', value => '',
8aede7babd9a Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1564
diff changeset
722 mode => 2, huff => 1 },
8aede7babd9a Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1564
diff changeset
723 ]}, $sid);
8aede7babd9a Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1564
diff changeset
724
8aede7babd9a Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1564
diff changeset
725 return $s->read(all => [{ type => 'RST_STREAM' }]);
8aede7babd9a Tests: added grpc tests with wrong response size.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1564
diff changeset
726 };
1303
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
727 $f->{continuation} = sub {
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
728 $c->new_stream({ continuation => 1, body_more => 1, headers => [
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
729 { name => ':status', value => '200', mode => 0 },
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
730 ]}, $sid);
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
731 $c->h2_continue($sid, { continuation => 1, headers => [
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
732 { name => 'content-type', value => 'application/grpc',
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
733 mode => 1, huff => 1 },
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
734 ]});
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
735 $c->h2_continue($sid, { headers => [
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
736 # an empty CONTINUATION frame is legitimate
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
737 ]});
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
738 $c->h2_body('Hello world', { body_more => 1 });
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
739 $c->new_stream({ continuation => 1, headers => [
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
740 { name => 'grpc-status', value => '0',
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
741 mode => 2, huff => 1 },
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
742 ]}, $sid);
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
743 $c->h2_continue($sid, { headers => [
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
744 { name => 'grpc-message', value => '',
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
745 mode => 2, huff => 1 },
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
746 ]});
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
747
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
748 return $s->read(all => [{ fin => 1 }]);
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
749 };
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
750 $f->{field_len} = sub {
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
751 my ($len) = @_;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
752 $c->new_stream({ continuation => [map {2**14} (0..$len/2**13)],
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
753 body_more => 1, headers => [
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
754 { name => ':status', value => '200', mode => 0 },
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
755 { name => 'content-type', value => 'application/grpc',
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
756 mode => 1, huff => 1 },
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
757 { name => 'x' x $len, value => 'y' x $len, mode => 6 },
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
758 ]}, $sid);
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
759 $c->h2_body('Hello world', { body_more => 1 });
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
760 $c->new_stream({ headers => [
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
761 { name => 'grpc-status', value => '0',
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
762 mode => 2, huff => 1 },
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
763 { name => 'grpc-message', value => '',
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
764 mode => 2, huff => 1 },
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
765 ]}, $sid);
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
766
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
767 return $s->read(all => [{ fin => 1 }]);
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
768 };
1564
fe938b5daf80 Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1535
diff changeset
769 $f->{discard} = sub {
fe938b5daf80 Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1535
diff changeset
770 my (%extra) = @_;
fe938b5daf80 Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1535
diff changeset
771 $c->new_stream({ body_more => 1, %extra, headers => [
fe938b5daf80 Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1535
diff changeset
772 { name => ':status', value => '200',
fe938b5daf80 Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1535
diff changeset
773 mode => $extra{mode} || 0 },
fe938b5daf80 Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1535
diff changeset
774 { name => 'content-type', value => 'application/grpc',
fe938b5daf80 Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1535
diff changeset
775 mode => $extra{mode} || 1, huff => 1 },
fe938b5daf80 Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1535
diff changeset
776 { name => 'x-connection', value => $n,
fe938b5daf80 Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1535
diff changeset
777 mode => 2, huff => 1 },
fe938b5daf80 Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1535
diff changeset
778 ]}, $sid);
fe938b5daf80 Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1535
diff changeset
779 $c->h2_body('Hello world', { body_more => 1,
fe938b5daf80 Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1535
diff changeset
780 body_padding => $extra{body_padding} });
fe938b5daf80 Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1535
diff changeset
781
fe938b5daf80 Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1535
diff changeset
782 # stick trailers and subsequent frames for reproducibility
fe938b5daf80 Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1535
diff changeset
783
1623
3fe652bc9dae Tests: introduced HTTP/2 frames buffering option in HTTP2 package.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1622
diff changeset
784 $c->start_chain();
3fe652bc9dae Tests: introduced HTTP/2 frames buffering option in HTTP2 package.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1622
diff changeset
785 $c->new_stream({ headers => [
3fe652bc9dae Tests: introduced HTTP/2 frames buffering option in HTTP2 package.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1622
diff changeset
786 { name => 'grpc-status', value => '0', mode => 2 }
3fe652bc9dae Tests: introduced HTTP/2 frames buffering option in HTTP2 package.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1622
diff changeset
787 ]}, $sid);
3fe652bc9dae Tests: introduced HTTP/2 frames buffering option in HTTP2 package.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1622
diff changeset
788 $c->h2_window(42, $sid) if $uri eq '/Discard_WU';
3fe652bc9dae Tests: introduced HTTP/2 frames buffering option in HTTP2 package.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1622
diff changeset
789 $c->h2_rst($sid, 0) if $uri eq '/Discard_NE';
3fe652bc9dae Tests: introduced HTTP/2 frames buffering option in HTTP2 package.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1622
diff changeset
790 $c->h2_rst($sid, 0), $c->h2_rst($sid, 0), $c->h2_rst($sid, 0)
3fe652bc9dae Tests: introduced HTTP/2 frames buffering option in HTTP2 package.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1622
diff changeset
791 if $uri eq '/Discard_NE3';
3fe652bc9dae Tests: introduced HTTP/2 frames buffering option in HTTP2 package.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1622
diff changeset
792 $c->h2_rst($sid, 8) if $uri eq '/Discard_CNL';
3fe652bc9dae Tests: introduced HTTP/2 frames buffering option in HTTP2 package.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1622
diff changeset
793 $c->send_chain();
1564
fe938b5daf80 Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1535
diff changeset
794
fe938b5daf80 Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1535
diff changeset
795 return $s->read(all => [{ fin => 1 }], wait => 2)
fe938b5daf80 Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1535
diff changeset
796 if $uri eq '/Discard_WU' || $uri eq '/Discard_NE';
fe938b5daf80 Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1535
diff changeset
797 return $s->read(all => [{ type => 'RST_STREAM' }]);
fe938b5daf80 Tests: more grpc tests with discarded request body.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1535
diff changeset
798 };
1303
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
799 return $f;
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
800 }
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
801
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
802 sub log2i { Test::Nginx::log_core('|| <<', @_); }
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
803 sub log2o { Test::Nginx::log_core('|| >>', @_); }
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
804 sub log2c { Test::Nginx::log_core('||', @_); }
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
805
42577a840a7d Tests: grpc module tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
806 ###############################################################################