diff options
author | Paulius Sapragonas <pauliussap@gmail.com> | 2021-03-05 20:15:30 +0200 |
---|---|---|
committer | Jakub Zelenka <bukka@php.net> | 2021-03-28 20:53:58 +0100 |
commit | eac1609a847f7cca45c9c14e1b9c4d72cea04fd6 (patch) | |
tree | 203b80f304ce36679641e96ef5d8c23745858e4d /sapi/fpm/tests | |
parent | 830d38535178920bfaae6e8e8d93fadcba4a1a7e (diff) | |
download | php-git-eac1609a847f7cca45c9c14e1b9c4d72cea04fd6.tar.gz |
Max spawn child processes rate an once
* Add functionality to expect log config options
Diffstat (limited to 'sapi/fpm/tests')
-rw-r--r-- | sapi/fpm/tests/set-pm-max-spawn-rate.phpt | 39 | ||||
-rw-r--r-- | sapi/fpm/tests/tester.inc | 42 |
2 files changed, 81 insertions, 0 deletions
diff --git a/sapi/fpm/tests/set-pm-max-spawn-rate.phpt b/sapi/fpm/tests/set-pm-max-spawn-rate.phpt new file mode 100644 index 0000000000..8b5f6b4eb6 --- /dev/null +++ b/sapi/fpm/tests/set-pm-max-spawn-rate.phpt @@ -0,0 +1,39 @@ +--TEST-- +FPM: set pm.max_spawn_rate +--SKIPIF-- +<?php +include "skipif.inc"; +?> +--FILE-- +<?php + +require_once "tester.inc"; + +$cfg = <<<EOT +[global] +error_log = {{FILE:LOG}} +log_level = notice +[unconfined] +listen = {{ADDR}} +pm = dynamic +pm.max_children = 5 +pm.start_servers = 2 +pm.min_spare_servers = 1 +pm.max_spare_servers = 3 +pm.max_spawn_rate = 64 +EOT; + +$tester = new FPM\Tester($cfg); +$tester->start(['-t', '-t']); +$tester->expectLogConfigOptions(['pm.max_spawn_rate' => 64]); +$tester->close(); + +?> +Done +--EXPECT-- +Done +--CLEAN-- +<?php +require_once "tester.inc"; +FPM\Tester::clean(); +?> diff --git a/sapi/fpm/tests/tester.inc b/sapi/fpm/tests/tester.inc index 7aab2d3aa9..9ce4c1a091 100644 --- a/sapi/fpm/tests/tester.inc +++ b/sapi/fpm/tests/tester.inc @@ -1348,6 +1348,48 @@ class Tester } /** + * Expect log config options + * + * @param array $options + * @return bool + */ + public function expectLogConfigOptions(array $options) + { + $configOptions = $this->getConfigOptions(); + foreach ($options as $name => $value) { + if (!isset($configOptions[$name])) { + return $this->error("Expected config option: {$name} = {$value} but {$name} is not set"); + } + if ($configOptions[$name] != $value) { + return $this->error( + "Expected config option: {$name} = {$value} but got: {$name} = {$configOptions[$name]}" + ); + } + } + + return true; + } + + /** + * Get set config options + * + * @return array + */ + private function getConfigOptions() + { + $options = []; + + foreach ($this->getLogLines(-1) as $line) { + preg_match('/.+NOTICE:\s+(.+)\s=\s(.+)/', $line, $matches); + if ($matches) { + $options[$matches[1]] = $matches[2]; + } + } + + return $options; + } + + /** * Print content of access log. */ public function printAccessLog() |