mirror of
https://github.com/php/php-src.git
synced 2024-09-22 02:17:32 +00:00
Add test for bug #68442
Add another helper function fpm_display_log Restore change fromc996a989
badly reverted in8c0cc49
This commit is contained in:
parent
8c0cc49b9b
commit
51394dff3f
@ -8,12 +8,13 @@ FPM: Startup and connect
|
||||
include "include.inc";
|
||||
|
||||
$logfile = dirname(__FILE__).'/php-fpm.log.tmp';
|
||||
$port = 9000+PHP_INT_SIZE;
|
||||
|
||||
$cfg = <<<EOT
|
||||
[global]
|
||||
error_log = $logfile
|
||||
[unconfined]
|
||||
listen = 127.0.0.1:9000
|
||||
listen = 127.0.0.1:$port
|
||||
pm = dynamic
|
||||
pm.max_children = 5
|
||||
pm.start_servers = 2
|
||||
@ -26,7 +27,7 @@ if (is_resource($fpm)) {
|
||||
var_dump(fgets($tail));
|
||||
var_dump(fgets($tail));
|
||||
$i = 0;
|
||||
while (($i++ < 30) && !($fp = @fsockopen('127.0.0.1', 9000))) {
|
||||
while (($i++ < 30) && !($fp = @fsockopen('127.0.0.1', $port))) {
|
||||
usleep(10000);
|
||||
}
|
||||
if ($fp) {
|
||||
|
@ -8,12 +8,13 @@ FPM: Test IPv6 support
|
||||
include "include.inc";
|
||||
|
||||
$logfile = dirname(__FILE__).'/php-fpm.log.tmp';
|
||||
$port = 9000+PHP_INT_SIZE;
|
||||
|
||||
$cfg = <<<EOT
|
||||
[global]
|
||||
error_log = $logfile
|
||||
[unconfined]
|
||||
listen = [::1]:9000
|
||||
listen = [::1]:$port
|
||||
pm = dynamic
|
||||
pm.max_children = 5
|
||||
pm.start_servers = 2
|
||||
@ -26,7 +27,7 @@ if (is_resource($fpm)) {
|
||||
var_dump(fgets($tail));
|
||||
var_dump(fgets($tail));
|
||||
$i = 0;
|
||||
while (($i++ < 30) && !($fp = fsockopen('[::1]', 9000))) {
|
||||
while (($i++ < 30) && !($fp = fsockopen('[::1]', $port))) {
|
||||
usleep(10000);
|
||||
}
|
||||
if ($fp) {
|
||||
|
79
sapi/fpm/tests/012.phpt
Normal file
79
sapi/fpm/tests/012.phpt
Normal file
@ -0,0 +1,79 @@
|
||||
--TEST--
|
||||
FPM: Test reload configuration (bug #68442)
|
||||
--SKIPIF--
|
||||
<?php include "skipif.inc"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
include "include.inc";
|
||||
|
||||
$logfile = dirname(__FILE__).'/php-fpm.log.tmp';
|
||||
$pidfile = dirname(__FILE__).'/php-fpm.pid';
|
||||
$port = 9000+PHP_INT_SIZE;
|
||||
|
||||
$cfg = <<<EOT
|
||||
[global]
|
||||
error_log = $logfile
|
||||
pid = $pidfile
|
||||
[unconfined]
|
||||
listen = 127.0.0.1:$port
|
||||
ping.path = /ping
|
||||
ping.response = pong
|
||||
pm = dynamic
|
||||
pm.max_children = 5
|
||||
pm.start_servers = 2
|
||||
pm.min_spare_servers = 1
|
||||
pm.max_spare_servers = 3
|
||||
EOT;
|
||||
|
||||
$fpm = run_fpm($cfg, $tail);
|
||||
if (is_resource($fpm)) {
|
||||
fpm_display_log($tail, 2);
|
||||
try {
|
||||
var_dump(strpos(run_request('127.0.0.1', $port), 'pong'));
|
||||
echo "IPv4 ok\n";
|
||||
} catch (Exception $e) {
|
||||
echo "IPv4 error\n";
|
||||
}
|
||||
|
||||
$pid=file_get_contents($pidfile);
|
||||
if ($pid) {
|
||||
exec("kill -USR2 $pid");
|
||||
} else {
|
||||
die("PID not found\n");
|
||||
}
|
||||
fpm_display_log($tail, 5);
|
||||
|
||||
try {
|
||||
var_dump(strpos(run_request('127.0.0.1', $port), 'pong'));
|
||||
echo "IPv4 ok\n";
|
||||
} catch (Exception $e) {
|
||||
echo "IPv4 error\n";
|
||||
}
|
||||
|
||||
proc_terminate($fpm);
|
||||
stream_get_contents($tail);
|
||||
fclose($tail);
|
||||
proc_close($fpm);
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
[%d-%s-%d %d:%d:%d] NOTICE: fpm is running, pid %d
|
||||
[%d-%s-%d %d:%d:%d] NOTICE: ready to handle connections
|
||||
int(%d)
|
||||
IPv4 ok
|
||||
[%d-%s-%d %d:%d:%d] NOTICE: Reloading in progress ...
|
||||
[%d-%s-%d %d:%d:%d] NOTICE: reloading: %s
|
||||
[%d-%s-%d %d:%d:%d] NOTICE: using inherited socket fd=%d, "127.0.0.1:%d"
|
||||
[%d-%s-%d %d:%d:%d] NOTICE: fpm is running, pid %d
|
||||
[%d-%s-%d %d:%d:%d] NOTICE: ready to handle connections
|
||||
int(%d)
|
||||
IPv4 ok
|
||||
--CLEAN--
|
||||
<?php
|
||||
$logfile = dirname(__FILE__).'/php-fpm.log.tmp';
|
||||
@unlink($logfile);
|
||||
$pidfile = dirname(__FILE__).'/php-fpm.pid';
|
||||
@unlink($pidfile);
|
||||
?>
|
@ -76,6 +76,16 @@ function run_fpm_till($needle, $config, $max = 10) /* {{{ */
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
function fpm_display_log($tail, $n=1, $ignore='systemd') {
|
||||
while ($n) {
|
||||
$a = fgets($tail);
|
||||
if (empty($ignore) || !strpos($a, $ignore)) {
|
||||
echo $a;
|
||||
$n--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function run_request($host, $port, $uri='/ping', $query='') {
|
||||
require_once 'fcgi.inc';
|
||||
$client = new Adoy\FastCGI\Client($host, $port);
|
||||
|
Loading…
Reference in New Issue
Block a user