comparison h3_limit_req.t @ 1888:cc13f7b098db

Tests: avoid premature stream reset in h3_limit_req.t. STREAM and RESET_STREAM frames could be batched, which prevents the stream from being processed and changes the status code. The fix is to wait for the stream acknowledgment. Here we just look at the largest acknowledged, this should be enough for simple cases.
author Sergey Kandaurov <pluknet@nginx.com>
date Tue, 04 Apr 2023 00:33:54 +0400
parents 12d950e1165c
children 8b74936ff2ac
comparison
equal deleted inserted replaced
1887:1023354f3a41 1888:cc13f7b098db
136 136
137 # detect RESET_STREAM while request is delayed 137 # detect RESET_STREAM while request is delayed
138 138
139 $s = Test::Nginx::HTTP3->new(); 139 $s = Test::Nginx::HTTP3->new();
140 $sid = $s->new_stream({ path => '/', body_more => 1 }); 140 $sid = $s->new_stream({ path => '/', body_more => 1 });
141 wait_ack($s);
142
141 $s->reset_stream($sid, 0x010c); 143 $s->reset_stream($sid, 0x010c);
142 $frames = $s->read(all => [{ type => 'DECODER_C' }]); 144 $frames = $s->read(all => [{ type => 'DECODER_C' }]);
143 145
144 ($frame) = grep { $_->{type} eq "DECODER_C" } @$frames; 146 ($frame) = grep { $_->{type} eq "DECODER_C" } @$frames;
145 is($frame->{'val'}, $sid, 'reset stream - cancellation'); 147 is($frame->{'val'}, $sid, 'reset stream - cancellation');
148 150
149 like($t->read_file('test.log'), qr/499/, 'reset stream - log'); 151 like($t->read_file('test.log'), qr/499/, 'reset stream - log');
150 152
151 ############################################################################### 153 ###############################################################################
152 154
155 sub wait_ack {
156 my ($s) = @_;
157 my $last = $s->{pn}[0][3];
158
159 for (1 .. 5) {
160 my $frames = $s->read(all => [ {type => 'ACK' }]);
161 my ($frame) = grep { $_->{type} eq "ACK" } @$frames;
162 last unless $frame->{largest} < $last;
163 }
164 }
165
153 sub read_body_file { 166 sub read_body_file {
154 my ($path) = @_; 167 my ($path) = @_;
155 return unless $path; 168 return unless $path;
156 open FILE, $path or return "$!"; 169 open FILE, $path or return "$!";
157 local $/; 170 local $/;