# HG changeset patch # User Sergey Kandaurov # Date 1673546187 -14400 # Node ID 33432a6877f77b13d1e16373c3924f14b13855d2 # Parent 03cebb996b5b9a6bda77526b59661ed3e89a90e2 Tests: reusable HTTP/3 worker connections. diff --git a/h3_reusable.t b/h3_reusable.t new file mode 100644 --- /dev/null +++ b/h3_reusable.t @@ -0,0 +1,94 @@ +#!/usr/bin/perl + +# (C) Sergey Kandaurov +# (C) Nginx, Inc. + +# Tests for HTTP/3, reusable connections. + +############################################################################### + +use warnings; +use strict; + +use Test::More; + +BEGIN { use FindBin; chdir($FindBin::Bin); } + +use lib 'lib'; +use Test::Nginx; +use Test::Nginx::HTTP3; + +############################################################################### + +select STDERR; $| = 1; +select STDOUT; $| = 1; + +eval { require Crypt::Misc; die if $Crypt::Misc::VERSION < 0.067; }; +plan(skip_all => 'CryptX version >= 0.067 required') if $@; + +my $t = Test::Nginx->new()->has(qw/http http_v3/) + ->has_daemon('openssl')->plan(1) + ->write_file_expand('nginx.conf', <<'EOF'); + +%%TEST_GLOBALS%% + +daemon off; + +events { + worker_connections 12; +} + +http { + %%TEST_GLOBALS_HTTP%% + + ssl_certificate_key localhost.key; + ssl_certificate localhost.crt; + + server { + listen 127.0.0.1:%%PORT_8980_UDP%% quic; + server_name localhost; + + location / { } + } +} + +EOF + +$t->write_file('openssl.conf', <testdir(); + +foreach my $name ('localhost') { + system('openssl req -x509 -new ' + . "-config $d/openssl.conf -subj /CN=$name/ " + . "-out $d/$name.crt -keyout $d/$name.key " + . ">>$d/openssl.out 2>&1") == 0 + or die "Can't create certificate for $name: $!\n"; +} + +$t->run(); + +############################################################################### + +my $s1 = Test::Nginx::HTTP3->new(); +$s1->insert_literal(':path', '/foo'); +$s1->read(all => [ { type => 'DECODER_ICI' } ]); + +# expect to steal reusable worker connections + +my $s2 = Test::Nginx::HTTP3->new(); +$s2->start_chain(); +my @sids = map { $s2->new_stream() } 1 .. 5; +$s2->send_chain(); +my $frames = $s2->read(all => [ map { { sid => $_, fin => 1 } } @sids ]); + +my $streams = grep { $_->{type} eq "HEADERS" } @$frames; +is($streams, 5, 'streams'); + +###############################################################################