summaryrefslogtreecommitdiffhomepage
path: root/test/test_java_isolation_rootfs.py
diff options
context:
space:
mode:
authorAndrei Zeliankou <zelenkov@nginx.com>2023-06-14 18:20:09 +0100
committerAndrei Zeliankou <zelenkov@nginx.com>2023-06-14 18:20:09 +0100
commitc183bd8749a19477390f8cb77efe5f6d223f0905 (patch)
tree4e821e9cb07be9a86bf2d442acb3ea6740ba5a99 /test/test_java_isolation_rootfs.py
parentc6d05191a069ac150cc8eb2bece75cf79c0a465a (diff)
downloadunit-c183bd8749a19477390f8cb77efe5f6d223f0905.tar.gz
unit-c183bd8749a19477390f8cb77efe5f6d223f0905.tar.bz2
Tests: get rid of classes in test files.
Class usage came from the unittest framework and it was always redundant after migration to the pytest. This commit removes classes from files containing tests to make them more readable and understandable.
Diffstat (limited to 'test/test_java_isolation_rootfs.py')
-rw-r--r--test/test_java_isolation_rootfs.py91
1 files changed, 46 insertions, 45 deletions
diff --git a/test/test_java_isolation_rootfs.py b/test/test_java_isolation_rootfs.py
index bbd2c915..66b2a81e 100644
--- a/test/test_java_isolation_rootfs.py
+++ b/test/test_java_isolation_rootfs.py
@@ -2,64 +2,65 @@ import os
import subprocess
import pytest
-from unit.applications.lang.java import TestApplicationJava
+from unit.applications.lang.java import ApplicationJava
from unit.option import option
prerequisites = {'modules': {'java': 'all'}, 'privileged_user': True}
+client = ApplicationJava()
-class TestJavaIsolationRootfs(TestApplicationJava):
- @pytest.fixture(autouse=True)
- 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)
- try:
- subprocess.run(
- [
- "mount",
- "--bind",
- f'{option.current_dir}/build',
- f'{temp_dir}/jars',
- ],
- stderr=subprocess.STDOUT,
- )
+@pytest.fixture(autouse=True)
+def setup_method_fixture(temp_dir):
+ os.makedirs(f'{temp_dir}/jars')
+ os.makedirs(f'{temp_dir}/tmp')
+ os.chmod(f'{temp_dir}/tmp', 0o777)
- except KeyboardInterrupt:
- raise
+ try:
+ subprocess.run(
+ [
+ "mount",
+ "--bind",
+ f'{option.current_dir}/build',
+ f'{temp_dir}/jars',
+ ],
+ stderr=subprocess.STDOUT,
+ )
- except subprocess.CalledProcessError:
- pytest.fail("Can't run mount process.")
+ except KeyboardInterrupt:
+ raise
- def teardown_method(self):
- try:
- subprocess.run(
- ["umount", "--lazy", f"{option.temp_dir}/jars"],
- stderr=subprocess.STDOUT,
- )
+ except subprocess.CalledProcessError:
+ pytest.fail("Can't run mount process.")
- except KeyboardInterrupt:
- raise
+ yield
- except subprocess.CalledProcessError:
- pytest.fail("Can't run umount process.")
+ try:
+ subprocess.run(
+ ["umount", "--lazy", f"{option.temp_dir}/jars"],
+ stderr=subprocess.STDOUT,
+ )
- def test_java_isolation_rootfs_chroot_war(self, temp_dir):
- isolation = {'rootfs': temp_dir}
+ except KeyboardInterrupt:
+ raise
- self.load('empty_war', isolation=isolation)
+ except subprocess.CalledProcessError:
+ pytest.fail("Can't run umount process.")
- assert 'success' in self.conf(
- '"/"',
- '/config/applications/empty_war/working_directory',
- )
- assert 'success' in self.conf(
- '"/jars"', 'applications/empty_war/unit_jars'
- )
- assert 'success' in self.conf(
- '"/java/empty.war"', 'applications/empty_war/webapp'
- )
+def test_java_isolation_rootfs_chroot_war(temp_dir):
+ client.load('empty_war', isolation={'rootfs': temp_dir})
+
+ assert 'success' in client.conf(
+ '"/"',
+ '/config/applications/empty_war/working_directory',
+ )
+
+ assert 'success' in client.conf(
+ '"/jars"', 'applications/empty_war/unit_jars'
+ )
+ assert 'success' in client.conf(
+ '"/java/empty.war"', 'applications/empty_war/webapp'
+ )
- assert self.get()['status'] == 200, 'war'
+ assert client.get()['status'] == 200, 'war'