2 Star 0 Fork 0

mirrors_nginx/nginx-tests

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
binary_upgrade.t 1.77 KB
一键复制 编辑 原始数据 按行查看 历史
#!/usr/bin/perl
# (C) Sergey Kandaurov
# (C) Nginx, Inc.
# Tests for binary upgrade.
###############################################################################
use warnings;
use strict;
use Test::More;
BEGIN { use FindBin; chdir($FindBin::Bin); }
use lib 'lib';
use Test::Nginx;
###############################################################################
select STDERR; $| = 1;
select STDOUT; $| = 1;
plan(skip_all => 'can leave orphaned process group')
unless $ENV{TEST_NGINX_UNSAFE};
my $t = Test::Nginx->new(qr/http unix/)->plan(4)
->write_file_expand('nginx.conf', <<'EOF');
%%TEST_GLOBALS%%
events {
}
http {
%%TEST_GLOBALS_HTTP%%
server {
listen unix:%%TESTDIR%%/unix.sock;
server_name localhost;
}
}
EOF
my $d = $t->testdir();
$t->run();
###############################################################################
my $pid = $t->read_file('nginx.pid');
ok($pid, 'master pid');
kill 'USR2', $pid;
for (1 .. 30) {
last if -e "$d/nginx.pid" && -e "$d/nginx.pid.oldbin";
select undef, undef, undef, 0.2
}
isnt($t->read_file('nginx.pid'), $pid, 'master pid changed');
kill 'QUIT', $pid;
for (1 .. 30) {
last if ! -e "$d/nginx.pid.oldbin";
select undef, undef, undef, 0.2
}
ok(-e "$d/unix.sock", 'unix socket exists on old master shutdown');
# unix socket on new master termination
$pid = $t->read_file('nginx.pid');
kill 'USR2', $pid;
for (1 .. 30) {
last if -e "$d/nginx.pid" && -e "$d/nginx.pid.oldbin";
select undef, undef, undef, 0.2
}
kill 'TERM', $t->read_file('nginx.pid');
for (1 .. 30) {
last if ! -e "$d/nginx.pid.oldbin";
select undef, undef, undef, 0.2
}
ok(-e "$d/unix.sock", 'unix socket exists on new master termination');
###############################################################################
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mirrors_nginx/nginx-tests.git
git@gitee.com:mirrors_nginx/nginx-tests.git
mirrors_nginx
nginx-tests
nginx-tests
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385