Tests: PHP shared opcache test added.
This commit is contained in:
18
test/php/opcache/index.php
Normal file
18
test/php/opcache/index.php
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
$pid = getmypid();
|
||||||
|
|
||||||
|
header('X-Pid: ' . $pid);
|
||||||
|
|
||||||
|
if (function_exists('opcache_is_script_cached')) {
|
||||||
|
if (opcache_is_script_cached(__DIR__ . '/test.php')) {
|
||||||
|
header('X-Cached: 1');
|
||||||
|
} else {
|
||||||
|
header('X-Cached: 0');
|
||||||
|
opcache_compile_file(__DIR__ . '/test.php');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
header('X-Cached: -1');
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
1
test/php/opcache/test.php
Normal file
1
test/php/opcache/test.php
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<?php phpinfo(); ?>
|
||||||
@@ -713,3 +713,20 @@ class TestPHPApplication(TestApplicationPHP):
|
|||||||
), 'relative path w/ chdir'
|
), 'relative path w/ chdir'
|
||||||
|
|
||||||
assert self.get()['body'] == 'test', 'relative path 2'
|
assert self.get()['body'] == 'test', 'relative path 2'
|
||||||
|
|
||||||
|
def test_php_application_shared_opcache(self):
|
||||||
|
self.load('opcache', limits={'requests': 1})
|
||||||
|
|
||||||
|
r = self.get()
|
||||||
|
cached = r['headers']['X-Cached']
|
||||||
|
if cached == '-1':
|
||||||
|
pytest.skip('opcache is not supported')
|
||||||
|
|
||||||
|
pid = r['headers']['X-Pid']
|
||||||
|
|
||||||
|
assert cached == '0', 'not cached'
|
||||||
|
|
||||||
|
r = self.get()
|
||||||
|
|
||||||
|
assert r['headers']['X-Pid'] != pid, 'new instance'
|
||||||
|
assert r['headers']['X-Cached'] == '1', 'cached'
|
||||||
|
|||||||
@@ -22,18 +22,27 @@ class TestApplicationPHP(TestApplicationProto):
|
|||||||
|
|
||||||
script_path = '/app/php/' + script
|
script_path = '/app/php/' + script
|
||||||
|
|
||||||
|
app = {
|
||||||
|
"type": self.get_application_type(),
|
||||||
|
"processes": kwargs.pop('processes', {"spare": 0}),
|
||||||
|
"root": script_path,
|
||||||
|
"working_directory": script_path,
|
||||||
|
"index": index,
|
||||||
|
}
|
||||||
|
|
||||||
|
for attr in (
|
||||||
|
'environment',
|
||||||
|
'limits',
|
||||||
|
'options',
|
||||||
|
'targets',
|
||||||
|
):
|
||||||
|
if attr in kwargs:
|
||||||
|
app[attr] = kwargs.pop(attr)
|
||||||
|
|
||||||
self._load_conf(
|
self._load_conf(
|
||||||
{
|
{
|
||||||
"listeners": {"*:7080": {"pass": "applications/" + script}},
|
"listeners": {"*:7080": {"pass": "applications/" + script}},
|
||||||
"applications": {
|
"applications": {script: app},
|
||||||
script: {
|
|
||||||
"type": self.get_application_type(),
|
|
||||||
"processes": {"spare": 0},
|
|
||||||
"root": script_path,
|
|
||||||
"working_directory": script_path,
|
|
||||||
"index": index,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
**kwargs
|
**kwargs
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user