xref: /PHP-5.6/sapi/fpm/tests/015.phpt (revision cb1a297b)
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++ < 30) && !($fp = @fsockopen('127.0.0.1', $port1))) {
46		usleep(10000);
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	if (!feof($tail)) {
66		echo stream_get_contents($tail);
67	}
68	fclose($tail);
69	proc_close($fpm);
70}
71
72?>
73Done
74--EXPECTF--
75Started
76Error 2
77[%s] NOTICE: [pool pool1] pm.start_servers is not set. It's been set to 2.
78[%s] NOTICE: [pool pool1] 'user' directive is ignored when FPM is not running as root
79[%s] NOTICE: fpm is running, pid %d
80[%s] NOTICE: ready to handle connections
81[%s] WARNING: [pool pool2] child %d said into stderr: "ERROR: Wrong IP address 'xxx' in listen.allowed_clients"
82[%s] WARNING: [pool pool2] child %d said into stderr: "ERROR: There are no allowed addresses for this pool"
83[%s] WARNING: [pool pool2] child %d said into stderr: "ERROR: Connection disallowed: IP address '127.0.0.1' has been dropped."
84[%s] NOTICE: Terminating ...
85[%s] NOTICE: exiting, bye-bye!
86Done
87--CLEAN--
88<?php
89	$logfile = dirname(__FILE__).'/php-fpm.log.tmp';
90	@unlink($logfile);
91?>