Mercurial > hg > nginx-tests
annotate worker_shutdown_timeout_mail.t @ 1477:8b122b35703b
Tests: fixed session reuse tests in ssl_certificate.t with TLSv1.3.
Previously, session data was retrieved too early, before server passed
application data, which usually means NewSessionTicket is not yet sent.
The fix is to ask server for application data, then retrieve a session.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Mon, 20 May 2019 16:00:40 +0300 |
parents | 97c8280de681 |
children | 74986ebee2fd |
rev | line source |
---|---|
1244
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
2 |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
3 # (C) Sergey Kandaurov |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
4 # (C) Nginx, Inc. |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
5 |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
6 # Tests for worker_shutdown_timeout directive within the mail module. |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
7 |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
8 ############################################################################### |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
9 |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
10 use warnings; |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
11 use strict; |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
12 |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
13 use Test::More; |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
14 |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
15 use MIME::Base64; |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
16 |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
17 BEGIN { use FindBin; chdir($FindBin::Bin); } |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
18 |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
19 use lib 'lib'; |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
20 use Test::Nginx; |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
21 use Test::Nginx::SMTP; |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
22 |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
23 ############################################################################### |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
24 |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
25 select STDERR; $| = 1; |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
26 select STDOUT; $| = 1; |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
27 |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
28 local $SIG{PIPE} = 'IGNORE'; |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
29 |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
30 my $t = Test::Nginx->new()->has(qw/mail imap http rewrite/)->plan(4) |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
31 ->write_file_expand('nginx.conf', <<'EOF'); |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
32 |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
33 %%TEST_GLOBALS%% |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
34 |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
35 daemon off; |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
36 worker_shutdown_timeout 10ms; |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
37 |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
38 events { |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
39 } |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
40 |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
41 mail { |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
42 proxy_pass_error_message on; |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
43 auth_http http://127.0.0.1:8080/mail/auth; |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
44 xclient off; |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
45 |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
46 server { |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
47 listen 127.0.0.1:8025; |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
48 protocol smtp; |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
49 } |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
50 } |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
51 |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
52 http { |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
53 %%TEST_GLOBALS_HTTP%% |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
54 |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
55 server { |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
56 listen 127.0.0.1:8080; |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
57 server_name localhost; |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
58 |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
59 location = /mail/auth { |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
60 add_header Auth-Status OK; |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
61 add_header Auth-Server 127.0.0.1; |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
62 add_header Auth-Port %%PORT_8026%%; |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
63 add_header Auth-Wait 1; |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
64 return 204; |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
65 } |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
66 } |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
67 } |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
68 |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
69 EOF |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
70 |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
71 $t->run_daemon(\&Test::Nginx::SMTP::smtp_test_daemon); |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
72 $t->run()->waitforsocket('127.0.0.1:' . port(8026)); |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
73 |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
74 ############################################################################### |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
75 |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
76 my $s = Test::Nginx::SMTP->new(); |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
77 $s->check(qr/^220 /, "greeting"); |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
78 |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
79 $s->send('EHLO example.com'); |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
80 $s->check(qr/^250 /, "ehlo"); |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
81 |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
82 $s->send('AUTH PLAIN ' . encode_base64("\0test\@example.com\0secret", '')); |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
83 $s->authok('auth plain'); |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
84 |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
85 $t->reload(); |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
86 |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
87 ok($s->can_read(), 'mail connection shutdown'); |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
88 |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
89 undef $s; |
1259
caf59f42a3e1
Tests: handled GC deficiency in Perl < 5.22.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1244
diff
changeset
|
90 1; |
1244
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
91 |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
92 ############################################################################### |