comparison h2_max_requests.t @ 1668:0c1bd4c23c95

Tests: $connection_requests and $connection_time tests.
author Sergey Kandaurov <pluknet@nginx.com>
date Thu, 08 Apr 2021 14:51:04 +0300
parents bdebd63dbab3
children 5ac6efbe5552
comparison
equal deleted inserted replaced
1667:bdebd63dbab3 1668:0c1bd4c23c95
61 listen 127.0.0.1:8082 http2; 61 listen 127.0.0.1:8082 http2;
62 server_name localhost; 62 server_name localhost;
63 63
64 keepalive_time 1s; 64 keepalive_time 1s;
65 65
66 add_header X-Conn $connection_requests:$connection_time;
67
66 location / { } 68 location / { }
67 } 69 }
68 } 70 }
69 71
70 EOF 72 EOF
73 $t->write_file('t.html', 'SEE-THAT'); 75 $t->write_file('t.html', 'SEE-THAT');
74 76
75 # suppress deprecation warning 77 # suppress deprecation warning
76 78
77 open OLDERR, ">&", \*STDERR; close STDERR; 79 open OLDERR, ">&", \*STDERR; close STDERR;
78 $t->try_run('no keepalive_time')->plan(17); 80 $t->try_run('no keepalive_time')->plan(19);
79 open STDERR, ">&", \*OLDERR; 81 open STDERR, ">&", \*OLDERR;
80 82
81 ############################################################################### 83 ###############################################################################
82 84
83 my $s = Test::Nginx::HTTP2->new(); 85 my $s = Test::Nginx::HTTP2->new();
156 $sid = $s->new_stream({ path => '/t.html' }); 158 $sid = $s->new_stream({ path => '/t.html' });
157 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); 159 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]);
158 160
159 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; 161 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
160 is($frame->{headers}->{':status'}, 200, 'keepalive time request'); 162 is($frame->{headers}->{':status'}, 200, 'keepalive time request');
163 like($frame->{headers}->{'x-conn'}, qr/^1:0/, 'keepalive time variables');
161 164
162 $frames = $s->read(all => [{ type => 'GOAWAY' }], wait => 0.5); 165 $frames = $s->read(all => [{ type => 'GOAWAY' }], wait => 0.5);
163 166
164 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; 167 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames;
165 is($frame, undef, 'keepalive time - no GOAWAY yet'); 168 is($frame, undef, 'keepalive time - no GOAWAY yet');
169 $sid = $s->new_stream({ path => '/t.html' }); 172 $sid = $s->new_stream({ path => '/t.html' });
170 $frames = $s->read(all => [{ sid => $sid, fin => 1 }, { type => 'GOAWAY' }]); 173 $frames = $s->read(all => [{ sid => $sid, fin => 1 }, { type => 'GOAWAY' }]);
171 174
172 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; 175 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
173 is($frame->{headers}->{':status'}, 200, 'keepalive time request 2'); 176 is($frame->{headers}->{':status'}, 200, 'keepalive time request 2');
177 like($frame->{headers}->{'x-conn'}, qr/^2:[^0]/, 'keepalive time variables 2');
174 178
175 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; 179 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames;
176 ok($frame, 'keepalive time limit - GOAWAY'); 180 ok($frame, 'keepalive time limit - GOAWAY');
177 is($frame->{last_sid}, $sid, 'keepalive time limit - GOAWAY last stream'); 181 is($frame->{last_sid}, $sid, 'keepalive time limit - GOAWAY last stream');
178 182