Mercurial > hg > nginx-tests
annotate h2_keepalive.t @ 1990:85d88cd5091c
Tests: SSI include stub tests.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 04 Jul 2024 17:42:55 +0300 |
parents | 11463d379570 |
children |
rev | line source |
---|---|
1077
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
2 |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
3 # (C) Sergey Kandaurov |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
4 # (C) Nginx, Inc. |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
5 |
1693
5ac6efbe5552
Tests: removed TODO and try_run() checks for legacy versions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1668
diff
changeset
|
6 # Tests for HTTP/2 protocol, keepalive directives. |
1077
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
7 |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
8 ############################################################################### |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
9 |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
10 use warnings; |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
11 use strict; |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
12 |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
13 use Test::More; |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
14 |
1579
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
15 use Socket qw(SOL_SOCKET SO_RCVBUF); |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
16 |
1077
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
17 BEGIN { use FindBin; chdir($FindBin::Bin); } |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
18 |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
19 use lib 'lib'; |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
20 use Test::Nginx; |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
21 use Test::Nginx::HTTP2; |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
22 |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
23 ############################################################################### |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
24 |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
25 select STDERR; $| = 1; |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
26 select STDOUT; $| = 1; |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
27 |
1900
236d038dc04a
Tests: suppress "listen .. http2;" deprecation warnings.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1694
diff
changeset
|
28 my $t = Test::Nginx->new()->has(qw/http http_v2/)->plan(19) |
1077
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
29 ->write_file_expand('nginx.conf', <<'EOF'); |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
30 |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
31 %%TEST_GLOBALS%% |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
32 |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
33 daemon off; |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
34 |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
35 events { |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
36 } |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
37 |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
38 http { |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
39 %%TEST_GLOBALS_HTTP%% |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
40 |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
41 server { |
1986
11463d379570
Tests: reworked HTTP/2 tests to use "http2 on".
Maxim Dounin <mdounin@mdounin.ru>
parents:
1900
diff
changeset
|
42 listen 127.0.0.1:8080 sndbuf=1m; |
1077
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
43 server_name localhost; |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
44 |
1986
11463d379570
Tests: reworked HTTP/2 tests to use "http2 on".
Maxim Dounin <mdounin@mdounin.ru>
parents:
1900
diff
changeset
|
45 http2 on; |
1652
21f511a7f5c3
Tests: compatibility with http2_max_requests removal.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1588
diff
changeset
|
46 keepalive_requests 2; |
1077
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
47 |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
48 location / { } |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
49 } |
1657
22e0133d68b4
Tests: added HTTP/2 test with "keepalive_timeout 0" (ticket #2142).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1652
diff
changeset
|
50 |
22e0133d68b4
Tests: added HTTP/2 test with "keepalive_timeout 0" (ticket #2142).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1652
diff
changeset
|
51 server { |
1986
11463d379570
Tests: reworked HTTP/2 tests to use "http2 on".
Maxim Dounin <mdounin@mdounin.ru>
parents:
1900
diff
changeset
|
52 listen 127.0.0.1:8081; |
1657
22e0133d68b4
Tests: added HTTP/2 test with "keepalive_timeout 0" (ticket #2142).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1652
diff
changeset
|
53 server_name localhost; |
22e0133d68b4
Tests: added HTTP/2 test with "keepalive_timeout 0" (ticket #2142).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1652
diff
changeset
|
54 |
1986
11463d379570
Tests: reworked HTTP/2 tests to use "http2 on".
Maxim Dounin <mdounin@mdounin.ru>
parents:
1900
diff
changeset
|
55 http2 on; |
1657
22e0133d68b4
Tests: added HTTP/2 test with "keepalive_timeout 0" (ticket #2142).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1652
diff
changeset
|
56 keepalive_timeout 0; |
22e0133d68b4
Tests: added HTTP/2 test with "keepalive_timeout 0" (ticket #2142).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1652
diff
changeset
|
57 |
22e0133d68b4
Tests: added HTTP/2 test with "keepalive_timeout 0" (ticket #2142).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1652
diff
changeset
|
58 location / { } |
22e0133d68b4
Tests: added HTTP/2 test with "keepalive_timeout 0" (ticket #2142).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1652
diff
changeset
|
59 } |
1667
bdebd63dbab3
Tests: keepalive_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1657
diff
changeset
|
60 |
bdebd63dbab3
Tests: keepalive_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1657
diff
changeset
|
61 server { |
1986
11463d379570
Tests: reworked HTTP/2 tests to use "http2 on".
Maxim Dounin <mdounin@mdounin.ru>
parents:
1900
diff
changeset
|
62 listen 127.0.0.1:8082; |
1667
bdebd63dbab3
Tests: keepalive_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1657
diff
changeset
|
63 server_name localhost; |
bdebd63dbab3
Tests: keepalive_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1657
diff
changeset
|
64 |
1986
11463d379570
Tests: reworked HTTP/2 tests to use "http2 on".
Maxim Dounin <mdounin@mdounin.ru>
parents:
1900
diff
changeset
|
65 http2 on; |
1667
bdebd63dbab3
Tests: keepalive_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1657
diff
changeset
|
66 keepalive_time 1s; |
bdebd63dbab3
Tests: keepalive_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1657
diff
changeset
|
67 |
1668
0c1bd4c23c95
Tests: $connection_requests and $connection_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1667
diff
changeset
|
68 add_header X-Conn $connection_requests:$connection_time; |
0c1bd4c23c95
Tests: $connection_requests and $connection_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1667
diff
changeset
|
69 |
1667
bdebd63dbab3
Tests: keepalive_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1657
diff
changeset
|
70 location / { } |
bdebd63dbab3
Tests: keepalive_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1657
diff
changeset
|
71 } |
1077
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
72 } |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
73 |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
74 EOF |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
75 |
1579
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
76 $t->write_file('index.html', 'SEE-THAT' x 50000); |
1657
22e0133d68b4
Tests: added HTTP/2 test with "keepalive_timeout 0" (ticket #2142).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1652
diff
changeset
|
77 $t->write_file('t.html', 'SEE-THAT'); |
1652
21f511a7f5c3
Tests: compatibility with http2_max_requests removal.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1588
diff
changeset
|
78 |
1900
236d038dc04a
Tests: suppress "listen .. http2;" deprecation warnings.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1694
diff
changeset
|
79 $t->run(); |
1077
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
80 |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
81 ############################################################################### |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
82 |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
83 my $s = Test::Nginx::HTTP2->new(); |
1579
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
84 |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
85 # to test lingering close, let full response settle down in send buffer space |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
86 # so that client additional data past server-side close would trigger TCP RST |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
87 |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
88 $s->{socket}->setsockopt(SOL_SOCKET, SO_RCVBUF, 64*1024) or die $!; |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
89 $s->h2_settings(0, 0x4 => 2**20); |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
90 $s->h2_window(2**21); |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
91 |
1077
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
92 my $frames = $s->read(all => [{ sid => $s->new_stream(), fin => 1 }]); |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
93 |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
94 my ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
95 is($frame->{headers}->{':status'}, 200, 'max requests'); |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
96 |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
97 $frames = $s->read(all => [{ type => 'GOAWAY' }], wait => 0.5) |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
98 unless grep { $_->{type} eq "GOAWAY" } @$frames; |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
99 |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
100 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
101 is($frame, undef, 'max requests - GOAWAY'); |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
102 |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
103 # max requests limited |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
104 |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
105 my $sid = $s->new_stream(); |
1579
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
106 |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
107 # wait server to finish and close socket if lingering close were disabled |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
108 |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
109 select undef, undef, undef, 0.1; |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
110 $s->h2_ping("SEE-THIS"); |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
111 |
1077
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
112 $frames = $s->read(all => [{ sid => $sid, fin => 1 }, { type => 'GOAWAY' }]); |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
113 |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
114 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
115 is($frame->{headers}->{':status'}, 200, 'max requests limited'); |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
116 |
1579
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
117 my @data = grep { $_->{type} eq "DATA" } @$frames; |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
118 my $sum = eval join '+', map { $_->{length} } @data; |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
119 is($sum, 400000, 'max requests limited - all data received'); |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
120 |
1077
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
121 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
122 ok($frame, 'max requests limited - GOAWAY'); |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
123 is($frame->{last_sid}, $sid, 'max requests limited - GOAWAY last stream'); |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
124 |
1657
22e0133d68b4
Tests: added HTTP/2 test with "keepalive_timeout 0" (ticket #2142).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1652
diff
changeset
|
125 # keepalive_timeout 0 |
22e0133d68b4
Tests: added HTTP/2 test with "keepalive_timeout 0" (ticket #2142).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1652
diff
changeset
|
126 |
22e0133d68b4
Tests: added HTTP/2 test with "keepalive_timeout 0" (ticket #2142).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1652
diff
changeset
|
127 $s = Test::Nginx::HTTP2->new(port(8081)); |
22e0133d68b4
Tests: added HTTP/2 test with "keepalive_timeout 0" (ticket #2142).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1652
diff
changeset
|
128 $sid = $s->new_stream({ path => '/t.html' }); |
22e0133d68b4
Tests: added HTTP/2 test with "keepalive_timeout 0" (ticket #2142).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1652
diff
changeset
|
129 $frames = $s->read(all => [{ sid => $sid, fin => 1 }, { type => 'GOAWAY' }]); |
22e0133d68b4
Tests: added HTTP/2 test with "keepalive_timeout 0" (ticket #2142).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1652
diff
changeset
|
130 |
22e0133d68b4
Tests: added HTTP/2 test with "keepalive_timeout 0" (ticket #2142).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1652
diff
changeset
|
131 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
22e0133d68b4
Tests: added HTTP/2 test with "keepalive_timeout 0" (ticket #2142).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1652
diff
changeset
|
132 is($frame->{headers}->{':status'}, 200, 'keepalive_timeout 0'); |
22e0133d68b4
Tests: added HTTP/2 test with "keepalive_timeout 0" (ticket #2142).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1652
diff
changeset
|
133 |
22e0133d68b4
Tests: added HTTP/2 test with "keepalive_timeout 0" (ticket #2142).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1652
diff
changeset
|
134 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; |
22e0133d68b4
Tests: added HTTP/2 test with "keepalive_timeout 0" (ticket #2142).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1652
diff
changeset
|
135 ok($frame, 'keepalive_timeout 0 - GOAWAY'); |
22e0133d68b4
Tests: added HTTP/2 test with "keepalive_timeout 0" (ticket #2142).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1652
diff
changeset
|
136 |
1667
bdebd63dbab3
Tests: keepalive_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1657
diff
changeset
|
137 # keepalive_time |
bdebd63dbab3
Tests: keepalive_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1657
diff
changeset
|
138 |
bdebd63dbab3
Tests: keepalive_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1657
diff
changeset
|
139 $s = Test::Nginx::HTTP2->new(port(8082)); |
bdebd63dbab3
Tests: keepalive_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1657
diff
changeset
|
140 $sid = $s->new_stream({ path => '/t.html' }); |
bdebd63dbab3
Tests: keepalive_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1657
diff
changeset
|
141 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
bdebd63dbab3
Tests: keepalive_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1657
diff
changeset
|
142 |
bdebd63dbab3
Tests: keepalive_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1657
diff
changeset
|
143 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
bdebd63dbab3
Tests: keepalive_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1657
diff
changeset
|
144 is($frame->{headers}->{':status'}, 200, 'keepalive time request'); |
1668
0c1bd4c23c95
Tests: $connection_requests and $connection_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1667
diff
changeset
|
145 like($frame->{headers}->{'x-conn'}, qr/^1:0/, 'keepalive time variables'); |
1667
bdebd63dbab3
Tests: keepalive_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1657
diff
changeset
|
146 |
bdebd63dbab3
Tests: keepalive_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1657
diff
changeset
|
147 $frames = $s->read(all => [{ type => 'GOAWAY' }], wait => 0.5); |
bdebd63dbab3
Tests: keepalive_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1657
diff
changeset
|
148 |
bdebd63dbab3
Tests: keepalive_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1657
diff
changeset
|
149 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; |
bdebd63dbab3
Tests: keepalive_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1657
diff
changeset
|
150 is($frame, undef, 'keepalive time - no GOAWAY yet'); |
bdebd63dbab3
Tests: keepalive_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1657
diff
changeset
|
151 |
bdebd63dbab3
Tests: keepalive_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1657
diff
changeset
|
152 select undef, undef, undef, 1.1; |
bdebd63dbab3
Tests: keepalive_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1657
diff
changeset
|
153 |
bdebd63dbab3
Tests: keepalive_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1657
diff
changeset
|
154 $sid = $s->new_stream({ path => '/t.html' }); |
bdebd63dbab3
Tests: keepalive_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1657
diff
changeset
|
155 $frames = $s->read(all => [{ sid => $sid, fin => 1 }, { type => 'GOAWAY' }]); |
bdebd63dbab3
Tests: keepalive_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1657
diff
changeset
|
156 |
bdebd63dbab3
Tests: keepalive_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1657
diff
changeset
|
157 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
bdebd63dbab3
Tests: keepalive_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1657
diff
changeset
|
158 is($frame->{headers}->{':status'}, 200, 'keepalive time request 2'); |
1668
0c1bd4c23c95
Tests: $connection_requests and $connection_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1667
diff
changeset
|
159 like($frame->{headers}->{'x-conn'}, qr/^2:[^0]/, 'keepalive time variables 2'); |
1667
bdebd63dbab3
Tests: keepalive_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1657
diff
changeset
|
160 |
bdebd63dbab3
Tests: keepalive_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1657
diff
changeset
|
161 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; |
bdebd63dbab3
Tests: keepalive_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1657
diff
changeset
|
162 ok($frame, 'keepalive time limit - GOAWAY'); |
bdebd63dbab3
Tests: keepalive_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1657
diff
changeset
|
163 is($frame->{last_sid}, $sid, 'keepalive time limit - GOAWAY last stream'); |
bdebd63dbab3
Tests: keepalive_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1657
diff
changeset
|
164 |
1579
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
165 # graceful shutdown in idle state |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
166 |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
167 $s = Test::Nginx::HTTP2->new(); |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
168 $s->{socket}->setsockopt(SOL_SOCKET, SO_RCVBUF, 64*1024) or die $!; |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
169 $s->h2_settings(0, 0x4 => 2**20); |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
170 $s->h2_window(2**21); |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
171 |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
172 $sid = $s->new_stream(); |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
173 |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
174 # wait server to finish and close socket if lingering close were disabled |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
175 |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
176 select undef, undef, undef, 0.1; |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
177 |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
178 $t->reload(); |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
179 |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
180 select undef, undef, undef, 0.3; |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
181 |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
182 $s->h2_ping("SEE-THIS"); |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
183 |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
184 $frames = $s->read(all => [{ sid => $sid, fin => 1 }, { type => 'GOAWAY' }]); |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
185 |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
186 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
187 is($frame->{headers}->{':status'}, 200, 'graceful shutdown in idle'); |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
188 |
1693
5ac6efbe5552
Tests: removed TODO and try_run() checks for legacy versions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1668
diff
changeset
|
189 @data = grep { $_->{type} eq "DATA" } @$frames; |
5ac6efbe5552
Tests: removed TODO and try_run() checks for legacy versions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1668
diff
changeset
|
190 $sum = eval join '+', map { $_->{length} } @data; |
1579
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
191 is($sum, 400000, 'graceful shutdown in idle - all data received'); |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
192 |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
193 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
194 ok($frame, 'graceful shutdown in idle - GOAWAY'); |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
195 is($frame->{last_sid}, $sid, 'graceful shutdown in idle - GOAWAY last stream'); |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
196 |
1077
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
197 ############################################################################### |