From ad843df965f47b5d209603de49d0b3b16938149d Mon Sep 17 00:00:00 2001 From: Andrei Zeliankou Date: Fri, 10 Dec 2021 15:34:52 +0000 Subject: Tests: fixed path to the "php.ini" file. --- test/test_php_application.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'test/test_php_application.py') diff --git a/test/test_php_application.py b/test/test_php_application.py index d9c16a6d..194caa9f 100644 --- a/test/test_php_application.py +++ b/test/test_php_application.py @@ -294,20 +294,28 @@ class TestPHPApplication(TestApplicationPHP): self.load('ini_precision') assert 'success' in self.conf( - {"file": "php.ini", "admin": {"precision": "5"}}, + {"file": "ini/php.ini", "admin": {"precision": "5"}}, 'applications/ini_precision/options', ) + assert ( + self.get()['headers']['X-File'] + == option.test_dir + '/php/ini_precision/ini/php.ini' + ), 'ini file' assert self.get()['headers']['X-Precision'] == '5', 'ini value admin' def test_php_application_ini_user(self): self.load('ini_precision') assert 'success' in self.conf( - {"file": "php.ini", "user": {"precision": "5"}}, + {"file": "ini/php.ini", "user": {"precision": "5"}}, 'applications/ini_precision/options', ) + assert ( + self.get()['headers']['X-File'] + == option.test_dir + '/php/ini_precision/ini/php.ini' + ), 'ini file' assert self.get()['headers']['X-Precision'] == '5', 'ini value user' def test_php_application_ini_user_2(self): -- cgit From 4b3efcea0dfcc842fb1a0f62b610652323844d35 Mon Sep 17 00:00:00 2001 From: Andrei Zeliankou Date: Sat, 11 Dec 2021 00:16:59 +0000 Subject: Tests: added more OPcache tests. --- test/test_php_application.py | 65 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 53 insertions(+), 12 deletions(-) (limited to 'test/test_php_application.py') diff --git a/test/test_php_application.py b/test/test_php_application.py index 194caa9f..97bb9437 100644 --- a/test/test_php_application.py +++ b/test/test_php_application.py @@ -1,3 +1,4 @@ +import getpass import os import re import shutil @@ -18,18 +19,43 @@ class TestPHPApplication(TestApplicationPHP): assert re.search(r'time: \d+', body), 'disable_functions before time' assert re.search(r'exec: \/\w+', body), 'disable_functions before exec' + def check_opcache(self): + resp = self.get() + assert resp['status'] == 200, 'status' + + headers = resp['headers'] + if 'X-OPcache' in headers and headers['X-OPcache'] == '-1': + pytest.skip('opcache is not supported') + + return resp + def set_opcache(self, app, val): assert 'success' in self.conf( {"admin": {"opcache.enable": val, "opcache.enable_cli": val}}, 'applications/' + app + '/options', ) - opcache = self.get()['headers']['X-OPcache'] - - if not opcache or opcache == '-1': - pytest.skip('opcache is not supported') + r = self.check_opcache() + assert r['headers']['X-OPcache'] == val, 'opcache value' + + def set_preload(self, preload): + with open(option.temp_dir + '/php.ini', 'w') as f: + f.write( + """opcache.preload = %(test_dir)s/php/opcache/preload\ +/%(preload)s +opcache.preload_user = %(user)s +""" + % { + 'test_dir': option.test_dir, + 'preload': preload, + 'user': option.user or getpass.getuser(), + } + ) - assert opcache == val, 'opcache value' + assert 'success' in self.conf( + {"file": option.temp_dir + "/php.ini"}, + 'applications/opcache/options', + ) def test_php_application_variables(self): self.load('variables') @@ -725,16 +751,31 @@ class TestPHPApplication(TestApplicationPHP): 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') - + r = self.check_opcache() pid = r['headers']['X-Pid'] - - assert cached == '0', 'not cached' + assert r['headers']['X-Cached'] == '0', 'not cached' r = self.get() assert r['headers']['X-Pid'] != pid, 'new instance' assert r['headers']['X-Cached'] == '1', 'cached' + + def test_php_application_opcache_preload_chdir(self, temp_dir): + self.load('opcache') + + self.check_opcache() + + self.set_preload('chdir.php') + + assert self.get()['headers']['X-Cached'] == '0', 'not cached' + assert self.get()['headers']['X-Cached'] == '1', 'cached' + + def test_php_application_opcache_preload_ffr(self, temp_dir): + self.load('opcache') + + self.check_opcache() + + self.set_preload('fastcgi_finish_request.php') + + assert self.get()['headers']['X-Cached'] == '0', 'not cached' + assert self.get()['headers']['X-Cached'] == '1', 'cached' -- cgit From 9bea8c452ffea1d9ff78a1bc3ce5c4d2f0d6b95f Mon Sep 17 00:00:00 2001 From: Andrei Zeliankou Date: Sun, 12 Dec 2021 21:36:44 +0000 Subject: Tests: fixed type of applications. --- test/test_php_application.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'test/test_php_application.py') diff --git a/test/test_php_application.py b/test/test_php_application.py index 97bb9437..e6540318 100644 --- a/test/test_php_application.py +++ b/test/test_php_application.py @@ -600,7 +600,7 @@ opcache.preload_user = %(user)s "listeners": {"*:7080": {"pass": "applications/script"}}, "applications": { "script": { - "type": "php", + "type": self.get_application_type(), "processes": {"spare": 0}, "root": option.test_dir + "/php/script", "script": "phpinfo.php", @@ -620,7 +620,7 @@ opcache.preload_user = %(user)s "listeners": {"*:7080": {"pass": "applications/phpinfo"}}, "applications": { "phpinfo": { - "type": "php", + "type": self.get_application_type(), "processes": {"spare": 0}, "root": option.test_dir + "/php/phpinfo", } @@ -647,7 +647,7 @@ opcache.preload_user = %(user)s "listeners": {"*:7080": {"pass": "applications/phpinfo"}}, "applications": { "phpinfo": { - "type": "php", + "type": self.get_application_type(), "processes": {"spare": 0}, "root": new_root, "working_directory": new_root, -- cgit From 0f725346603f4de4473d12da502104b188ac02a4 Mon Sep 17 00:00:00 2001 From: Andrei Zeliankou Date: Mon, 11 Apr 2022 21:05:14 +0100 Subject: Tests: style. --- test/test_php_application.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'test/test_php_application.py') diff --git a/test/test_php_application.py b/test/test_php_application.py index e6540318..606ac723 100644 --- a/test/test_php_application.py +++ b/test/test_php_application.py @@ -419,9 +419,7 @@ opcache.preload_user = %(user)s body = self.get()['body'] - assert not re.search( - r'time: \d+', body - ), 'disable_functions comma time' + assert not re.search(r'time: \d+', body), 'disable_functions comma time' assert not re.search( r'exec: \/\w+', body ), 'disable_functions comma exec' @@ -498,9 +496,7 @@ opcache.preload_user = %(user)s body = self.get()['body'] - assert not re.search( - r'time: \d+', body - ), 'disable_functions space time' + assert not re.search(r'time: \d+', body), 'disable_functions space time' assert not re.search( r'exec: \/\w+', body ), 'disable_functions space exec' @@ -671,7 +667,8 @@ opcache.preload_user = %(user)s assert resp['body'] == script_cwd, 'default cwd' assert 'success' in self.conf( - '"' + option.test_dir + '"', 'applications/cwd/working_directory', + '"' + option.test_dir + '"', + 'applications/cwd/working_directory', ) resp = self.get() -- cgit