Mercurial > hg > nginx-tests
comparison binary_upgrade.t @ 1573:d7e83ce613c2
Tests: unix sockets removal tests on master process exit.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Tue, 02 Jun 2020 14:30:27 +0300 |
parents | fe60c3959069 |
children | 5ac6efbe5552 |
comparison
equal
deleted
inserted
replaced
1572:f5a3b70c0f2f | 1573:d7e83ce613c2 |
---|---|
23 select STDOUT; $| = 1; | 23 select STDOUT; $| = 1; |
24 | 24 |
25 plan(skip_all => 'can leave orphaned process group') | 25 plan(skip_all => 'can leave orphaned process group') |
26 unless $ENV{TEST_NGINX_UNSAFE}; | 26 unless $ENV{TEST_NGINX_UNSAFE}; |
27 | 27 |
28 my $t = Test::Nginx->new()->plan(2)->write_file_expand('nginx.conf', <<'EOF'); | 28 my $t = Test::Nginx->new(qr/http unix/)->plan(4) |
29 ->write_file_expand('nginx.conf', <<'EOF'); | |
29 | 30 |
30 %%TEST_GLOBALS%% | 31 %%TEST_GLOBALS%% |
31 | 32 |
32 events { | 33 events { |
33 } | 34 } |
34 | 35 |
36 http { | |
37 %%TEST_GLOBALS_HTTP%% | |
38 | |
39 server { | |
40 listen unix:%%TESTDIR%%/unix.sock; | |
41 server_name localhost; | |
42 } | |
43 } | |
44 | |
35 EOF | 45 EOF |
46 | |
47 my $d = $t->testdir(); | |
36 | 48 |
37 $t->run(); | 49 $t->run(); |
38 | 50 |
39 ############################################################################### | 51 ############################################################################### |
40 | 52 |
42 ok($pid, 'master pid'); | 54 ok($pid, 'master pid'); |
43 | 55 |
44 kill 'USR2', $pid; | 56 kill 'USR2', $pid; |
45 | 57 |
46 for (1 .. 30) { | 58 for (1 .. 30) { |
47 last if -e $t->testdir() . '/nginx.pid' | 59 last if -e "$d/nginx.pid" && -e "$d/nginx.pid.oldbin"; |
48 && -e $t->testdir() . '/nginx.pid.oldbin'; | |
49 select undef, undef, undef, 0.2 | 60 select undef, undef, undef, 0.2 |
50 } | 61 } |
51 | 62 |
52 isnt($t->read_file('nginx.pid'), $pid, 'master pid changed'); | 63 isnt($t->read_file('nginx.pid'), $pid, 'master pid changed'); |
53 | 64 |
54 kill 'QUIT', $pid; | 65 kill 'QUIT', $pid; |
55 | 66 |
67 for (1 .. 30) { | |
68 last if ! -e "$d/nginx.pid.oldbin"; | |
69 select undef, undef, undef, 0.2 | |
70 } | |
71 | |
72 ok(-e "$d/unix.sock", 'unix socket exists on old master shutdown'); | |
73 | |
74 # unix socket on new master termination | |
75 | |
76 $pid = $t->read_file('nginx.pid'); | |
77 | |
78 kill 'USR2', $pid; | |
79 | |
80 for (1 .. 30) { | |
81 last if -e "$d/nginx.pid" && -e "$d/nginx.pid.oldbin"; | |
82 select undef, undef, undef, 0.2 | |
83 } | |
84 | |
85 kill 'TERM', $t->read_file('nginx.pid'); | |
86 | |
87 for (1 .. 30) { | |
88 last if ! -e "$d/nginx.pid.oldbin"; | |
89 select undef, undef, undef, 0.2 | |
90 } | |
91 | |
92 TODO: { | |
93 $TODO = 'not yet' unless $t->has_version('1.19.1'); | |
94 | |
95 ok(-e "$d/unix.sock", 'unix socket exists on new master termination'); | |
96 | |
97 } | |
98 | |
56 ############################################################################### | 99 ############################################################################### |