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