summaryrefslogtreecommitdiffstats
path: root/dovetail
diff options
context:
space:
mode:
authorxudan <xudan16@huawei.com>2018-10-18 04:37:59 -0400
committerxudan <xudan16@huawei.com>2018-11-01 02:38:25 -0400
commit41392d61f366130d089bccfff5cd1b08bc0bb5d2 (patch)
treee86bbb47e8424b1f5d094e392709471862107c11 /dovetail
parent33ffeda0ebd938087fb43c137e7ed8873754c03e (diff)
Update classes in testcase.py
1. Remove the functions which are not called anywhere 2. Change some class methods to be static methods and instance methods Change-Id: I2e754cdff61aa34ffe899e352653ff767d4ac69d Signed-off-by: xudan <xudan16@huawei.com>
Diffstat (limited to 'dovetail')
-rwxr-xr-xdovetail/run.py6
-rw-r--r--dovetail/test_runner.py19
-rw-r--r--dovetail/testcase.py50
3 files changed, 12 insertions, 63 deletions
diff --git a/dovetail/run.py b/dovetail/run.py
index 8d4b7f8..3037980 100755
--- a/dovetail/run.py
+++ b/dovetail/run.py
@@ -52,12 +52,6 @@ def run_test(testcase_list, logger):
testcase = Testcase.get(testcase_name)
run_testcase = True
- # if testcase.exceed_max_retry_times():
- # run_testcase = False
-
- # if testcase.script_result_acquired():
- # run_testcase = False
-
if run_testcase:
testcase.run()
diff --git a/dovetail/test_runner.py b/dovetail/test_runner.py
index a2bc774..95bed6f 100644
--- a/dovetail/test_runner.py
+++ b/dovetail/test_runner.py
@@ -106,7 +106,6 @@ class DockerRunner(object):
if cmds:
for cmd in cmds:
ret, msg = container.exec_cmd(cmd)
- self.testcase.cleaned(True)
if not dt_cfg.dovetail_config['noclean']:
container.clean()
@@ -229,18 +228,14 @@ class ShellRunner(object):
def run(self):
testcase_passed = 'PASS'
- prepare_failed = False
result = {'pass': 'PASS', 'results': []}
- if not self.testcase.prepared():
- cmds = self.testcase.pre_condition()
- for cmd in cmds:
- ret, msg = dt_utils.exec_cmd(cmd, self.logger)
- result['results'].append((cmd, ret, msg))
- if ret != 0:
- prepare_failed = True
- break
- if not prepare_failed:
- self.testcase.prepared(True)
+ cmds = self.testcase.pre_condition()
+ for cmd in cmds:
+ ret, msg = dt_utils.exec_cmd(cmd, self.logger)
+ result['results'].append((cmd, ret, msg))
+ if ret != 0:
+ self.logger.error('Failed to execute all pre_condition cmds.')
+ break
if not self.testcase.prepare_cmd(self.type):
self.logger.error(
diff --git a/dovetail/testcase.py b/dovetail/testcase.py
index ba28905..33f14a9 100644
--- a/dovetail/testcase.py
+++ b/dovetail/testcase.py
@@ -89,13 +89,7 @@ class Testcase(object):
def validate_testcase(self):
return self.testcase['validate']['testcase']
- def exceed_max_retry_times(self):
- # logger.debug('retry times:%d' % self.testcase['retry'])
- return self._exceed_max_retry_times(self.validate_testcase())
-
def increase_retry(self):
- # self.testcase['retry'] = self.testcase['retry'] + 1
- # return self.testcase['retry']
return self._increase_retry(self.validate_testcase())
def passed(self, passed=None):
@@ -109,9 +103,6 @@ class Testcase(object):
def get_results(self):
return self.results
- def script_result_acquired(self, acquired=None):
- return self._result_acquired(self.validate_testcase(), acquired)
-
def pre_condition(self):
try:
pre_condition = self.testcase['validate']['pre_condition']
@@ -177,18 +168,6 @@ class Testcase(object):
# testcase in dovetail
testcase_list = {}
- @classmethod
- def prepared(cls, prepared=None):
- if prepared is not None:
- cls.validate_testcase_list['prepared'] = prepared
- return cls.validate_testcase_list['prepared']
-
- @classmethod
- def cleaned(cls, cleaned=None):
- if cleaned is not None:
- cls.validate_testcase_list['cleaned'] = cleaned
- return cls.validate_testcase_list['cleaned']
-
@staticmethod
def pre_condition_cls(validate_type):
try:
@@ -203,32 +182,15 @@ class Testcase(object):
except KeyError:
return None
- @classmethod
- def update_validate_testcase(cls, testcase_name):
- if testcase_name not in cls.validate_testcase_list:
- cls.validate_testcase_list[testcase_name] = \
- {'retry': 0, 'acquired': False}
- cls.validate_testcase_list['prepared'] = False
- cls.validate_testcase_list['cleaned'] = False
+ def update_validate_testcase(self, testcase_name):
+ if testcase_name not in self.validate_testcase_list:
+ self.validate_testcase_list[testcase_name] = {'retry': 0}
- @classmethod
- def _exceed_max_retry_times(cls, validate_testcase):
- retry = cls.validate_testcase_list[validate_testcase]['retry']
- return retry > 1
-
- @classmethod
def _increase_retry(cls, validate_testcase):
cls.validate_testcase_list[validate_testcase]['retry'] += 1
return cls.validate_testcase_list[validate_testcase]['retry']
@classmethod
- def _result_acquired(cls, testcase, acquired=None):
- if acquired is not None:
- cls.validate_testcase_list[testcase]['acquired'] = \
- acquired
- return cls.validate_testcase_list[testcase]['acquired']
-
- @classmethod
def load(cls):
abs_testcase_path = constants.TESTCASE_PATH
for root, dirs, files in os.walk(abs_testcase_path):
@@ -250,8 +212,8 @@ class Testcase(object):
return cls.testcase_list[testcase_name]
return None
- @classmethod
- def check_testarea(cls, testarea):
+ @staticmethod
+ def check_testarea(testarea):
area_no_duplicate = []
area_full = ['full']
@@ -428,8 +390,6 @@ class Testsuite(object):
testsuite_yaml = yaml.safe_load(f)
cls.testsuite_list.update(testsuite_yaml)
- # cls.logger.debug(cls.testsuite_list)
-
@classmethod
def get(cls, testsuite_name):
if testsuite_name in cls.testsuite_list: