xref: /PHP-7.0/sapi/fpm/tests/015.phpt (revision fd92b911)
1--TEST--
2FPM: Test various messages on start, from master and childs
3--SKIPIF--
4<?php include "skipif.inc"; ?>
5--XFAIL--
6randomly intermittently failing all the time in CI,
7ERROR: unable to read what child say: Bad file descriptor (9)
8catch_workers_output = yes seems not reliable
9--FILE--
10<?php
11
12include "include.inc";
13
14$logfile = dirname(__FILE__).'/php-fpm.log.tmp';
15$port1 = 9000+PHP_INT_SIZE;
16$port2 = 9001+PHP_INT_SIZE;
17
18$cfg = <<<EOT
19[global]
20error_log = $logfile
21log_level = notice
22[pool1]
23listen = 127.0.0.1:$port1
24listen.allowed_clients=127.0.0.1
25user = foo
26pm = dynamic
27pm.max_children = 5
28pm.min_spare_servers = 1
29pm.max_spare_servers = 3
30catch_workers_output = yes
31[pool2]
32listen = 127.0.0.1:$port2
33listen.allowed_clients=xxx
34pm = dynamic
35pm.max_children = 5
36pm.start_servers = 1
37pm.min_spare_servers = 1
38pm.max_spare_servers = 3
39catch_workers_output = yes
40EOT;
41
42$fpm = run_fpm($cfg, $tail);
43if (is_resource($fpm)) {
44    $i = 0;
45	while (($i++ < 60) && !($fp = @fsockopen('127.0.0.1', $port1))) {
46		usleep(50000);
47	}
48	if ($fp) {
49		echo "Started\n";
50		fclose($fp);
51	}
52	for ($i=0 ; $i<10 ; $i++) {
53		try {
54			run_request('127.0.0.1', $port1);
55		} catch (Exception $e) {
56			echo "Error 1\n";
57		}
58	}
59	try {
60		run_request('127.0.0.1', $port2);
61	} catch (Exception $e) {
62		echo "Error 2\n";
63	}
64	proc_terminate($fpm);
65	fpm_display_log($tail, -1);
66	fclose($tail);
67	proc_close($fpm);
68}
69
70?>
71Done
72--EXPECTF--
73Started
74Error 2
75[%s] NOTICE: [pool pool1] pm.start_servers is not set. It's been set to 2.
76[%s] NOTICE: [pool pool1] 'user' directive is ignored when FPM is not running as root
77[%s] NOTICE: fpm is running, pid %d
78[%s] NOTICE: ready to handle connections
79[%s] WARNING: [pool pool2] child %d said into stderr: "ERROR: Wrong IP address 'xxx' in listen.allowed_clients"
80[%s] WARNING: [pool pool2] child %d said into stderr: "ERROR: There are no allowed %s"
81[%s] WARNING: [pool pool2] child %d said into stderr: "ERROR: Connection disallowed: IP address '127.0.0.1' has been dropped."
82[%s] NOTICE: Terminating ...
83[%s] NOTICE: exiting, bye-bye!
84Done
85--CLEAN--
86<?php
87	$logfile = dirname(__FILE__).'/php-fpm.log.tmp';
88	@unlink($logfile);
89?>
90