Mercurial > hg > nginx-tests
annotate h3_keepalive.t @ 1878:b69bae343c53
Tests: HTTP/3 keepalive tests.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Thu, 12 Jan 2023 14:09:25 +0400 |
parents | |
children | 8b74936ff2ac |
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 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
26 eval { require Crypt::Misc; die if $Crypt::Misc::VERSION < 0.067; }; |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
27 plan(skip_all => 'CryptX version >= 0.067 required') if $@; |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
28 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
29 my $t = Test::Nginx->new()->has(qw/http http_v3/) |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
30 ->has_daemon('openssl')->plan(15) |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
31 ->write_file_expand('nginx.conf', <<'EOF'); |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
32 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
33 %%TEST_GLOBALS%% |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
34 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
35 daemon off; |
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 events { |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
38 } |
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 http { |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
41 %%TEST_GLOBALS_HTTP%% |
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 ssl_certificate_key localhost.key; |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
44 ssl_certificate localhost.crt; |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
45 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
46 server { |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
47 listen 127.0.0.1:%%PORT_8980_UDP%% quic; |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
48 server_name localhost; |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
49 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
50 keepalive_requests 2; |
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 location / { } |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
53 } |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
54 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
55 server { |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
56 listen 127.0.0.1:%%PORT_8981_UDP%% quic; |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
57 server_name localhost; |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
58 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
59 keepalive_timeout 0; |
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 location / { } |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
62 } |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
63 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
64 server { |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
65 listen 127.0.0.1:%%PORT_8982_UDP%% quic; |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
66 server_name localhost; |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
67 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
68 keepalive_time 1s; |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
69 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
70 add_header X-Conn $connection_requests:$connection_time; |
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 location / { } |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
73 } |
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 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
76 EOF |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
77 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
78 $t->write_file('openssl.conf', <<EOF); |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
79 [ req ] |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
80 default_bits = 2048 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
81 encrypt_key = no |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
82 distinguished_name = req_distinguished_name |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
83 [ req_distinguished_name ] |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
84 EOF |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
85 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
86 my $d = $t->testdir(); |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
87 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
88 foreach my $name ('localhost') { |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
89 system('openssl req -x509 -new ' |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
90 . "-config $d/openssl.conf -subj /CN=$name/ " |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
91 . "-out $d/$name.crt -keyout $d/$name.key " |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
92 . ">>$d/openssl.out 2>&1") == 0 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
93 or die "Can't create certificate for $name: $!\n"; |
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 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
96 $t->write_file('index.html', 'SEE-THIS'); |
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 $t->run(); |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
99 |
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 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
102 my ($s, $sid, $frames, $frame); |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
103 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
104 # max requests limited |
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 $s = Test::Nginx::HTTP3->new(); |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
107 $frames = $s->read(all => [{ sid => $s->new_stream(), fin => 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 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
110 is($frame->{headers}->{':status'}, 200, 'keepalive requests 1'); |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
111 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
112 $frames = $s->read(all => [ |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
113 { sid => $s->new_stream(), fin => 1 }, |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
114 { type => 'GOAWAY' } |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
115 ]); |
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 "HEADERS" } @$frames; |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
118 is($frame->{headers}->{':status'}, 200, 'keepalive requests 2'); |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
119 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
120 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
121 is($frame->{sid}, 3, 'keepalive requests - GOAWAY stream type'); |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
122 is($frame->{last_sid}, 8, 'keepalive requests - GOAWAY last stream'); |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
123 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
124 # keepalive_timeout 0 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
125 # currently, keepalive timer is set before reading 1st request |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
126 # and there is no special handling for zero value timeout |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
127 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
128 $s = Test::Nginx::HTTP3->new(8981); |
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 TODO: { |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
131 todo_skip 'keepalive_timeout 0', 2 unless $s; |
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 $sid = $s->new_stream(); |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
134 $frames = $s->read(all => [{ sid => $sid, fin => 1 }, { type => 'GOAWAY' }]); |
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 "HEADERS" } @$frames; |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
137 is($frame->{headers}->{':status'}, 200, 'keepalive_timeout 0'); |
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 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
140 ok($frame, 'keepalive_timeout 0 - GOAWAY'); |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
141 |
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 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
144 # keepalive_time |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
145 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
146 $s = Test::Nginx::HTTP3->new(8982); |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
147 $sid = $s->new_stream(); |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
148 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
149 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
150 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
151 is($frame->{headers}->{':status'}, 200, 'keepalive time request'); |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
152 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
|
153 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
154 $frames = $s->read(all => [{ type => 'GOAWAY' }], wait => 0.5); |
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 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
157 is($frame, undef, 'keepalive time - no GOAWAY yet'); |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
158 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
159 select undef, undef, undef, 1.1; |
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 $sid = $s->new_stream(); |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
162 $frames = $s->read(all => [{ sid => $sid, fin => 1 }, { type => 'GOAWAY' }]); |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
163 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
164 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
165 is($frame->{headers}->{':status'}, 200, 'keepalive time request 2'); |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
166 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
|
167 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
168 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
169 is($frame->{sid}, 3, 'keepalive time limit - GOAWAY stream type'); |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
170 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
|
171 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
172 # graceful shutdown in idle state |
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 $s = Test::Nginx::HTTP3->new(); |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
175 $sid = $s->new_stream(); |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
176 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
177 $t->reload(); |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
178 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
179 $frames = $s->read(all => [{ type => 'GOAWAY' }]); |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
180 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
181 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
182 is($frame->{sid}, 3, 'graceful shutdown - GOAWAY stream type'); |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
183 is($frame->{last_sid}, 4, 'graceful shutdown - GOAWAY last stream'); |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
184 |
b69bae343c53
Tests: HTTP/3 keepalive tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
185 ############################################################################### |