Mercurial > hg > nginx-tests
annotate h3_keepalive.t @ 1912:f61d1b4ac638
Tests: unbreak quic_ciphers.t with AEAD_AES_128_CCM enabled.
Although CCM ciphers are disabled in a stock OpenSSL as rarely used,
"to reduce ClientHello bloat", AEAD_AES_128_CCM is apparently turned
back in certain distributions such as RHEL. Previously, this caused
testing connections to fail as the CCM cipher being negotiated isn't
supported yet in nginx. Now the test is skipped instead on failure.
While here, fixed nearby style.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Wed, 14 Jun 2023 16:57:01 +0400 |
parents | 8b74936ff2ac |
children | 6e4a480ab370 |
rev | line source |
---|---|
1878
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
2 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
3 # (C) Sergey Kandaurov |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
4 # (C) Nginx, Inc. |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
5 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
6 # Tests for HTTP/3 protocol, keepalive directives. |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
7 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
8 ############################################################################### |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
9 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
10 use warnings; |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
11 use strict; |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
12 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
13 use Test::More; |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
14 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
15 BEGIN { use FindBin; chdir($FindBin::Bin); } |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
16 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
17 use lib 'lib'; |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
18 use Test::Nginx; |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
19 use Test::Nginx::HTTP3; |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
20 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
21 ############################################################################### |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
22 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
23 select STDERR; $| = 1; |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
24 select STDOUT; $| = 1; |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
25 |
1896
8b74936ff2ac
Tests: added has_feature() test for CryptX.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1878
diff
changeset
|
26 my $t = Test::Nginx->new()->has(qw/http http_v3 cryptx/) |
1878
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
27 ->has_daemon('openssl')->plan(15) |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
28 ->write_file_expand('nginx.conf', <<'EOF'); |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
29 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
30 %%TEST_GLOBALS%% |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
31 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
32 daemon off; |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
33 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
34 events { |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
35 } |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
36 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
37 http { |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
38 %%TEST_GLOBALS_HTTP%% |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
39 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
40 ssl_certificate_key localhost.key; |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
41 ssl_certificate localhost.crt; |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
42 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
43 server { |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
44 listen 127.0.0.1:%%PORT_8980_UDP%% quic; |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
45 server_name localhost; |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
46 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
47 keepalive_requests 2; |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
48 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
49 location / { } |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
50 } |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
51 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
52 server { |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
53 listen 127.0.0.1:%%PORT_8981_UDP%% quic; |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
54 server_name localhost; |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
55 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
56 keepalive_timeout 0; |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
57 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
58 location / { } |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
59 } |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
60 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
61 server { |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
62 listen 127.0.0.1:%%PORT_8982_UDP%% quic; |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
63 server_name localhost; |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
64 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
65 keepalive_time 1s; |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
66 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
67 add_header X-Conn $connection_requests:$connection_time; |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
68 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
69 location / { } |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
70 } |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
71 } |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
72 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
73 EOF |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
74 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
75 $t->write_file('openssl.conf', <<EOF); |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
76 [ req ] |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
77 default_bits = 2048 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
78 encrypt_key = no |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
79 distinguished_name = req_distinguished_name |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
80 [ req_distinguished_name ] |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
81 EOF |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
82 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
83 my $d = $t->testdir(); |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
84 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
85 foreach my $name ('localhost') { |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
86 system('openssl req -x509 -new ' |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
87 . "-config $d/openssl.conf -subj /CN=$name/ " |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
88 . "-out $d/$name.crt -keyout $d/$name.key " |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
89 . ">>$d/openssl.out 2>&1") == 0 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
90 or die "Can't create certificate for $name: $!\n"; |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
91 } |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
92 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
93 $t->write_file('index.html', 'SEE-THIS'); |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
94 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
95 $t->run(); |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
96 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
97 ############################################################################### |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
98 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
99 my ($s, $sid, $frames, $frame); |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
100 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
101 # max requests limited |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
102 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
103 $s = Test::Nginx::HTTP3->new(); |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
104 $frames = $s->read(all => [{ sid => $s->new_stream(), fin => 1 }]); |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
105 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
106 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
107 is($frame->{headers}->{':status'}, 200, 'keepalive requests 1'); |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
108 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
109 $frames = $s->read(all => [ |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
110 { sid => $s->new_stream(), fin => 1 }, |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
111 { type => 'GOAWAY' } |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
112 ]); |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
113 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
114 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
115 is($frame->{headers}->{':status'}, 200, 'keepalive requests 2'); |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
116 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
117 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
118 is($frame->{sid}, 3, 'keepalive requests - GOAWAY stream type'); |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
119 is($frame->{last_sid}, 8, 'keepalive requests - GOAWAY last stream'); |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
120 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
121 # keepalive_timeout 0 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
122 # currently, keepalive timer is set before reading 1st request |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
123 # and there is no special handling for zero value timeout |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
124 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
125 $s = Test::Nginx::HTTP3->new(8981); |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
126 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
127 TODO: { |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
128 todo_skip 'keepalive_timeout 0', 2 unless $s; |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
129 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
130 $sid = $s->new_stream(); |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
131 $frames = $s->read(all => [{ sid => $sid, fin => 1 }, { type => 'GOAWAY' }]); |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
132 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
133 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
134 is($frame->{headers}->{':status'}, 200, 'keepalive_timeout 0'); |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
135 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
136 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
137 ok($frame, 'keepalive_timeout 0 - GOAWAY'); |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
138 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
139 } |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
140 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
141 # keepalive_time |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
142 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
143 $s = Test::Nginx::HTTP3->new(8982); |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
144 $sid = $s->new_stream(); |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
145 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
146 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
147 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
148 is($frame->{headers}->{':status'}, 200, 'keepalive time request'); |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
149 like($frame->{headers}->{'x-conn'}, qr/^1:0/, 'keepalive time variables'); |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
150 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
151 $frames = $s->read(all => [{ type => 'GOAWAY' }], wait => 0.5); |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
152 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
153 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
154 is($frame, undef, 'keepalive time - no GOAWAY yet'); |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
155 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
156 select undef, undef, undef, 1.1; |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
157 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
158 $sid = $s->new_stream(); |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
159 $frames = $s->read(all => [{ sid => $sid, fin => 1 }, { type => 'GOAWAY' }]); |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
160 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
161 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
162 is($frame->{headers}->{':status'}, 200, 'keepalive time request 2'); |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
163 like($frame->{headers}->{'x-conn'}, qr/^2:[^0]/, 'keepalive time variables 2'); |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
164 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
165 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
166 is($frame->{sid}, 3, 'keepalive time limit - GOAWAY stream type'); |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
167 is($frame->{last_sid}, 8, 'keepalive time limit - GOAWAY last stream'); |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
168 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
169 # graceful shutdown in idle state |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
170 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
171 $s = Test::Nginx::HTTP3->new(); |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
172 $sid = $s->new_stream(); |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
173 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
174 $t->reload(); |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
175 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
176 $frames = $s->read(all => [{ type => 'GOAWAY' }]); |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
177 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
178 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
179 is($frame->{sid}, 3, 'graceful shutdown - GOAWAY stream type'); |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
180 is($frame->{last_sid}, 4, 'graceful shutdown - GOAWAY last stream'); |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
181 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
182 ############################################################################### |