Skip to content

Commit 084271b

Browse files
authored
Fix flaky FPM test for bug #77023 (#24999)
The test sent two parallel requests to a pool with a single child and expected the dynamic process manager to spawn a second child. That only happens when the idle server maintenance heartbeat (1s) fires while the child is busy, but the scripts kept it busy for just 300ms each, so the spawn was a matter of luck and the total processes check failed on slow machines. Use a single request that blocks the child for longer than the heartbeat so the spare child is always spawned, and rely on the fact that the blocked child is the oldest idle one and is therefore quit first. One blocked child is enough to verify the SIGKILL fallback. Replace the fixed sleep with log timeouts and poll the status until the spare child is quit.
1 parent 6a1a57d commit 084271b

1 file changed

Lines changed: 15 additions & 9 deletions

File tree

‎sapi/fpm/tests/bug77023-pm-dynamic-blocking-sigquit.phpt‎

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
FPM: Blocked SIGQUIT prevents idle process to be killed
33
--EXTENSIONS--
44
pcntl
5-
--FLAKY--
65
--SKIPIF--
76
<?php
87
include "skipif.inc";
@@ -32,23 +31,30 @@ EOT;
3231
$code = <<<EOT
3332
<?php
3433
pcntl_sigprocmask(SIG_BLOCK, [SIGQUIT, SIGTERM]);
35-
usleep(300000);
34+
usleep(2000000);
3635
EOT;
3736

38-
3937
$tester = new FPM\Tester($cfg, $code);
4038
$tester->start(extensions: ['pcntl']);
4139
$tester->expectLogStartNotices();
42-
$tester->multiRequest(2);
40+
$tester->request()->expectEmptyBody();
4341
$tester->status([
4442
'total processes' => 2,
4543
]);
46-
// wait for process to be killed
47-
sleep(7);
48-
$tester->expectLogWarning('child \\d+ exited on signal 9 \\(SIGKILL\\) after \\d+.\\d+ seconds from start', 'unconfined');
49-
$tester->expectLogNotice('child \\d+ started', 'unconfined');
50-
$tester->expectLogWarning('child \\d+ exited on signal 9 \\(SIGKILL\\) after \\d+.\\d+ seconds from start', 'unconfined');
44+
$tester->expectLogWarning(
45+
'child \\d+ exited on signal 9 \\(SIGKILL\\) after \\d+.\\d+ seconds from start',
46+
'unconfined',
47+
timeoutSeconds: 10
48+
);
5149
$tester->expectLogNotice('child \\d+ started', 'unconfined');
50+
// wait for the remaining spare process to be quit
51+
for ($i = 0; $i < 20; $i++) {
52+
$status = json_decode($tester->request('json', [], '/status')->getBody('application/json'), true);
53+
if (($status['total processes'] ?? null) === 1) {
54+
break;
55+
}
56+
usleep(500000);
57+
}
5258
$tester->status([
5359
'total processes' => 1,
5460
]);

0 commit comments

Comments
 (0)