Mercurial > hg > nginx-tests
annotate http_keepalive_shutdown.t @ 1972:f3573393f36f
Tests: guarded ssl_stapling.t for old OpenSSL versions.
Stapling requires the certificate status TLS extension. It is implemented
in OpenSSL 0.9.8h and available if TLS extensions support is explicitly
configured, and by default since 0.9.8j.
To properly test if stapling is available, OpenSSL version is checked,
and SNI availability is checked to ensure TLS extensions support is
compiled in.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Mon, 06 May 2024 00:04:22 +0300 |
parents | 2a0a6035a1af |
children |
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 # 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
|
59 |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
60 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
|
61 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
|
62 Host: localhost |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
63 |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
64 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
|
65 Host: localhost |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
66 |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
67 EOF |
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 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
|
70 |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
71 $t->stop(); |
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 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
|
74 |
0c50a00e6733
Tests: added http keepalive test for Connection header on shutdown.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
75 ############################################################################### |