Mercurial > hg > nginx-tests
comparison h2_max_requests.t @ 1693:5ac6efbe5552
Tests: removed TODO and try_run() checks for legacy versions.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Tue, 01 Jun 2021 16:40:18 +0300 |
parents | 0c1bd4c23c95 |
children |
comparison
equal
deleted
inserted
replaced
1692:f6795e2e6a4b | 1693:5ac6efbe5552 |
---|---|
1 #!/usr/bin/perl | 1 #!/usr/bin/perl |
2 | 2 |
3 # (C) Sergey Kandaurov | 3 # (C) Sergey Kandaurov |
4 # (C) Nginx, Inc. | 4 # (C) Nginx, Inc. |
5 | 5 |
6 # Tests for HTTP/2 protocol, http2_max_requests directive. | 6 # Tests for HTTP/2 protocol, keepalive directives. |
7 | 7 |
8 ############################################################################### | 8 ############################################################################### |
9 | 9 |
10 use warnings; | 10 use warnings; |
11 use strict; | 11 use strict; |
40 | 40 |
41 server { | 41 server { |
42 listen 127.0.0.1:8080 http2 sndbuf=1m; | 42 listen 127.0.0.1:8080 http2 sndbuf=1m; |
43 server_name localhost; | 43 server_name localhost; |
44 | 44 |
45 http2_max_requests 2; | |
46 keepalive_requests 2; | 45 keepalive_requests 2; |
47 | 46 |
48 location / { } | 47 location / { } |
49 } | 48 } |
50 | 49 |
72 EOF | 71 EOF |
73 | 72 |
74 $t->write_file('index.html', 'SEE-THAT' x 50000); | 73 $t->write_file('index.html', 'SEE-THAT' x 50000); |
75 $t->write_file('t.html', 'SEE-THAT'); | 74 $t->write_file('t.html', 'SEE-THAT'); |
76 | 75 |
77 # suppress deprecation warning | 76 $t->run()->plan(19); |
78 | |
79 open OLDERR, ">&", \*STDERR; close STDERR; | |
80 $t->try_run('no keepalive_time')->plan(19); | |
81 open STDERR, ">&", \*OLDERR; | |
82 | 77 |
83 ############################################################################### | 78 ############################################################################### |
84 | 79 |
85 my $s = Test::Nginx::HTTP2->new(); | 80 my $s = Test::Nginx::HTTP2->new(); |
86 | 81 |
114 $frames = $s->read(all => [{ sid => $sid, fin => 1 }, { type => 'GOAWAY' }]); | 109 $frames = $s->read(all => [{ sid => $sid, fin => 1 }, { type => 'GOAWAY' }]); |
115 | 110 |
116 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | 111 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
117 is($frame->{headers}->{':status'}, 200, 'max requests limited'); | 112 is($frame->{headers}->{':status'}, 200, 'max requests limited'); |
118 | 113 |
119 TODO: { | |
120 local $TODO = 'not yet' if ($^O eq 'linux' or $^O eq 'freebsd') | |
121 and !$t->has_version('1.19.1'); | |
122 | |
123 my @data = grep { $_->{type} eq "DATA" } @$frames; | 114 my @data = grep { $_->{type} eq "DATA" } @$frames; |
124 my $sum = eval join '+', map { $_->{length} } @data; | 115 my $sum = eval join '+', map { $_->{length} } @data; |
125 is($sum, 400000, 'max requests limited - all data received'); | 116 is($sum, 400000, 'max requests limited - all data received'); |
126 | |
127 } | |
128 | 117 |
129 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; | 118 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; |
130 ok($frame, 'max requests limited - GOAWAY'); | 119 ok($frame, 'max requests limited - GOAWAY'); |
131 is($frame->{last_sid}, $sid, 'max requests limited - GOAWAY last stream'); | 120 is($frame->{last_sid}, $sid, 'max requests limited - GOAWAY last stream'); |
132 | 121 |
133 # keepalive_timeout 0 | 122 # keepalive_timeout 0 |
134 | 123 |
135 SKIP: { | |
136 skip 'not yet', 2 unless $t->has_version('1.19.7'); | |
137 | |
138 $s = Test::Nginx::HTTP2->new(port(8081)); | 124 $s = Test::Nginx::HTTP2->new(port(8081)); |
139 $sid = $s->new_stream({ path => '/t.html' }); | 125 $sid = $s->new_stream({ path => '/t.html' }); |
140 $frames = $s->read(all => [{ sid => $sid, fin => 1 }, { type => 'GOAWAY' }]); | 126 $frames = $s->read(all => [{ sid => $sid, fin => 1 }, { type => 'GOAWAY' }]); |
141 | 127 |
142 TODO: { | |
143 local $TODO = 'not yet' unless $t->has_version('1.19.8'); | |
144 | |
145 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | 128 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
146 is($frame->{headers}->{':status'}, 200, 'keepalive_timeout 0'); | 129 is($frame->{headers}->{':status'}, 200, 'keepalive_timeout 0'); |
147 | 130 |
148 } | |
149 | |
150 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; | 131 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; |
151 ok($frame, 'keepalive_timeout 0 - GOAWAY'); | 132 ok($frame, 'keepalive_timeout 0 - GOAWAY'); |
152 | |
153 } | |
154 | 133 |
155 # keepalive_time | 134 # keepalive_time |
156 | 135 |
157 $s = Test::Nginx::HTTP2->new(port(8082)); | 136 $s = Test::Nginx::HTTP2->new(port(8082)); |
158 $sid = $s->new_stream({ path => '/t.html' }); | 137 $sid = $s->new_stream({ path => '/t.html' }); |
202 $frames = $s->read(all => [{ sid => $sid, fin => 1 }, { type => 'GOAWAY' }]); | 181 $frames = $s->read(all => [{ sid => $sid, fin => 1 }, { type => 'GOAWAY' }]); |
203 | 182 |
204 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | 183 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
205 is($frame->{headers}->{':status'}, 200, 'graceful shutdown in idle'); | 184 is($frame->{headers}->{':status'}, 200, 'graceful shutdown in idle'); |
206 | 185 |
207 TODO: { | 186 @data = grep { $_->{type} eq "DATA" } @$frames; |
208 local $TODO = 'not yet' if ($^O eq 'linux' or $^O eq 'freebsd') | 187 $sum = eval join '+', map { $_->{length} } @data; |
209 and !$t->has_version('1.19.1'); | |
210 | |
211 my @data = grep { $_->{type} eq "DATA" } @$frames; | |
212 my $sum = eval join '+', map { $_->{length} } @data; | |
213 is($sum, 400000, 'graceful shutdown in idle - all data received'); | 188 is($sum, 400000, 'graceful shutdown in idle - all data received'); |
214 | 189 |
215 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; | 190 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; |
216 ok($frame, 'graceful shutdown in idle - GOAWAY'); | 191 ok($frame, 'graceful shutdown in idle - GOAWAY'); |
217 is($frame->{last_sid}, $sid, 'graceful shutdown in idle - GOAWAY last stream'); | 192 is($frame->{last_sid}, $sid, 'graceful shutdown in idle - GOAWAY last stream'); |
218 | 193 |
219 } | |
220 | |
221 ############################################################################### | 194 ############################################################################### |