blob: ec6822b7d769d336ac50d3ac284ec3f956dca74b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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")
|