Mercurial > hg > nginx-tests
annotate worker_shutdown_timeout.t @ 1829:a78c32419f02
Tests: separate SSL session reuse tests.
Instead of being mixed with generic SSL tests, session reuse variants
are now tested in a separate file.
In the generic SSL tests only basic session reuse is now tested,
notably with session tickets enabled and a shared SSL session cache.
This should make it possible to reuse sessions in all cases (except
when it's not supported, such as with LibreSSL with TLSv1.3).
Note that session reuse with tickets implies that $ssl_session_id
is selected by the client and therefore is not available on the
initial connection. Relevant test is modified to handle this.
Further, BoringSSL does not use legacy session ID with TLSv1.3 even
if it is sent by the client. In contrast, OpenSSL always generates
an unique legacy session id, so it is available with TLSv1.3 even if
session resumption does not work (such as with old Net::SSLeay and
IO::Socket::SSL modules).
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 23 Mar 2023 19:49:47 +0300 |
parents | 766bcbb632ee |
children |
rev | line source |
---|---|
1149
b1c2857d2e97
Tests: basic worker_shutdown_timeout test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
b1c2857d2e97
Tests: basic worker_shutdown_timeout test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
2 |
b1c2857d2e97
Tests: basic worker_shutdown_timeout test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
3 # (C) Sergey Kandaurov |
b1c2857d2e97
Tests: basic worker_shutdown_timeout test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
4 # (C) Nginx, Inc. |
b1c2857d2e97
Tests: basic worker_shutdown_timeout test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
5 |
b1c2857d2e97
Tests: basic worker_shutdown_timeout test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
6 # Tests for worker_shutdown_timeout directive. |
b1c2857d2e97
Tests: basic worker_shutdown_timeout test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
7 |
b1c2857d2e97
Tests: basic worker_shutdown_timeout test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
8 ############################################################################### |
b1c2857d2e97
Tests: basic worker_shutdown_timeout test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
9 |
b1c2857d2e97
Tests: basic worker_shutdown_timeout test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
10 use warnings; |
b1c2857d2e97
Tests: basic worker_shutdown_timeout test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
11 use strict; |
b1c2857d2e97
Tests: basic worker_shutdown_timeout test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
12 |
b1c2857d2e97
Tests: basic worker_shutdown_timeout test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
13 use Test::More; |
b1c2857d2e97
Tests: basic worker_shutdown_timeout test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
14 |
1157
06bb6af4324e
Tests: adjusted worker_shutdown_timeout test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1149
diff
changeset
|
15 use IO::Select; |
06bb6af4324e
Tests: adjusted worker_shutdown_timeout test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1149
diff
changeset
|
16 |
1149
b1c2857d2e97
Tests: basic worker_shutdown_timeout test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
17 BEGIN { use FindBin; chdir($FindBin::Bin); } |
b1c2857d2e97
Tests: basic worker_shutdown_timeout test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
18 |
b1c2857d2e97
Tests: basic worker_shutdown_timeout test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
19 use lib 'lib'; |
b1c2857d2e97
Tests: basic worker_shutdown_timeout test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
20 use Test::Nginx; |
b1c2857d2e97
Tests: basic worker_shutdown_timeout test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
21 |
b1c2857d2e97
Tests: basic worker_shutdown_timeout test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
22 ############################################################################### |
b1c2857d2e97
Tests: basic worker_shutdown_timeout test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
23 |
b1c2857d2e97
Tests: basic worker_shutdown_timeout test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
24 select STDERR; $| = 1; |
b1c2857d2e97
Tests: basic worker_shutdown_timeout test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
25 select STDOUT; $| = 1; |
b1c2857d2e97
Tests: basic worker_shutdown_timeout test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
26 |
b1c2857d2e97
Tests: basic worker_shutdown_timeout test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
27 my $t = Test::Nginx->new()->has(qw/http/) |
b1c2857d2e97
Tests: basic worker_shutdown_timeout test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
28 ->write_file_expand('nginx.conf', <<'EOF'); |
b1c2857d2e97
Tests: basic worker_shutdown_timeout test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
29 |
b1c2857d2e97
Tests: basic worker_shutdown_timeout test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
30 %%TEST_GLOBALS%% |
b1c2857d2e97
Tests: basic worker_shutdown_timeout test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
31 |
b1c2857d2e97
Tests: basic worker_shutdown_timeout test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
32 daemon off; |
b1c2857d2e97
Tests: basic worker_shutdown_timeout test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
33 worker_shutdown_timeout 10ms; |
b1c2857d2e97
Tests: basic worker_shutdown_timeout test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
34 |
b1c2857d2e97
Tests: basic worker_shutdown_timeout test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
35 events { |
b1c2857d2e97
Tests: basic worker_shutdown_timeout test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
36 } |
b1c2857d2e97
Tests: basic worker_shutdown_timeout test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
37 |
b1c2857d2e97
Tests: basic worker_shutdown_timeout test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
38 http { |
b1c2857d2e97
Tests: basic worker_shutdown_timeout test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
39 %%TEST_GLOBALS_HTTP%% |
b1c2857d2e97
Tests: basic worker_shutdown_timeout test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
40 |
b1c2857d2e97
Tests: basic worker_shutdown_timeout test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
41 server { |
b1c2857d2e97
Tests: basic worker_shutdown_timeout test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
42 listen 127.0.0.1:8080; |
b1c2857d2e97
Tests: basic worker_shutdown_timeout test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
43 server_name localhost; |
b1c2857d2e97
Tests: basic worker_shutdown_timeout test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
44 |
b1c2857d2e97
Tests: basic worker_shutdown_timeout test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
45 location / { } |
b1c2857d2e97
Tests: basic worker_shutdown_timeout test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
46 } |
b1c2857d2e97
Tests: basic worker_shutdown_timeout test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
47 } |
b1c2857d2e97
Tests: basic worker_shutdown_timeout test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
48 |
b1c2857d2e97
Tests: basic worker_shutdown_timeout test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
49 EOF |
b1c2857d2e97
Tests: basic worker_shutdown_timeout test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
50 |
1251
766bcbb632ee
Tests: removed TODO and try_run() checks for legacy versions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1206
diff
changeset
|
51 $t->run()->plan(1); |
1149
b1c2857d2e97
Tests: basic worker_shutdown_timeout test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
52 |
b1c2857d2e97
Tests: basic worker_shutdown_timeout test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
53 ############################################################################### |
b1c2857d2e97
Tests: basic worker_shutdown_timeout test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
54 |
b1c2857d2e97
Tests: basic worker_shutdown_timeout test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
55 my $s = http('', start => 1); |
b1c2857d2e97
Tests: basic worker_shutdown_timeout test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
56 |
1162
feb91ae3fca3
Tests: reduced race in worker_shutdown_timeout test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1160
diff
changeset
|
57 select undef, undef, undef, 0.2; |
feb91ae3fca3
Tests: reduced race in worker_shutdown_timeout test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1160
diff
changeset
|
58 |
1206
c99c1f43cb15
Tests: reload() introduced in Test::Nginx.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1162
diff
changeset
|
59 $t->reload(); |
1160
4ed2226d47de
Tests: increased read timeout in worker_shutdown_timeout test.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1157
diff
changeset
|
60 |
4ed2226d47de
Tests: increased read timeout in worker_shutdown_timeout test.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1157
diff
changeset
|
61 if (IO::Select->new($s)->can_read(5)) { |
4ed2226d47de
Tests: increased read timeout in worker_shutdown_timeout test.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1157
diff
changeset
|
62 Test::Nginx::log_core('||', "select: can_read"); |
4ed2226d47de
Tests: increased read timeout in worker_shutdown_timeout test.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1157
diff
changeset
|
63 } |
1149
b1c2857d2e97
Tests: basic worker_shutdown_timeout test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
64 |
b1c2857d2e97
Tests: basic worker_shutdown_timeout test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
65 is(http_get('/', socket => $s) || '', '', 'worker_shutdown_timeout'); |
b1c2857d2e97
Tests: basic worker_shutdown_timeout test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
66 |
b1c2857d2e97
Tests: basic worker_shutdown_timeout test.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
67 ############################################################################### |