mirror of
https://github.com/php/php-src.git
synced 2024-11-23 09:54:15 +08:00
Port FPM test 023 and 024 to the new FPM testing
This commit is contained in:
parent
bc58ba750f
commit
dd622f9ca9
@ -1,57 +0,0 @@
|
||||
--TEST--
|
||||
FPM: Test already bound address
|
||||
--SKIPIF--
|
||||
<?php include "skipif.inc"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
include "include.inc";
|
||||
|
||||
$logfile = dirname(__FILE__).'/php-fpm.log.tmp';
|
||||
$port = 9000+PHP_INT_SIZE;
|
||||
|
||||
$cfg = <<<EOT
|
||||
[global]
|
||||
log_level = debug
|
||||
error_log = $logfile
|
||||
[unconfined]
|
||||
listen = $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;
|
||||
|
||||
// Occupy our port and let things fail
|
||||
$busy = stream_socket_server("tcp://[::]:$port");
|
||||
|
||||
$fpm = run_fpm($cfg, $tail);
|
||||
if (is_resource($fpm)) {
|
||||
/* Expect two specific lines of log output and show them
|
||||
* If we get any different number of those patterns, display whole log
|
||||
*/
|
||||
$out = $all = '';
|
||||
$count = 0;
|
||||
while (!feof($tail)) {
|
||||
$line = fgets($tail);
|
||||
$all .= $line;
|
||||
if ((false !== strpos($line, 'retrying with 0.0.0.0')) ||
|
||||
(false !== strpos($line, 'unable to bind'))) {
|
||||
$out .= $line;
|
||||
++$count;
|
||||
}
|
||||
}
|
||||
echo ($count == 2) ? $out : $all;
|
||||
}
|
||||
?>
|
||||
--EXPECTF--
|
||||
[%d-%s-%d %d:%d:%f] NOTICE: pid %d, fpm_socket_af_inet_listening_socket(), line %d: Failed implicitly binding to ::, retrying with 0.0.0.0
|
||||
[%d-%s-%d %d:%d:%f] ERROR: pid %d, fpm_sockets_new_listening_socket(), line %d: unable to bind listening socket for address '%d': %s
|
||||
--CLEAN--
|
||||
<?php
|
||||
$logfile = dirname(__FILE__).'/php-fpm.log.tmp';
|
||||
@unlink($logfile);
|
||||
?>
|
@ -1,82 +0,0 @@
|
||||
--TEST--
|
||||
FPM: bug #75212 php_value acts like php_admin_value
|
||||
--SKIPIF--
|
||||
<?php include "skipif.inc"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
include "include.inc";
|
||||
|
||||
$logfile = __DIR__.'/php-fpm.log.tmp';
|
||||
$srcfile = __DIR__.'/bug75212.php';
|
||||
$inifile = __DIR__.'/.user.ini';
|
||||
$port = 9000+PHP_INT_SIZE;
|
||||
|
||||
$cfg = <<<EOT
|
||||
[global]
|
||||
error_log = $logfile
|
||||
[unconfined]
|
||||
listen = 127.0.0.1:$port
|
||||
pm = dynamic
|
||||
pm.max_children = 5
|
||||
pm.start_servers = 1
|
||||
pm.min_spare_servers = 1
|
||||
pm.max_spare_servers = 3
|
||||
php_admin_value[memory_limit]=32M
|
||||
php_value[date.timezone]=Europe/London
|
||||
EOT;
|
||||
|
||||
$code = <<<EOT
|
||||
<?php
|
||||
echo "Test Start\n";
|
||||
var_dump(ini_get('memory_limit'), ini_get('date.timezone'));
|
||||
echo "Test End\n";
|
||||
EOT;
|
||||
file_put_contents($srcfile, $code);
|
||||
|
||||
$ini = <<<EOT
|
||||
memory_limit=64M
|
||||
date.timezone=Europe/Paris
|
||||
|
||||
EOT;
|
||||
file_put_contents($inifile, $ini);
|
||||
|
||||
$fpm = run_fpm($cfg, $tail);
|
||||
if (is_resource($fpm)) {
|
||||
fpm_display_log($tail, 2);
|
||||
try {
|
||||
$req = run_request('127.0.0.1', $port, $srcfile);
|
||||
echo strstr($req, "Test Start");
|
||||
echo "Request ok\n";
|
||||
} catch (Exception $e) {
|
||||
echo "Request error\n";
|
||||
}
|
||||
proc_terminate($fpm);
|
||||
fpm_display_log($tail, -1);
|
||||
fclose($tail);
|
||||
proc_close($fpm);
|
||||
}
|
||||
|
||||
?>
|
||||
Done
|
||||
--EXPECTF--
|
||||
[%s] NOTICE: fpm is running, pid %d
|
||||
[%s] NOTICE: ready to handle connections
|
||||
Test Start
|
||||
string(3) "32M"
|
||||
string(12) "Europe/Paris"
|
||||
Test End
|
||||
|
||||
Request ok
|
||||
[%s] NOTICE: Terminating ...
|
||||
[%s] NOTICE: exiting, bye-bye!
|
||||
Done
|
||||
--CLEAN--
|
||||
<?php
|
||||
$logfile = __DIR__.'/php-fpm.log.tmp';
|
||||
$srcfile = __DIR__.'/bug75212.php';
|
||||
$inifile = __DIR__.'/.user.ini';
|
||||
@unlink($logfile);
|
||||
@unlink($srcfile);
|
||||
@unlink($inifile);
|
||||
?>
|
57
sapi/fpm/tests/bug75212-php-value-in-user-ini.phpt
Normal file
57
sapi/fpm/tests/bug75212-php-value-in-user-ini.phpt
Normal file
@ -0,0 +1,57 @@
|
||||
--TEST--
|
||||
FPM: bug75212 - php_value acts like php_admin_value
|
||||
--SKIPIF--
|
||||
<?php include "skipif.inc"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once "tester.inc";
|
||||
|
||||
$cfg = <<<EOT
|
||||
[global]
|
||||
error_log = {{FILE:LOG}}
|
||||
[unconfined]
|
||||
listen = {{ADDR}}
|
||||
pm = dynamic
|
||||
pm.max_children = 5
|
||||
pm.start_servers = 1
|
||||
pm.min_spare_servers = 1
|
||||
pm.max_spare_servers = 3
|
||||
php_admin_value[memory_limit]=32M
|
||||
php_value[date.timezone]=Europe/London
|
||||
EOT;
|
||||
|
||||
$code = <<<EOT
|
||||
<?php
|
||||
echo "Test Start\n";
|
||||
var_dump(ini_get('memory_limit'), ini_get('date.timezone'));
|
||||
echo "Test End\n";
|
||||
EOT;
|
||||
|
||||
$ini = <<<EOT
|
||||
memory_limit=64M
|
||||
date.timezone=Europe/Paris
|
||||
EOT;
|
||||
|
||||
$tester = new FPM\Tester($cfg, $code);
|
||||
$tester->setUserIni($ini);
|
||||
$tester->start();
|
||||
$tester->expectLogStartNotices();
|
||||
$tester->request()->expectBody([
|
||||
'Test Start',
|
||||
'string(3) "32M"',
|
||||
'string(12) "Europe/Paris"',
|
||||
'Test End'
|
||||
]);
|
||||
$tester->terminate();
|
||||
$tester->close();
|
||||
|
||||
?>
|
||||
Done
|
||||
--EXPECT--
|
||||
Done
|
||||
--CLEAN--
|
||||
<?php
|
||||
require_once "tester.inc";
|
||||
FPM\Tester::clean();
|
||||
?>
|
43
sapi/fpm/tests/socket-ipv4-fallback.phpt
Normal file
43
sapi/fpm/tests/socket-ipv4-fallback.phpt
Normal file
@ -0,0 +1,43 @@
|
||||
--TEST--
|
||||
FPM: Socket port connection falls back to IPv4
|
||||
--SKIPIF--
|
||||
<?php
|
||||
include "skipif.inc";
|
||||
FPM\Tester::skipIfIPv6IsNotSupported();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once "tester.inc";
|
||||
|
||||
$cfg = <<<EOT
|
||||
[global]
|
||||
error_log = {{FILE:LOG}}
|
||||
[unconfined]
|
||||
listen = {{PORT}}
|
||||
pm = dynamic
|
||||
pm.max_children = 5
|
||||
pm.start_servers = 2
|
||||
pm.min_spare_servers = 1
|
||||
pm.max_spare_servers = 3
|
||||
EOT;
|
||||
|
||||
$tester = new FPM\Tester($cfg);
|
||||
$port = $tester->getPort();
|
||||
// Occupy our port and let things fail
|
||||
$busy = stream_socket_server("tcp://[::]:$port");
|
||||
$tester->start();
|
||||
$tester->expectLogNotice('Failed implicitly binding to ::, retrying with 0.0.0.0');
|
||||
$tester->expectLogError("unable to bind listening socket for address '$port': " .
|
||||
'Address already in use \(\d+\)');
|
||||
$tester->expectLogError('FPM initialization failed');
|
||||
$tester->close(true);
|
||||
?>
|
||||
Done
|
||||
--EXPECT--
|
||||
Done
|
||||
--CLEAN--
|
||||
<?php
|
||||
require_once "tester.inc";
|
||||
FPM\Tester::clean();
|
||||
?>
|
Loading…
Reference in New Issue
Block a user