Mercurial > hg > nginx-tests
comparison h2_request_body_preread.t @ 974:882267679006
Tests: simplified parallel modifications in tests.
Mail tests were simplified in c227348453db.
author | Andrey Zelenkov <zelenkov@nginx.com> |
---|---|
date | Tue, 12 Jul 2016 17:39:03 +0300 |
parents | e214983c605b |
children | 196d33c2bb45 |
comparison
equal
deleted
inserted
replaced
973:7d7aef8b9f3a | 974:882267679006 |
---|---|
38 %%TEST_GLOBALS_HTTP%% | 38 %%TEST_GLOBALS_HTTP%% |
39 | 39 |
40 limit_req_zone $binary_remote_addr zone=req:1m rate=30r/m; | 40 limit_req_zone $binary_remote_addr zone=req:1m rate=30r/m; |
41 | 41 |
42 server { | 42 server { |
43 listen 127.0.0.1:%%PORT_0%% http2; | 43 listen 127.0.0.1:8080 http2; |
44 listen 127.0.0.1:%%PORT_1%%; | 44 listen 127.0.0.1:8081; |
45 server_name localhost; | 45 server_name localhost; |
46 | 46 |
47 http2_body_preread_size 10; | 47 http2_body_preread_size 10; |
48 | 48 |
49 location /t { } | 49 location /t { } |
50 location / { | 50 location / { |
51 add_header X-Body $request_body; | 51 add_header X-Body $request_body; |
52 proxy_pass http://127.0.0.1:%%PORT_1%%/t; | 52 proxy_pass http://127.0.0.1:8081/t; |
53 | 53 |
54 location /req { | 54 location /req { |
55 limit_req zone=req burst=2; | 55 limit_req zone=req burst=2; |
56 proxy_pass http://127.0.0.1:%%PORT_1%%/t; | 56 proxy_pass http://127.0.0.1:8081/t; |
57 } | 57 } |
58 } | 58 } |
59 } | 59 } |
60 | 60 |
61 server { | 61 server { |
62 listen 127.0.0.1:%%PORT_2%% http2; | 62 listen 127.0.0.1:8082 http2; |
63 server_name localhost; | 63 server_name localhost; |
64 | 64 |
65 http2_body_preread_size 0; | 65 http2_body_preread_size 0; |
66 | 66 |
67 location / { | 67 location / { |
68 add_header X-Body $request_body; | 68 add_header X-Body $request_body; |
69 proxy_pass http://127.0.0.1:%%PORT_1%%/t; | 69 proxy_pass http://127.0.0.1:8081/t; |
70 | 70 |
71 location /req { | 71 location /req { |
72 limit_req zone=req burst=2; | 72 limit_req zone=req burst=2; |
73 proxy_pass http://127.0.0.1:%%PORT_1%%/t; | 73 proxy_pass http://127.0.0.1:8081/t; |
74 } | 74 } |
75 } | 75 } |
76 } | 76 } |
77 | 77 |
78 server { | 78 server { |
79 listen 127.0.0.1:%%PORT_3%% http2; | 79 listen 127.0.0.1:8083 http2; |
80 server_name localhost; | 80 server_name localhost; |
81 | 81 |
82 location / { | 82 location / { |
83 add_header X-Body $request_body; | 83 add_header X-Body $request_body; |
84 proxy_pass http://127.0.0.1:%%PORT_1%%/t; | 84 proxy_pass http://127.0.0.1:8081/t; |
85 } | 85 } |
86 } | 86 } |
87 } | 87 } |
88 | 88 |
89 EOF | 89 EOF |
142 # zero preread size | 142 # zero preread size |
143 | 143 |
144 TODO: { | 144 TODO: { |
145 local $TODO = 'not yet'; | 145 local $TODO = 'not yet'; |
146 | 146 |
147 $s = Test::Nginx::HTTP2->new(port(2)); | 147 $s = Test::Nginx::HTTP2->new(port(8082)); |
148 $sid = $s->new_stream({ body => 'TEST' }); | 148 $sid = $s->new_stream({ body => 'TEST' }); |
149 $frames = $s->read(all => [{ type => 'RST_STREAM' }], wait => 0.5); | 149 $frames = $s->read(all => [{ type => 'RST_STREAM' }], wait => 0.5); |
150 | 150 |
151 ($frame) = grep { $_->{type} eq "RST_STREAM" } @$frames; | 151 ($frame) = grep { $_->{type} eq "RST_STREAM" } @$frames; |
152 is($frame->{code}, 3, 'zero preread - FLOW_CONTROL_ERROR'); | 152 is($frame->{code}, 3, 'zero preread - FLOW_CONTROL_ERROR'); |
153 | 153 |
154 } | 154 } |
155 | 155 |
156 # zero preread size - limited | 156 # zero preread size - limited |
157 | 157 |
158 $s = Test::Nginx::HTTP2->new(port(2)); | 158 $s = Test::Nginx::HTTP2->new(port(8082)); |
159 $sid = $s->new_stream({ path => '/req', body => 'TEST' }); | 159 $sid = $s->new_stream({ path => '/req', body => 'TEST' }); |
160 $frames = $s->read(all => [{ type => 'RST_STREAM' }]); | 160 $frames = $s->read(all => [{ type => 'RST_STREAM' }]); |
161 | 161 |
162 ($frame) = grep { $_->{type} eq "RST_STREAM" } @$frames; | 162 ($frame) = grep { $_->{type} eq "RST_STREAM" } @$frames; |
163 is($frame->{code}, 3, 'zero preread limited - FLOW_CONTROL_ERROR'); | 163 is($frame->{code}, 3, 'zero preread limited - FLOW_CONTROL_ERROR'); |
164 | 164 |
165 | 165 |
166 # REFUSED_STREAM on request body prior SETTINGS acknowledgement | 166 # REFUSED_STREAM on request body prior SETTINGS acknowledgement |
167 | 167 |
168 $s = Test::Nginx::HTTP2->new(port(0), pure => 1); | 168 $s = Test::Nginx::HTTP2->new(port(8080), pure => 1); |
169 $sid = $s->new_stream({ body => 'TEST' }); | 169 $sid = $s->new_stream({ body => 'TEST' }); |
170 $frames = $s->read(all => [{ type => 'RST_STREAM' }]); | 170 $frames = $s->read(all => [{ type => 'RST_STREAM' }]); |
171 | 171 |
172 ($frame) = grep { $_->{type} eq "RST_STREAM" } @$frames; | 172 ($frame) = grep { $_->{type} eq "RST_STREAM" } @$frames; |
173 is($frame->{code}, 7, 'no SETTINGS ack - REFUSED_STREAM'); | 173 is($frame->{code}, 7, 'no SETTINGS ack - REFUSED_STREAM'); |
174 | 174 |
175 # default preread size - no REFUSED_STREAM expected | 175 # default preread size - no REFUSED_STREAM expected |
176 | 176 |
177 $s = Test::Nginx::HTTP2->new(port(3), pure => 1); | 177 $s = Test::Nginx::HTTP2->new(port(8083), pure => 1); |
178 $sid = $s->new_stream({ body => 'TEST' }); | 178 $sid = $s->new_stream({ body => 'TEST' }); |
179 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); | 179 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
180 | 180 |
181 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | 181 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
182 is($frame->{headers}->{'x-body'}, 'TEST', 'no SETTINGS ack - default preread'); | 182 is($frame->{headers}->{'x-body'}, 'TEST', 'no SETTINGS ack - default preread'); |