aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorduerpei <duep.fnst@fujitsu.com>2022-08-27 12:00:04 +0800
committerduerpei <duep.fnst@fujitsu.com>2022-08-27 12:00:04 +0800
commitef29f9077a89038525e20a517d972453f2cc4d62 (patch)
tree213c2ff1d8a1c6db64d8cf625102c25cd19a3113
parentf9f4b0ef5dfd10bf8a936b3eecc2407fe94fc305 (diff)
agl-test-framework: add test 'stress'
Add test script for 'stress' Bug-AGL: SPEC-4345 Signed-off-by: duerpei <duep.fnst@fujitsu.com> Change-Id: I1c0c048dc907e5cff5d50396ab28b7550371b32e
-rw-r--r--tests/stress/__init__.py0
-rw-r--r--tests/stress/run_tests.py57
2 files changed, 57 insertions, 0 deletions
diff --git a/tests/stress/__init__.py b/tests/stress/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/stress/__init__.py
diff --git a/tests/stress/run_tests.py b/tests/stress/run_tests.py
new file mode 100644
index 0000000..d2bc70c
--- /dev/null
+++ b/tests/stress/run_tests.py
@@ -0,0 +1,57 @@
+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")