changeset 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 1023354f3a41
children 8303f3633f65
files h3_limit_req.t
diffstat 1 files changed, 13 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/h3_limit_req.t
+++ b/h3_limit_req.t
@@ -138,6 +138,8 @@ is($frame->{headers}->{':status'}, 200, 
 
 $s = Test::Nginx::HTTP3->new();
 $sid = $s->new_stream({ path => '/', body_more => 1 });
+wait_ack($s);
+
 $s->reset_stream($sid, 0x010c);
 $frames = $s->read(all => [{ type => 'DECODER_C' }]);
 
@@ -150,6 +152,17 @@ like($t->read_file('test.log'), qr/499/,
 
 ###############################################################################
 
+sub wait_ack {
+	my ($s) = @_;
+	my $last = $s->{pn}[0][3];
+
+	for (1 .. 5) {
+		my $frames = $s->read(all => [ {type => 'ACK' }]);
+		my ($frame) = grep { $_->{type} eq "ACK" } @$frames;
+		last unless $frame->{largest} < $last;
+	}
+}
+
 sub read_body_file {
 	my ($path) = @_;
 	return unless $path;