Mercurial > hg > nginx-tests
annotate worker_shutdown_timeout_mail.t @ 1905:f35824e75b66
Tests: fixed reading QUIC streams on Perl < 5.24.
The parse_stream() routine has had a missing explicit return if there were no
streams received. In Perl < 5.24 this used to return no value, or an empty
array in the list context. In modern Perl this returns an empty value, or an
array of 1 element, which made the check for last index of the returned array
work rather by accident.
The fix is to return explicitly and to check the array size in callers instead.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Tue, 06 Jun 2023 18:50:07 +0400 |
parents | 74986ebee2fd |
children |
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; |
1679
74986ebee2fd
Tests: added proxy_timeout in mail tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1381
diff
changeset
|
43 proxy_timeout 15s; |
1244
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
44 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
|
45 xclient off; |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
46 |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
47 server { |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
48 listen 127.0.0.1:8025; |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
49 protocol smtp; |
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 |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
53 http { |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
54 %%TEST_GLOBALS_HTTP%% |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
55 |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
56 server { |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
57 listen 127.0.0.1:8080; |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
58 server_name localhost; |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
59 |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
60 location = /mail/auth { |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
61 add_header Auth-Status OK; |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
62 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
|
63 add_header Auth-Port %%PORT_8026%%; |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
64 add_header Auth-Wait 1; |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
65 return 204; |
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 |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
70 EOF |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
71 |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
72 $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
|
73 $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
|
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 |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
77 my $s = Test::Nginx::SMTP->new(); |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
78 $s->check(qr/^220 /, "greeting"); |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
79 |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
80 $s->send('EHLO example.com'); |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
81 $s->check(qr/^250 /, "ehlo"); |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
82 |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
83 $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
|
84 $s->authok('auth plain'); |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
85 |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
86 $t->reload(); |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
87 |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
88 ok($s->can_read(), 'mail connection shutdown'); |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
89 |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
90 undef $s; |
1259
caf59f42a3e1
Tests: handled GC deficiency in Perl < 5.22.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1244
diff
changeset
|
91 1; |
1244
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
92 |
575d39cc0e35
Tests: worker_shutdown_timeout within the mail module.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
93 ############################################################################### |