diff options
author | Remi Collet <remi@php.net> | 2014-11-18 11:08:49 +0100 |
---|---|---|
committer | Remi Collet <remi@php.net> | 2014-11-18 11:08:49 +0100 |
commit | 51394dff3f8d55fd40823e1841a97e631f4dfec5 (patch) | |
tree | 94887b686584bbaee0796b8f506ae79cea6a734b | |
parent | 8c0cc49b9bf714a307f84708ec22fceab397c00c (diff) | |
download | php-git-51394dff3f8d55fd40823e1841a97e631f4dfec5.tar.gz |
Add test for bug #68442
Add another helper function fpm_display_log
Restore change from c996a989 badly reverted in 8c0cc49
-rw-r--r-- | sapi/fpm/tests/002.phpt | 5 | ||||
-rw-r--r-- | sapi/fpm/tests/003.phpt | 5 | ||||
-rw-r--r-- | sapi/fpm/tests/012.phpt | 79 | ||||
-rw-r--r-- | sapi/fpm/tests/include.inc | 10 |
4 files changed, 95 insertions, 4 deletions
diff --git a/sapi/fpm/tests/002.phpt b/sapi/fpm/tests/002.phpt index 2ef6cedc38..ce878661ea 100644 --- a/sapi/fpm/tests/002.phpt +++ b/sapi/fpm/tests/002.phpt @@ -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) { diff --git a/sapi/fpm/tests/003.phpt b/sapi/fpm/tests/003.phpt index 389cb2401e..0ce1bd2828 100644 --- a/sapi/fpm/tests/003.phpt +++ b/sapi/fpm/tests/003.phpt @@ -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) { diff --git a/sapi/fpm/tests/012.phpt b/sapi/fpm/tests/012.phpt new file mode 100644 index 0000000000..d96c53081c --- /dev/null +++ b/sapi/fpm/tests/012.phpt @@ -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); +?> diff --git a/sapi/fpm/tests/include.inc b/sapi/fpm/tests/include.inc index 5d01ae693d..b195fad507 100644 --- a/sapi/fpm/tests/include.inc +++ b/sapi/fpm/tests/include.inc @@ -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); |