From 5d580b48ba3fc26735f7858461a47a7347baceec Mon Sep 17 00:00:00 2001 From: duerpei Date: Fri, 23 Sep 2022 16:11:48 +0800 Subject: agl-test-framework: add test "stress-ng" Replace "stress" with "stress-ng", the stress-ng package which is already in OE-core. Bug-AGL: SPEC-4345 Signed-off-by: duerpei Change-Id: Ia79453f2fc82d4aed0a7a405df93d2560da253de --- tests/stress-ng/__init__.py | 0 tests/stress-ng/run_tests.py | 55 ++++++++++++++++++++++++++++++++++++++++++ tests/stress/__init__.py | 0 tests/stress/run_tests.py | 57 -------------------------------------------- 4 files changed, 55 insertions(+), 57 deletions(-) create mode 100644 tests/stress-ng/__init__.py create mode 100644 tests/stress-ng/run_tests.py delete mode 100644 tests/stress/__init__.py delete mode 100644 tests/stress/run_tests.py (limited to 'tests') diff --git a/tests/stress-ng/__init__.py b/tests/stress-ng/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/stress-ng/run_tests.py b/tests/stress-ng/run_tests.py new file mode 100644 index 0000000..ec6822b --- /dev/null +++ b/tests/stress-ng/run_tests.py @@ -0,0 +1,55 @@ +import pytest +import subprocess +import pathlib + +from plugins.agl_test_base import AGLBaseTest + +class StressngBase(AGLBaseTest): + def __init__(self): + super().__init__(name="stress-ng") + + def run_test_fun(self): + log_file = self.get_logfile() + run_test = 'stress-ng ' +\ + '-i 2 -c 2 --hdd 2 --hdd-bytes 100M --vm 2 --vm-bytes 128M -t 60' + + with open(log_file, 'w') as log_f: + output = subprocess.run(run_test, shell=True, + stdout=log_f, stderr=log_f) + log_f.close() + + if (output.returncode == 0): + self.case_info_list = {'test_stress-ng': ['test_stress-ng', + str(output.returncode), 'passed']} + else: + self.case_info_list = {'test_stress-ng': ['test_stress-ng', + str(output.returncode), 'failed']} + + def precheck(self): + path_stress_ng = pathlib.Path("/usr/bin/stress-ng") + return super().precheck() and path_stress_ng.is_file() + +@pytest.fixture(scope='module') +def testbase(): + #init instance for test + instance = StressngBase() + #run test scripts + instance.run_test_fun() + + yield instance + + #package log files and make report file + instance.log_report() + +def precheck(): + instance = StressngBase() + return instance.precheck() +skip_msg = "The current environment does not match the test requirements." +pytestmark = pytest.mark.skipif(precheck() == False, reason = skip_msg) + +@pytest.mark.oss_default +def test_stress_ng(testbase: StressngBase): + assert testbase.case_info_list['test_stress-ng'][1] == '0' + +if __name__ == '__main__': + pytest.main("-s run_tests") diff --git a/tests/stress/__init__.py b/tests/stress/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/tests/stress/run_tests.py b/tests/stress/run_tests.py deleted file mode 100644 index d2bc70c..0000000 --- a/tests/stress/run_tests.py +++ /dev/null @@ -1,57 +0,0 @@ -import pytest -import subprocess -import pathlib - -from plugins.agl_test_base import AGLBaseTest - -class STRESSBase(AGLBaseTest): - def __init__(self): - super().__init__(name="stress") - - def run_test_fun(self): - log_file = self.get_logfile() - workdir = self.get_workdir() - run_test = workdir + '/stress ' +\ - '-i 2 -c 2 --hdd 2 --hdd-bytes 100M --vm 2 --vm-bytes 128M -t 60' - - with open(log_file, 'w') as log_f: - output = subprocess.run(run_test, shell=True, - cwd=workdir, stdout=log_f, stderr=log_f) - log_f.close() - - if (output.returncode == 0): - self.case_info_list = {'test_stress': ['test_stress', - str(output.returncode), 'passed']} - else: - self.case_info_list = {'test_stress': ['test_stress', - str(output.returncode), 'failed']} - - def precheck(self): - run_test = self.get_workdir() + "/stress" - path_script = pathlib.Path(run_test) - return super().precheck() and path_script.is_file() - -@pytest.fixture(scope='module') -def testbase(): - #init instance for test - instance = STRESSBase() - #run test scripts - instance.run_test_fun() - - yield instance - - #package log files and make report file - instance.log_report() - -def precheck(): - instance = STRESSBase() - return instance.precheck() -skip_msg = "The current environment does not match the test requirements." -pytestmark = pytest.mark.skipif(precheck() == False, reason = skip_msg) - -@pytest.mark.oss_default -def test_stress(testbase: STRESSBase): - assert testbase.case_info_list['test_stress'][1] == '0' - -if __name__ == '__main__': - pytest.main("-s run_tests") -- cgit 1.2.3-korg