Mercurial > hg > nginx-tests
annotate http_keepalive_shutdown.t @ 1932:b68471aee5ad
Tests: improved test for a stream initiating QUIC path migration.
Previously, the test mostly passed due to a push timer scheduled for an
unrelated delayed ACK, and the new path had enough data received to send
response back when the push timer fired. Otherwise, the test could fail
due to unvalidated address. Now it is fixed to perform path validation.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Mon, 21 Aug 2023 17:10:57 +0400 |
parents | 0c50a00e6733 |
children | 2a0a6035a1af |
rev | line source |
---|---|
1753
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
2 |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
3 # (C) Sergey Kandaurov |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
4 # (C) Nginx, Inc. |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
5 |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
6 # Tests for http keepalive connections on worker shutdown. |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
7 |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
8 ############################################################################### |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
9 |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
10 use warnings; |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
11 use strict; |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
12 |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
13 use Test::More; |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
14 |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
15 BEGIN { use FindBin; chdir($FindBin::Bin); } |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
16 |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
17 use lib 'lib'; |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
18 use Test::Nginx qw/ :DEFAULT http_end /; |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
19 |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
20 ############################################################################### |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
21 |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
22 select STDERR; $| = 1; |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
23 select STDOUT; $| = 1; |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
24 |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
25 my $t = Test::Nginx->new()->has(qw/http limit_req/)->plan(1); |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
26 |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
27 $t->write_file_expand('nginx.conf', <<'EOF'); |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
28 |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
29 %%TEST_GLOBALS%% |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
30 |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
31 daemon off; |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
32 |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
33 events { |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
34 } |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
35 |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
36 http { |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
37 %%TEST_GLOBALS_HTTP%% |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
38 |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
39 limit_req_zone $binary_remote_addr zone=one:1m rate=1r/s; |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
40 |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
41 server { |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
42 listen 127.0.0.1:8080; |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
43 server_name localhost; |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
44 |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
45 location / { |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
46 limit_req zone=one burst=5; |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
47 } |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
48 } |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
49 } |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
50 |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
51 EOF |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
52 |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
53 $t->write_file('test.html', 'XtestX'); |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
54 $t->run(); |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
55 |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
56 ############################################################################### |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
57 |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
58 local $TODO = 'not yet' unless $t->has_version('1.21.6'); |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
59 |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
60 # signaling on graceful shutdown to client that keepalive connection is closing |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
61 |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
62 my $s = http(<<EOF, start => 1); |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
63 HEAD /test.html HTTP/1.1 |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
64 Host: localhost |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
65 |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
66 HEAD /test.html HTTP/1.1 |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
67 Host: localhost |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
68 |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
69 EOF |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
70 |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
71 select undef, undef, undef, 0.1; |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
72 |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
73 $t->stop(); |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
74 |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
75 like(http_end($s), qr/Connection: close/, 'connection close on exit'); |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
76 |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
77 ############################################################################### |