annotate h3_proxy.t @ 1951:1867428f1673

Tests: fixed h3_limit_req.t spurious failures. In the "reset stream - cancellation" test, HTTP/3 stream is closed without sending the request body when the request is waiting in the limit_req module, and this results in error 444. However, when the request is received with some minor delay due to system load, it is not delayed by limit_req, and the stream is closed during reading the request body, which results in error 400 instead, breaking the test. Fix is to introduce yet another request before the "reset stream" test, so the stream in question is always delayed by limit_req.
author Maxim Dounin <mdounin@mdounin.ru>
date Thu, 14 Mar 2024 02:25:49 +0300
parents 8b74936ff2ac
children
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
1896
8b74936ff2ac Tests: added has_feature() test for CryptX.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1880
diff changeset
26 my $t = Test::Nginx->new()->has(qw/http http_v3 proxy cryptx/)
1880
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
27 ->has_daemon('openssl')->plan(3)
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
28 ->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
29
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
30 %%TEST_GLOBALS%%
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
31
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
32 daemon off;
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
33
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
34 events {
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
35 }
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 http {
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
38 %%TEST_GLOBALS_HTTP%%
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 ssl_certificate_key localhost.key;
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
41 ssl_certificate localhost.crt;
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 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
44
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
45 server {
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
46 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
47 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
48 server_name localhost;
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
49
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
50 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
51
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
52 location / {
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
53 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
54 }
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
55
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
56 location /stub {
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
57 limit_rate 100;
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 }
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
60 }
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 EOF
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 $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
65 [ req ]
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
66 default_bits = 2048
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
67 encrypt_key = no
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
68 distinguished_name = req_distinguished_name
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
69 [ req_distinguished_name ]
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
70 EOF
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
71
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
72 my $d = $t->testdir();
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
73
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
74 foreach my $name ('localhost') {
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
75 system('openssl req -x509 -new '
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
76 . "-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
77 . "-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
78 . ">>$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
79 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
80 }
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
81
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
82 $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
83 $t->run();
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 ###############################################################################
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
86
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
87 my ($s, $sid, $frames, $frame);
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 # upstream check broken connection
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
90 # 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
91
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
92 $s = Test::Nginx::HTTP3->new();
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
93 $sid = $s->new_stream();
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 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
96 $s->stop_sending($sid, 0x010c);
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
97 $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
98
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
99 ($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
100 ok($frame, 'RESET_STREAM received');
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 $t->stop();
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
103
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
104 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
105 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
106 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
107
03cebb996b5b Tests: added HTTP/3 test with upstream check broken connection.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff changeset
108 ###############################################################################