Mercurial > hg > nginx-tests
annotate binary_upgrade.t @ 1606:e4e0695552ed
Tests: fixed stream_proxy_ssl_conf_command.t.
The stream_proxy_ssl_conf_command.t test used stream return module
to return the response. Since this ignores actual request, but the
perl test code used http_get(). This might result in the request being
sent after the response is returned and the connection closed by the server,
resulting in RST being generated and no response seen by the client at all.
Fix is to use "stream(...)->read()" instead of http_get(), so
no request is sent at all, eliminating possibility of RST being
generated.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Tue, 10 Nov 2020 05:03:29 +0300 |
parents | d7e83ce613c2 |
children | 5ac6efbe5552 |
rev | line source |
---|---|
1254 | 1 #!/usr/bin/perl |
2 | |
3 # (C) Sergey Kandaurov | |
4 # (C) Nginx, Inc. | |
5 | |
6 # Tests for binary upgrade. | |
7 | |
8 ############################################################################### | |
9 | |
10 use warnings; | |
11 use strict; | |
12 | |
13 use Test::More; | |
14 | |
15 BEGIN { use FindBin; chdir($FindBin::Bin); } | |
16 | |
17 use lib 'lib'; | |
18 use Test::Nginx; | |
19 | |
20 ############################################################################### | |
21 | |
22 select STDERR; $| = 1; | |
23 select STDOUT; $| = 1; | |
24 | |
25 plan(skip_all => 'can leave orphaned process group') | |
26 unless $ENV{TEST_NGINX_UNSAFE}; | |
27 | |
1573
d7e83ce613c2
Tests: unix sockets removal tests on master process exit.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1332
diff
changeset
|
28 my $t = Test::Nginx->new(qr/http unix/)->plan(4) |
d7e83ce613c2
Tests: unix sockets removal tests on master process exit.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1332
diff
changeset
|
29 ->write_file_expand('nginx.conf', <<'EOF'); |
1254 | 30 |
31 %%TEST_GLOBALS%% | |
32 | |
33 events { | |
34 } | |
35 | |
1573
d7e83ce613c2
Tests: unix sockets removal tests on master process exit.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1332
diff
changeset
|
36 http { |
d7e83ce613c2
Tests: unix sockets removal tests on master process exit.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1332
diff
changeset
|
37 %%TEST_GLOBALS_HTTP%% |
d7e83ce613c2
Tests: unix sockets removal tests on master process exit.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1332
diff
changeset
|
38 |
d7e83ce613c2
Tests: unix sockets removal tests on master process exit.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1332
diff
changeset
|
39 server { |
d7e83ce613c2
Tests: unix sockets removal tests on master process exit.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1332
diff
changeset
|
40 listen unix:%%TESTDIR%%/unix.sock; |
d7e83ce613c2
Tests: unix sockets removal tests on master process exit.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1332
diff
changeset
|
41 server_name localhost; |
d7e83ce613c2
Tests: unix sockets removal tests on master process exit.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1332
diff
changeset
|
42 } |
d7e83ce613c2
Tests: unix sockets removal tests on master process exit.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1332
diff
changeset
|
43 } |
d7e83ce613c2
Tests: unix sockets removal tests on master process exit.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1332
diff
changeset
|
44 |
1254 | 45 EOF |
46 | |
1573
d7e83ce613c2
Tests: unix sockets removal tests on master process exit.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1332
diff
changeset
|
47 my $d = $t->testdir(); |
d7e83ce613c2
Tests: unix sockets removal tests on master process exit.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1332
diff
changeset
|
48 |
1254 | 49 $t->run(); |
50 | |
51 ############################################################################### | |
52 | |
53 my $pid = $t->read_file('nginx.pid'); | |
54 ok($pid, 'master pid'); | |
55 | |
56 kill 'USR2', $pid; | |
57 | |
1332
fe60c3959069
Tests: adjusted binary_upgrade.t for instrumented binaries.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1288
diff
changeset
|
58 for (1 .. 30) { |
1573
d7e83ce613c2
Tests: unix sockets removal tests on master process exit.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1332
diff
changeset
|
59 last if -e "$d/nginx.pid" && -e "$d/nginx.pid.oldbin"; |
1254 | 60 select undef, undef, undef, 0.2 |
61 } | |
62 | |
63 isnt($t->read_file('nginx.pid'), $pid, 'master pid changed'); | |
64 | |
65 kill 'QUIT', $pid; | |
66 | |
1573
d7e83ce613c2
Tests: unix sockets removal tests on master process exit.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1332
diff
changeset
|
67 for (1 .. 30) { |
d7e83ce613c2
Tests: unix sockets removal tests on master process exit.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1332
diff
changeset
|
68 last if ! -e "$d/nginx.pid.oldbin"; |
d7e83ce613c2
Tests: unix sockets removal tests on master process exit.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1332
diff
changeset
|
69 select undef, undef, undef, 0.2 |
d7e83ce613c2
Tests: unix sockets removal tests on master process exit.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1332
diff
changeset
|
70 } |
d7e83ce613c2
Tests: unix sockets removal tests on master process exit.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1332
diff
changeset
|
71 |
d7e83ce613c2
Tests: unix sockets removal tests on master process exit.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1332
diff
changeset
|
72 ok(-e "$d/unix.sock", 'unix socket exists on old master shutdown'); |
d7e83ce613c2
Tests: unix sockets removal tests on master process exit.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1332
diff
changeset
|
73 |
d7e83ce613c2
Tests: unix sockets removal tests on master process exit.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1332
diff
changeset
|
74 # unix socket on new master termination |
d7e83ce613c2
Tests: unix sockets removal tests on master process exit.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1332
diff
changeset
|
75 |
d7e83ce613c2
Tests: unix sockets removal tests on master process exit.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1332
diff
changeset
|
76 $pid = $t->read_file('nginx.pid'); |
d7e83ce613c2
Tests: unix sockets removal tests on master process exit.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1332
diff
changeset
|
77 |
d7e83ce613c2
Tests: unix sockets removal tests on master process exit.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1332
diff
changeset
|
78 kill 'USR2', $pid; |
d7e83ce613c2
Tests: unix sockets removal tests on master process exit.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1332
diff
changeset
|
79 |
d7e83ce613c2
Tests: unix sockets removal tests on master process exit.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1332
diff
changeset
|
80 for (1 .. 30) { |
d7e83ce613c2
Tests: unix sockets removal tests on master process exit.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1332
diff
changeset
|
81 last if -e "$d/nginx.pid" && -e "$d/nginx.pid.oldbin"; |
d7e83ce613c2
Tests: unix sockets removal tests on master process exit.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1332
diff
changeset
|
82 select undef, undef, undef, 0.2 |
d7e83ce613c2
Tests: unix sockets removal tests on master process exit.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1332
diff
changeset
|
83 } |
d7e83ce613c2
Tests: unix sockets removal tests on master process exit.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1332
diff
changeset
|
84 |
d7e83ce613c2
Tests: unix sockets removal tests on master process exit.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1332
diff
changeset
|
85 kill 'TERM', $t->read_file('nginx.pid'); |
d7e83ce613c2
Tests: unix sockets removal tests on master process exit.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1332
diff
changeset
|
86 |
d7e83ce613c2
Tests: unix sockets removal tests on master process exit.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1332
diff
changeset
|
87 for (1 .. 30) { |
d7e83ce613c2
Tests: unix sockets removal tests on master process exit.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1332
diff
changeset
|
88 last if ! -e "$d/nginx.pid.oldbin"; |
d7e83ce613c2
Tests: unix sockets removal tests on master process exit.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1332
diff
changeset
|
89 select undef, undef, undef, 0.2 |
d7e83ce613c2
Tests: unix sockets removal tests on master process exit.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1332
diff
changeset
|
90 } |
d7e83ce613c2
Tests: unix sockets removal tests on master process exit.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1332
diff
changeset
|
91 |
d7e83ce613c2
Tests: unix sockets removal tests on master process exit.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1332
diff
changeset
|
92 TODO: { |
d7e83ce613c2
Tests: unix sockets removal tests on master process exit.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1332
diff
changeset
|
93 $TODO = 'not yet' unless $t->has_version('1.19.1'); |
d7e83ce613c2
Tests: unix sockets removal tests on master process exit.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1332
diff
changeset
|
94 |
d7e83ce613c2
Tests: unix sockets removal tests on master process exit.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1332
diff
changeset
|
95 ok(-e "$d/unix.sock", 'unix socket exists on new master termination'); |
d7e83ce613c2
Tests: unix sockets removal tests on master process exit.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1332
diff
changeset
|
96 |
d7e83ce613c2
Tests: unix sockets removal tests on master process exit.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1332
diff
changeset
|
97 } |
d7e83ce613c2
Tests: unix sockets removal tests on master process exit.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1332
diff
changeset
|
98 |
1254 | 99 ############################################################################### |