xref: /PHP-7.0/sapi/fpm/tests/010.phpt (revision 3a16f511)
1--TEST--
2FPM: Test status page
3--SKIPIF--
4<?php include "skipif.inc"; ?>
5--XFAIL--
6randomly intermittently failing all the time in CI, with diff:
7017+ active processes:     0
8018+ total processes:      1
9017- active processes:     1
10018- total processes:      2
11--FILE--
12<?php
13
14include "include.inc";
15
16$logfile = dirname(__FILE__).'/php-fpm.log.tmp';
17$port = 9000+PHP_INT_SIZE;
18
19$cfg = <<<EOT
20[global]
21error_log = $logfile
22[unconfined]
23listen = 127.0.0.1:$port
24pm.status_path = /status
25pm = static
26pm.max_children = 1
27EOT;
28
29$fpm = run_fpm($cfg, $tail);
30if (is_resource($fpm)) {
31    fpm_display_log($tail, 2);
32    try {
33		echo run_request('127.0.0.1', $port, '/status');
34
35		$html = run_request('127.0.0.1', $port, '/status', 'html');
36		var_dump(strpos($html, 'text/html') && strpos($html, 'DOCTYPE') && strpos($html, 'PHP-FPM Status Page'));
37
38		$json = run_request('127.0.0.1', $port, '/status', 'json');
39		var_dump(strpos($json, 'application/json') && strpos($json, '"pool":"unconfined"'));
40
41		$xml = run_request('127.0.0.1', $port, '/status', 'xml');
42		var_dump(strpos($xml, 'text/xml') && strpos($xml, '<?xml'));
43
44		echo "IPv4 ok\n";
45	} catch (Exception $e) {
46		echo "IPv4 error\n";
47	}
48
49	proc_terminate($fpm);
50    stream_get_contents($tail);
51    fclose($tail);
52    proc_close($fpm);
53}
54
55?>
56--EXPECTF--
57[%d-%s-%d %d:%d:%d] NOTICE: fpm is running, pid %d
58[%d-%s-%d %d:%d:%d] NOTICE: ready to handle connections
59X-Powered-By: PHP/%s
60Expires: %s
61Cache-Control: %s
62Content-type: text/plain%s
63
64pool:                 unconfined
65process manager:      static
66start time:           %s
67start since:          %d
68accepted conn:        1
69listen queue:         0
70max listen queue:     0
71listen queue len:     %d
72idle processes:       0
73active processes:     1
74total processes:      1
75max active processes: 1
76max children reached: 0
77slow requests:        0
78
79bool(true)
80bool(true)
81bool(true)
82IPv4 ok
83--CLEAN--
84<?php
85    $logfile = dirname(__FILE__).'/php-fpm.log.tmp';
86    @unlink($logfile);
87?>
88