Mercurial > hg > nginx-tests
comparison h2_max_requests.t @ 1667:bdebd63dbab3
Tests: keepalive_time tests.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Thu, 08 Apr 2021 12:59:11 +0300 |
parents | 22e0133d68b4 |
children | 0c1bd4c23c95 |
comparison
equal
deleted
inserted
replaced
1666:9d4c88e5c183 | 1667:bdebd63dbab3 |
---|---|
54 | 54 |
55 keepalive_timeout 0; | 55 keepalive_timeout 0; |
56 | 56 |
57 location / { } | 57 location / { } |
58 } | 58 } |
59 | |
60 server { | |
61 listen 127.0.0.1:8082 http2; | |
62 server_name localhost; | |
63 | |
64 keepalive_time 1s; | |
65 | |
66 location / { } | |
67 } | |
59 } | 68 } |
60 | 69 |
61 EOF | 70 EOF |
62 | 71 |
63 $t->write_file('index.html', 'SEE-THAT' x 50000); | 72 $t->write_file('index.html', 'SEE-THAT' x 50000); |
64 $t->write_file('t.html', 'SEE-THAT'); | 73 $t->write_file('t.html', 'SEE-THAT'); |
65 | 74 |
66 # suppress deprecation warning | 75 # suppress deprecation warning |
67 | 76 |
68 open OLDERR, ">&", \*STDERR; close STDERR; | 77 open OLDERR, ">&", \*STDERR; close STDERR; |
69 $t->run()->plan(12); | 78 $t->try_run('no keepalive_time')->plan(17); |
70 open STDERR, ">&", \*OLDERR; | 79 open STDERR, ">&", \*OLDERR; |
71 | 80 |
72 ############################################################################### | 81 ############################################################################### |
73 | 82 |
74 my $s = Test::Nginx::HTTP2->new(); | 83 my $s = Test::Nginx::HTTP2->new(); |
138 | 147 |
139 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; | 148 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; |
140 ok($frame, 'keepalive_timeout 0 - GOAWAY'); | 149 ok($frame, 'keepalive_timeout 0 - GOAWAY'); |
141 | 150 |
142 } | 151 } |
152 | |
153 # keepalive_time | |
154 | |
155 $s = Test::Nginx::HTTP2->new(port(8082)); | |
156 $sid = $s->new_stream({ path => '/t.html' }); | |
157 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); | |
158 | |
159 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
160 is($frame->{headers}->{':status'}, 200, 'keepalive time request'); | |
161 | |
162 $frames = $s->read(all => [{ type => 'GOAWAY' }], wait => 0.5); | |
163 | |
164 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; | |
165 is($frame, undef, 'keepalive time - no GOAWAY yet'); | |
166 | |
167 select undef, undef, undef, 1.1; | |
168 | |
169 $sid = $s->new_stream({ path => '/t.html' }); | |
170 $frames = $s->read(all => [{ sid => $sid, fin => 1 }, { type => 'GOAWAY' }]); | |
171 | |
172 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | |
173 is($frame->{headers}->{':status'}, 200, 'keepalive time request 2'); | |
174 | |
175 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; | |
176 ok($frame, 'keepalive time limit - GOAWAY'); | |
177 is($frame->{last_sid}, $sid, 'keepalive time limit - GOAWAY last stream'); | |
143 | 178 |
144 # graceful shutdown in idle state | 179 # graceful shutdown in idle state |
145 | 180 |
146 $s = Test::Nginx::HTTP2->new(); | 181 $s = Test::Nginx::HTTP2->new(); |
147 $s->{socket}->setsockopt(SOL_SOCKET, SO_RCVBUF, 64*1024) or die $!; | 182 $s->{socket}->setsockopt(SOL_SOCKET, SO_RCVBUF, 64*1024) or die $!; |