annotate h3_proxy.t @ 1880:03cebb996b5b

Tests: added HTTP/3 test with upstream check broken connection.
author Sergey Kandaurov <pluknet@nginx.com>
date Thu, 12 Jan 2023 20:53:51 +0400
parents
children 8b74936ff2ac
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1880
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
1 #!/usr/bin/perl
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
2
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
3 # (C) Sergey Kandaurov
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
4 # (C) Nginx, Inc.
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
5
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
6 # Tests for HTTP/3 with proxy module.
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
7
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
8 ###############################################################################
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
9
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
10 use warnings;
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
11 use strict;
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
12
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
13 use Test::More;
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
14
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
15 BEGIN { use FindBin; chdir($FindBin::Bin); }
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
16
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
17 use lib 'lib';
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
18 use Test::Nginx;
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
19 use Test::Nginx::HTTP3;
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
20
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
21 ###############################################################################
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
22
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
23 select STDERR; $| = 1;
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
24 select STDOUT; $| = 1;
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
25
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
26 eval { require Crypt::Misc; die if $Crypt::Misc::VERSION < 0.067; };
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
27 plan(skip_all => 'CryptX version >= 0.067 required') if $@;
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
28
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
29 my $t = Test::Nginx->new()->has(qw/http http_v3 proxy/)
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
30 ->has_daemon('openssl')->plan(3)
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
31 ->write_file_expand('nginx.conf', <<'EOF');
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
32
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
33 %%TEST_GLOBALS%%
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
34
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
35 daemon off;
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
36
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
37 events {
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
38 }
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
39
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
40 http {
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
41 %%TEST_GLOBALS_HTTP%%
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
42
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
43 ssl_certificate_key localhost.key;
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
44 ssl_certificate localhost.crt;
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
45
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
46 log_format test $uri:$status:$request_completion;
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
47
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
48 server {
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
49 listen 127.0.0.1:%%PORT_8980_UDP%% quic;
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
50 listen 127.0.0.1:8081;
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
51 server_name localhost;
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
52
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
53 access_log %%TESTDIR%%/test.log test;
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
54
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
55 location / {
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
56 proxy_pass http://127.0.0.1:8081/stub;
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
57 }
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
58
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
59 location /stub {
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
60 limit_rate 100;
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
61 }
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
62 }
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
63 }
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
64
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
65 EOF
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
66
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
67 $t->write_file('openssl.conf', <<EOF);
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
68 [ req ]
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
69 default_bits = 2048
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
70 encrypt_key = no
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
71 distinguished_name = req_distinguished_name
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
72 [ req_distinguished_name ]
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
73 EOF
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
74
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
75 my $d = $t->testdir();
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
76
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
77 foreach my $name ('localhost') {
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
78 system('openssl req -x509 -new '
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
79 . "-config $d/openssl.conf -subj /CN=$name/ "
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
80 . "-out $d/$name.crt -keyout $d/$name.key "
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
81 . ">>$d/openssl.out 2>&1") == 0
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
82 or die "Can't create certificate for $name: $!\n";
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
83 }
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
84
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
85 $t->write_file('stub', 'SEE-THIS' x 10);
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
86 $t->run();
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
87
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
88 ###############################################################################
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
89
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
90 my ($s, $sid, $frames, $frame);
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
91
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
92 # upstream check broken connection
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
93 # ensure that STOP_SENDING results in write error, checked in a posted event
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
94
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
95 $s = Test::Nginx::HTTP3->new();
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
96 $sid = $s->new_stream();
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
97
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
98 select undef, undef, undef, 0.1;
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
99 $s->stop_sending($sid, 0x010c);
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
100 $frames = $s->read(all => [{ type => 'RESET_STREAM' }]);
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
101
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
102 ($frame) = grep { $_->{type} eq "RESET_STREAM" } @$frames;
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
103 ok($frame, 'RESET_STREAM received');
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
104
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
105 $t->stop();
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
106
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
107 my $log = $t->read_file('test.log');
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
108 like($log, qr|^/:499|, 'client reset connection');
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
109 unlike($log, qr|^/stub:200:OK|, 'backend request incomplete');
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
110
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
111 ###############################################################################