summaryrefslogtreecommitdiff
path: root/sapi/fpm/tests
diff options
context:
space:
mode:
Diffstat (limited to 'sapi/fpm/tests')
-rw-r--r--sapi/fpm/tests/set-pm-max-spawn-rate.phpt39
-rw-r--r--sapi/fpm/tests/tester.inc42
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()