com php-src: Migrate fpm_get_status test: sapi/fpm/te sts/025.phpt sapi/fpm/tests/fpm_get_status_basi c.phpt sapi/fpm/tests/response.inc

From: Date: Sat, 07 Jul 2018 11:48:16 +0000
Subject: com php-src: Migrate fpm_get_status test: sapi/fpm/te sts/025.phpt sapi/fpm/tests/fpm_get_status_basi c.phpt sapi/fpm/tests/response.inc
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-102472@lists.php.net to get a copy of this message
Commit: f86f3edeef67ecc10fd6dfeb0b9d28331962c895 Author: Jakub Zelenka <bukka@php.net> Sat, 7 Jul 2018 12:48:16 +0100 Parents: 140def4ac712acac6e2561f65e1b72f8efad8717 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=f86f3edeef67ecc10fd6dfeb0b9d28331962c895 Log: Migrate fpm_get_status test Changed paths: D sapi/fpm/tests/025.phpt A sapi/fpm/tests/fpm_get_status_basic.phpt M sapi/fpm/tests/response.inc Diff: diff --git a/sapi/fpm/tests/025.phpt b/sapi/fpm/tests/025.phpt deleted file mode 100644 index c3bd388..0000000 --- a/sapi/fpm/tests/025.phpt +++ /dev/null @@ -1,132 +0,0 @@ ---TEST-- -FPM: Test fpm_get_status function ---SKIPIF-- -<?php include "skipif.inc"; ?> ---FILE-- -<?php - -include "include.inc"; - -$logfile = __DIR__.'/php-fpm.log.tmp'; -$srcfile = __DIR__.'/php-fpm.tmp.php'; -$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 -EOT; - -$code = <<<EOT -<?php -echo "Test Start\n"; -var_dump(fpm_get_status()); -echo "Test End\n"; -EOT; -file_put_contents($srcfile, $code); - -$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 -array(15) { - ["pool"]=> - string(10) "unconfined" - ["process-manager"]=> - string(7) "dynamic" - ["start-time"]=> - int(%d) - ["start-since"]=> - int(%d) - ["accepted-conn"]=> - int(1) - ["listen-queue"]=> - int(0) - ["max-listen-queue"]=> - int(0) - ["listen-queue-len"]=> - int(128) - ["idle-processes"]=> - int(0) - ["active-processes"]=> - int(1) - ["total-processes"]=> - int(1) - ["max-active-processes"]=> - int(1) - ["max-children-reached"]=> - int(0) - ["slow-requests"]=> - int(0) - ["procs"]=> - array(1) { - [0]=> - array(14) { - ["pid"]=> - int(%d) - ["state"]=> - string(7) "Running" - ["start-time"]=> - int(%d) - ["start-since"]=> - int(%d) - ["requests"]=> - int(1) - ["request-duration"]=> - int(%d) - ["request-method"]=> - string(3) "GET" - ["request-uri"]=> - string(%d) "%s" - ["query-string"]=> - string(0) "" - ["request-length"]=> - int(0) - ["user"]=> - string(1) "-" - ["script"]=> - string(%d) "%s" - ["last-request-cpu"]=> - float(0) - ["last-request-memory"]=> - int(0) - } - } -} -Test End - -Request ok -[%s] NOTICE: Terminating ... -[%s] NOTICE: exiting, bye-bye! -Done ---CLEAN-- -<?php - $logfile = __DIR__.'/php-fpm.log.tmp'; - $srcfile = __DIR__..'/php-fpm.tmp.php'; - @unlink($logfile); - @unlink($srcfile); -?> diff --git a/sapi/fpm/tests/fpm_get_status_basic.phpt b/sapi/fpm/tests/fpm_get_status_basic.phpt new file mode 100644 index 0000000..a53fef2 --- /dev/null +++ b/sapi/fpm/tests/fpm_get_status_basic.phpt @@ -0,0 +1,112 @@ +--TEST-- +FPM: Function fpm_get_status basic test +--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 +EOT; + +$code = <<<EOT +<?php +echo "Test Start\n"; +var_dump(fpm_get_status()); +echo "Test End\n"; +EOT; + +$headers = []; +$tester = new FPM\Tester($cfg, $code); +$tester->start(); +$tester->expectLogStartNotices(); +$tester->request()->printBody(); +$tester->terminate(); +$tester->expectLogTerminatingNotices(); +$tester->close(); + +?> +Done +--EXPECTF-- +Test Start +array(15) { + ["pool"]=> + string(10) "unconfined" + ["process-manager"]=> + string(7) "dynamic" + ["start-time"]=> + int(%d) + ["start-since"]=> + int(%d) + ["accepted-conn"]=> + int(1) + ["listen-queue"]=> + int(0) + ["max-listen-queue"]=> + int(0) + ["listen-queue-len"]=> + int(128) + ["idle-processes"]=> + int(0) + ["active-processes"]=> + int(1) + ["total-processes"]=> + int(1) + ["max-active-processes"]=> + int(1) + ["max-children-reached"]=> + int(0) + ["slow-requests"]=> + int(0) + ["procs"]=> + array(1) { + [0]=> + array(14) { + ["pid"]=> + int(%d) + ["state"]=> + string(7) "Running" + ["start-time"]=> + int(%d) + ["start-since"]=> + int(%d) + ["requests"]=> + int(1) + ["request-duration"]=> + int(%d) + ["request-method"]=> + string(3) "GET" + ["request-uri"]=> + string(%d) "%s" + ["query-string"]=> + string(0) "" + ["request-length"]=> + int(0) + ["user"]=> + string(1) "-" + ["script"]=> + string(%d) "%s" + ["last-request-cpu"]=> + float(0) + ["last-request-memory"]=> + int(0) + } + } +} +Test End +Done +--CLEAN-- +<?php +require_once "tester.inc"; +FPM\Tester::clean(); +?> diff --git a/sapi/fpm/tests/response.inc b/sapi/fpm/tests/response.inc index 9888ec1..2ca9b1e 100644 --- a/sapi/fpm/tests/response.inc +++ b/sapi/fpm/tests/response.inc @@ -124,7 +124,7 @@ class Response */ public function printBody() { - echo $this->getBody(); + echo $this->getBody() . "\n"; } /**

« previous php.cvs (#102472) next »