Mercurial > hg > nginx-tests
annotate h2_keepalive.t @ 1900:236d038dc04a
Tests: suppress "listen .. http2;" deprecation warnings.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Wed, 31 May 2023 13:29:34 +0400 |
parents | 3366128e526b |
children | 11463d379570 |
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 { |
1579
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
42 listen 127.0.0.1:8080 http2 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 |
1652
21f511a7f5c3
Tests: compatibility with http2_max_requests removal.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1588
diff
changeset
|
45 keepalive_requests 2; |
1077
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
46 |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
47 location / { } |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
48 } |
1657
22e0133d68b4
Tests: added HTTP/2 test with "keepalive_timeout 0" (ticket #2142).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1652
diff
changeset
|
49 |
22e0133d68b4
Tests: added HTTP/2 test with "keepalive_timeout 0" (ticket #2142).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1652
diff
changeset
|
50 server { |
22e0133d68b4
Tests: added HTTP/2 test with "keepalive_timeout 0" (ticket #2142).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1652
diff
changeset
|
51 listen 127.0.0.1:8081 http2; |
22e0133d68b4
Tests: added HTTP/2 test with "keepalive_timeout 0" (ticket #2142).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1652
diff
changeset
|
52 server_name localhost; |
22e0133d68b4
Tests: added HTTP/2 test with "keepalive_timeout 0" (ticket #2142).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1652
diff
changeset
|
53 |
22e0133d68b4
Tests: added HTTP/2 test with "keepalive_timeout 0" (ticket #2142).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1652
diff
changeset
|
54 keepalive_timeout 0; |
22e0133d68b4
Tests: added HTTP/2 test with "keepalive_timeout 0" (ticket #2142).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1652
diff
changeset
|
55 |
22e0133d68b4
Tests: added HTTP/2 test with "keepalive_timeout 0" (ticket #2142).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1652
diff
changeset
|
56 location / { } |
22e0133d68b4
Tests: added HTTP/2 test with "keepalive_timeout 0" (ticket #2142).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1652
diff
changeset
|
57 } |
1667
bdebd63dbab3
Tests: keepalive_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1657
diff
changeset
|
58 |
bdebd63dbab3
Tests: keepalive_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1657
diff
changeset
|
59 server { |
bdebd63dbab3
Tests: keepalive_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1657
diff
changeset
|
60 listen 127.0.0.1:8082 http2; |
bdebd63dbab3
Tests: keepalive_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1657
diff
changeset
|
61 server_name localhost; |
bdebd63dbab3
Tests: keepalive_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1657
diff
changeset
|
62 |
bdebd63dbab3
Tests: keepalive_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1657
diff
changeset
|
63 keepalive_time 1s; |
bdebd63dbab3
Tests: keepalive_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1657
diff
changeset
|
64 |
1668
0c1bd4c23c95
Tests: $connection_requests and $connection_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1667
diff
changeset
|
65 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
|
66 |
1667
bdebd63dbab3
Tests: keepalive_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1657
diff
changeset
|
67 location / { } |
bdebd63dbab3
Tests: keepalive_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1657
diff
changeset
|
68 } |
1077
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
69 } |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
70 |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
71 EOF |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
72 |
1579
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
73 $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
|
74 $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
|
75 |
1900
236d038dc04a
Tests: suppress "listen .. http2;" deprecation warnings.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1694
diff
changeset
|
76 # suppress deprecation warning |
236d038dc04a
Tests: suppress "listen .. http2;" deprecation warnings.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1694
diff
changeset
|
77 |
236d038dc04a
Tests: suppress "listen .. http2;" deprecation warnings.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1694
diff
changeset
|
78 open OLDERR, ">&", \*STDERR; close STDERR; |
236d038dc04a
Tests: suppress "listen .. http2;" deprecation warnings.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1694
diff
changeset
|
79 $t->run(); |
236d038dc04a
Tests: suppress "listen .. http2;" deprecation warnings.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1694
diff
changeset
|
80 open STDERR, ">&", \*OLDERR; |
1077
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 |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
84 my $s = Test::Nginx::HTTP2->new(); |
1579
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
85 |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
86 # 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
|
87 # 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
|
88 |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
89 $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
|
90 $s->h2_settings(0, 0x4 => 2**20); |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
91 $s->h2_window(2**21); |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
92 |
1077
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
93 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
|
94 |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
95 my ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
96 is($frame->{headers}->{':status'}, 200, 'max requests'); |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
97 |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
98 $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
|
99 unless grep { $_->{type} eq "GOAWAY" } @$frames; |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
100 |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
101 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
102 is($frame, undef, 'max requests - GOAWAY'); |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
103 |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
104 # max requests limited |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
105 |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
106 my $sid = $s->new_stream(); |
1579
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
107 |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
108 # 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
|
109 |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
110 select undef, undef, undef, 0.1; |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
111 $s->h2_ping("SEE-THIS"); |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
112 |
1077
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
113 $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
|
114 |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
115 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
116 is($frame->{headers}->{':status'}, 200, 'max requests limited'); |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
117 |
1579
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
118 my @data = grep { $_->{type} eq "DATA" } @$frames; |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
119 my $sum = eval join '+', map { $_->{length} } @data; |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
120 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
|
121 |
1077
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
122 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
123 ok($frame, 'max requests limited - GOAWAY'); |
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
124 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
|
125 |
1657
22e0133d68b4
Tests: added HTTP/2 test with "keepalive_timeout 0" (ticket #2142).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1652
diff
changeset
|
126 # keepalive_timeout 0 |
22e0133d68b4
Tests: added HTTP/2 test with "keepalive_timeout 0" (ticket #2142).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1652
diff
changeset
|
127 |
22e0133d68b4
Tests: added HTTP/2 test with "keepalive_timeout 0" (ticket #2142).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1652
diff
changeset
|
128 $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
|
129 $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
|
130 $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
|
131 |
22e0133d68b4
Tests: added HTTP/2 test with "keepalive_timeout 0" (ticket #2142).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1652
diff
changeset
|
132 ($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
|
133 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
|
134 |
22e0133d68b4
Tests: added HTTP/2 test with "keepalive_timeout 0" (ticket #2142).
Sergey Kandaurov <pluknet@nginx.com>
parents:
1652
diff
changeset
|
135 ($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
|
136 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
|
137 |
1667
bdebd63dbab3
Tests: keepalive_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1657
diff
changeset
|
138 # keepalive_time |
bdebd63dbab3
Tests: keepalive_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1657
diff
changeset
|
139 |
bdebd63dbab3
Tests: keepalive_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1657
diff
changeset
|
140 $s = Test::Nginx::HTTP2->new(port(8082)); |
bdebd63dbab3
Tests: keepalive_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1657
diff
changeset
|
141 $sid = $s->new_stream({ path => '/t.html' }); |
bdebd63dbab3
Tests: keepalive_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1657
diff
changeset
|
142 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
bdebd63dbab3
Tests: keepalive_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1657
diff
changeset
|
143 |
bdebd63dbab3
Tests: keepalive_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1657
diff
changeset
|
144 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
bdebd63dbab3
Tests: keepalive_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1657
diff
changeset
|
145 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
|
146 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
|
147 |
bdebd63dbab3
Tests: keepalive_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1657
diff
changeset
|
148 $frames = $s->read(all => [{ type => 'GOAWAY' }], wait => 0.5); |
bdebd63dbab3
Tests: keepalive_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1657
diff
changeset
|
149 |
bdebd63dbab3
Tests: keepalive_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1657
diff
changeset
|
150 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; |
bdebd63dbab3
Tests: keepalive_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1657
diff
changeset
|
151 is($frame, undef, 'keepalive time - no GOAWAY yet'); |
bdebd63dbab3
Tests: keepalive_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1657
diff
changeset
|
152 |
bdebd63dbab3
Tests: keepalive_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1657
diff
changeset
|
153 select undef, undef, undef, 1.1; |
bdebd63dbab3
Tests: keepalive_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1657
diff
changeset
|
154 |
bdebd63dbab3
Tests: keepalive_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1657
diff
changeset
|
155 $sid = $s->new_stream({ path => '/t.html' }); |
bdebd63dbab3
Tests: keepalive_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1657
diff
changeset
|
156 $frames = $s->read(all => [{ sid => $sid, fin => 1 }, { type => 'GOAWAY' }]); |
bdebd63dbab3
Tests: keepalive_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1657
diff
changeset
|
157 |
bdebd63dbab3
Tests: keepalive_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1657
diff
changeset
|
158 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
bdebd63dbab3
Tests: keepalive_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1657
diff
changeset
|
159 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
|
160 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
|
161 |
bdebd63dbab3
Tests: keepalive_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1657
diff
changeset
|
162 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; |
bdebd63dbab3
Tests: keepalive_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1657
diff
changeset
|
163 ok($frame, 'keepalive time limit - GOAWAY'); |
bdebd63dbab3
Tests: keepalive_time tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1657
diff
changeset
|
164 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
|
165 |
1579
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
166 # graceful shutdown in idle state |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
167 |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
168 $s = Test::Nginx::HTTP2->new(); |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
169 $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
|
170 $s->h2_settings(0, 0x4 => 2**20); |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
171 $s->h2_window(2**21); |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
172 |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
173 $sid = $s->new_stream(); |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
174 |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
175 # 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
|
176 |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
177 select undef, undef, undef, 0.1; |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
178 |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
179 $t->reload(); |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
180 |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
181 select undef, undef, undef, 0.3; |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
182 |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
183 $s->h2_ping("SEE-THIS"); |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
184 |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
185 $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
|
186 |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
187 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
188 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
|
189 |
1693
5ac6efbe5552
Tests: removed TODO and try_run() checks for legacy versions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1668
diff
changeset
|
190 @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
|
191 $sum = eval join '+', map { $_->{length} } @data; |
1579
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
192 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
|
193 |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
194 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
195 ok($frame, 'graceful shutdown in idle - GOAWAY'); |
14eeaa39599d
Tests: HTTP/2 tests for lingering close.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1251
diff
changeset
|
196 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
|
197 |
1077
13247bbc1f7d
Tests: HTTP/2 tests for max requests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
198 ############################################################################### |