Skip to content

Commit 2f9f409

Browse files
plmnikulinbukka
authored andcommitted
Add (slow) test for fpm concurrent reloads #74083
1 parent ae5154c commit 2f9f409

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
--TEST--
2+
Concurrent reload signals should not kill PHP-FPM master process. (Bug: #74083)
3+
--SKIPIF--
4+
<?php
5+
if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
6+
?>
7+
--FILE--
8+
<?php
9+
10+
require_once "tester.inc";
11+
12+
$cfg = <<<EOT
13+
[global]
14+
error_log = {{FILE:LOG}}
15+
pid = {{FILE:PID}}
16+
process_control_timeout=1
17+
[unconfined]
18+
listen = {{ADDR}}
19+
ping.path = /ping
20+
ping.response = pong
21+
pm = dynamic
22+
pm.max_children = 5
23+
pm.start_servers = 1
24+
pm.min_spare_servers = 1
25+
pm.max_spare_servers = 1
26+
EOT;
27+
28+
$code = <<<EOT
29+
<?php
30+
/* empty */
31+
EOT;
32+
33+
$tester = new FPM\Tester($cfg, $code);
34+
$tester->start();
35+
$tester->expectLogStartNotices();
36+
$tester->ping('{{ADDR}}');
37+
38+
/* Vary interval between concurrent reload requests
39+
since performance of test instance is not known in advance */
40+
$max_interval = 25000;
41+
$step = 1000;
42+
$pid = $tester->getPid();
43+
for ($interval = 0; $interval < $max_interval; $interval += $step) {
44+
exec("kill -USR2 $pid", $out, $killExitCode);
45+
if ($killExitCode) {
46+
echo "ERROR: master process is dead\n";
47+
break;
48+
}
49+
usleep($interval);
50+
}
51+
echo "Reached interval $interval us with $step us steps\n";
52+
$tester->expectLogNotice('Reloading in progress ...');
53+
/* Consume mix of 'Reloading in progress ...' and 'reloading: .*' */
54+
$tester->getLogLines(2000);
55+
56+
$tester->signal('USR2');
57+
$tester->expectLogNotice('Reloading in progress ...');
58+
$tester->expectLogNotice('reloading: .*');
59+
$tester->expectLogNotice('using inherited socket fd=\d+, "127.0.0.1:\d+"');
60+
$tester->expectLogStartNotices();
61+
$tester->ping('{{ADDR}}');
62+
63+
$tester->terminate();
64+
$tester->expectLogTerminatingNotices();
65+
$tester->close();
66+
67+
?>
68+
Done
69+
--EXPECT--
70+
Reached interval 25000 us with 1000 us steps
71+
Done
72+
--CLEAN--
73+
<?php
74+
require_once "tester.inc";
75+
FPM\Tester::clean();
76+
?>

0 commit comments

Comments
 (0)