Mercurial > hg > nginx-tests
comparison h3_reusable.t @ 1881:33432a6877f7
Tests: reusable HTTP/3 worker connections.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Thu, 12 Jan 2023 21:56:27 +0400 |
parents | |
children | 8b74936ff2ac |
comparison
equal
deleted
inserted
replaced
1880:03cebb996b5b | 1881:33432a6877f7 |
---|---|
1 #!/usr/bin/perl | |
2 | |
3 # (C) Sergey Kandaurov | |
4 # (C) Nginx, Inc. | |
5 | |
6 # Tests for HTTP/3, reusable connections. | |
7 | |
8 ############################################################################### | |
9 | |
10 use warnings; | |
11 use strict; | |
12 | |
13 use Test::More; | |
14 | |
15 BEGIN { use FindBin; chdir($FindBin::Bin); } | |
16 | |
17 use lib 'lib'; | |
18 use Test::Nginx; | |
19 use Test::Nginx::HTTP3; | |
20 | |
21 ############################################################################### | |
22 | |
23 select STDERR; $| = 1; | |
24 select STDOUT; $| = 1; | |
25 | |
26 eval { require Crypt::Misc; die if $Crypt::Misc::VERSION < 0.067; }; | |
27 plan(skip_all => 'CryptX version >= 0.067 required') if $@; | |
28 | |
29 my $t = Test::Nginx->new()->has(qw/http http_v3/) | |
30 ->has_daemon('openssl')->plan(1) | |
31 ->write_file_expand('nginx.conf', <<'EOF'); | |
32 | |
33 %%TEST_GLOBALS%% | |
34 | |
35 daemon off; | |
36 | |
37 events { | |
38 worker_connections 12; | |
39 } | |
40 | |
41 http { | |
42 %%TEST_GLOBALS_HTTP%% | |
43 | |
44 ssl_certificate_key localhost.key; | |
45 ssl_certificate localhost.crt; | |
46 | |
47 server { | |
48 listen 127.0.0.1:%%PORT_8980_UDP%% quic; | |
49 server_name localhost; | |
50 | |
51 location / { } | |
52 } | |
53 } | |
54 | |
55 EOF | |
56 | |
57 $t->write_file('openssl.conf', <<EOF); | |
58 [ req ] | |
59 default_bits = 2048 | |
60 encrypt_key = no | |
61 distinguished_name = req_distinguished_name | |
62 [ req_distinguished_name ] | |
63 EOF | |
64 | |
65 my $d = $t->testdir(); | |
66 | |
67 foreach my $name ('localhost') { | |
68 system('openssl req -x509 -new ' | |
69 . "-config $d/openssl.conf -subj /CN=$name/ " | |
70 . "-out $d/$name.crt -keyout $d/$name.key " | |
71 . ">>$d/openssl.out 2>&1") == 0 | |
72 or die "Can't create certificate for $name: $!\n"; | |
73 } | |
74 | |
75 $t->run(); | |
76 | |
77 ############################################################################### | |
78 | |
79 my $s1 = Test::Nginx::HTTP3->new(); | |
80 $s1->insert_literal(':path', '/foo'); | |
81 $s1->read(all => [ { type => 'DECODER_ICI' } ]); | |
82 | |
83 # expect to steal reusable worker connections | |
84 | |
85 my $s2 = Test::Nginx::HTTP3->new(); | |
86 $s2->start_chain(); | |
87 my @sids = map { $s2->new_stream() } 1 .. 5; | |
88 $s2->send_chain(); | |
89 my $frames = $s2->read(all => [ map { { sid => $_, fin => 1 } } @sids ]); | |
90 | |
91 my $streams = grep { $_->{type} eq "HEADERS" } @$frames; | |
92 is($streams, 5, 'streams'); | |
93 | |
94 ############################################################################### |