diff options
author | Andrei Zeliankou <zelenkov@nginx.com> | 2023-06-12 14:16:59 +0100 |
---|---|---|
committer | Andrei Zeliankou <zelenkov@nginx.com> | 2023-06-12 14:16:59 +0100 |
commit | ce2405ec3dd97e8bdf8f63312e3c6ce59ef562d4 (patch) | |
tree | 818e60eb10d7f2be90f25003b3a2b347314e966f /test/test_java_isolation_rootfs.py | |
parent | a3b9b49cfb091410ca8f3c8d9df24d1fe184f8e0 (diff) | |
download | unit-ce2405ec3dd97e8bdf8f63312e3c6ce59ef562d4.tar.gz unit-ce2405ec3dd97e8bdf8f63312e3c6ce59ef562d4.tar.bz2 |
Tests: prerequisites checking reworked.
Prerequisites check moved to the module level to simplify class structure.
Discovery and prerequisites checks functions moved to the separate files.
Introduced "require" fixture to provide per-test requirements check.
Diffstat (limited to 'test/test_java_isolation_rootfs.py')
-rw-r--r-- | test/test_java_isolation_rootfs.py | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/test/test_java_isolation_rootfs.py b/test/test_java_isolation_rootfs.py index 28bc4a0d..bbd2c915 100644 --- a/test/test_java_isolation_rootfs.py +++ b/test/test_java_isolation_rootfs.py @@ -5,15 +5,12 @@ import pytest from unit.applications.lang.java import TestApplicationJava from unit.option import option +prerequisites = {'modules': {'java': 'all'}, 'privileged_user': True} -class TestJavaIsolationRootfs(TestApplicationJava): - prerequisites = {'modules': {'java': 'all'}} +class TestJavaIsolationRootfs(TestApplicationJava): @pytest.fixture(autouse=True) - def setup_method_fixture(self, is_su, temp_dir): - if not is_su: - pytest.skip('require root') - + def setup_method_fixture(self, temp_dir): os.makedirs(f'{temp_dir}/jars') os.makedirs(f'{temp_dir}/tmp') os.chmod(f'{temp_dir}/tmp', 0o777) @@ -35,10 +32,7 @@ class TestJavaIsolationRootfs(TestApplicationJava): except subprocess.CalledProcessError: pytest.fail("Can't run mount process.") - def teardown_method(self, is_su): - if not is_su: - return - + def teardown_method(self): try: subprocess.run( ["umount", "--lazy", f"{option.temp_dir}/jars"], @@ -51,13 +45,8 @@ class TestJavaIsolationRootfs(TestApplicationJava): except subprocess.CalledProcessError: pytest.fail("Can't run umount process.") - def test_java_isolation_rootfs_chroot_war(self, is_su, temp_dir): - if not is_su: - pytest.skip('require root') - - isolation = { - 'rootfs': temp_dir, - } + def test_java_isolation_rootfs_chroot_war(self, temp_dir): + isolation = {'rootfs': temp_dir} self.load('empty_war', isolation=isolation) |