summaryrefslogtreecommitdiff
path: root/sapi/fpm/tests
diff options
context:
space:
mode:
authorJakub Zelenka <bukka@php.net>2018-06-12 18:09:27 +0100
committerJakub Zelenka <bukka@php.net>2018-06-12 18:09:27 +0100
commitdd622f9ca9d032cafd324380586a4f6d55ff7a10 (patch)
tree6faa5d01d1541db5b279997b0177d91bdd362325 /sapi/fpm/tests
parentbc58ba750f343ce6f42f35573ff268fd31533cdc (diff)
downloadphp-git-dd622f9ca9d032cafd324380586a4f6d55ff7a10.tar.gz
Port FPM test 023 and 024 to the new FPM testing
Diffstat (limited to 'sapi/fpm/tests')
-rw-r--r--sapi/fpm/tests/023.phpt57
-rw-r--r--sapi/fpm/tests/024-bug72212.phpt82
-rw-r--r--sapi/fpm/tests/bug75212-php-value-in-user-ini.phpt57
-rw-r--r--sapi/fpm/tests/socket-ipv4-fallback.phpt43
4 files changed, 100 insertions, 139 deletions
diff --git a/sapi/fpm/tests/023.phpt b/sapi/fpm/tests/023.phpt
deleted file mode 100644
index 13d5cc0a78..0000000000
--- a/sapi/fpm/tests/023.phpt
+++ /dev/null
@@ -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);
-?>
diff --git a/sapi/fpm/tests/024-bug72212.phpt b/sapi/fpm/tests/024-bug72212.phpt
deleted file mode 100644
index e601aaf12f..0000000000
--- a/sapi/fpm/tests/024-bug72212.phpt
+++ /dev/null
@@ -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);
-?>
diff --git a/sapi/fpm/tests/bug75212-php-value-in-user-ini.phpt b/sapi/fpm/tests/bug75212-php-value-in-user-ini.phpt
new file mode 100644
index 0000000000..fd8e1b8887
--- /dev/null
+++ b/sapi/fpm/tests/bug75212-php-value-in-user-ini.phpt
@@ -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();
+?>
diff --git a/sapi/fpm/tests/socket-ipv4-fallback.phpt b/sapi/fpm/tests/socket-ipv4-fallback.phpt
new file mode 100644
index 0000000000..f0a8301916
--- /dev/null
+++ b/sapi/fpm/tests/socket-ipv4-fallback.phpt
@@ -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();
+?>