summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dovetail/container.py12
-rw-r--r--dovetail/parser.py4
-rw-r--r--dovetail/report.py25
-rw-r--r--dovetail/testcase.py29
-rw-r--r--dovetail/utils/dovetail_logger.py4
5 files changed, 38 insertions, 36 deletions
diff --git a/dovetail/container.py b/dovetail/container.py
index 6d7ac94d..57ce2144 100644
--- a/dovetail/container.py
+++ b/dovetail/container.py
@@ -29,8 +29,8 @@ class Container:
def get(cls, type):
return cls.container_list[type]
- @classmethod
- def get_docker_image(cls, type):
+ @staticmethod
+ def get_docker_image(type):
return '%s:%s' % (dovetail_config[type]['image_name'],
dovetail_config[type]['docker_tag'])
@@ -62,14 +62,14 @@ class Container:
dt_utils.exec_cmd(cmd, logger)
cls.has_pull_latest_image[type] = True
- @classmethod
- def clean(cls, container_id):
+ @staticmethod
+ def clean(container_id):
cmd1 = 'sudo docker stop %s' % (container_id)
dt_utils.exec_cmd(cmd1, logger)
cmd2 = 'sudo docker rm %s' % (container_id)
dt_utils.exec_cmd(cmd2, logger)
- @classmethod
- def exec_cmd(cls, container_id, sub_cmd, exit_on_error=False):
+ @staticmethod
+ def exec_cmd(container_id, sub_cmd, exit_on_error=False):
cmd = 'sudo docker exec %s /bin/bash -c "%s"' % (container_id, sub_cmd)
dt_utils.exec_cmd(cmd, logger, exit_on_error)
diff --git a/dovetail/parser.py b/dovetail/parser.py
index a9edb36e..621d20a3 100644
--- a/dovetail/parser.py
+++ b/dovetail/parser.py
@@ -20,8 +20,8 @@ logger = dt_logger.Logger('parser.py').getLogger()
class Parser:
'''preprocess configuration files'''
- @classmethod
- def parse_cmd(cls, cmd, testcase):
+ @staticmethod
+ def parse_cmd(cmd, testcase):
cmd_lines = None
try:
template = jinja2.Template(cmd, undefined=jinja2.StrictUndefined)
diff --git a/dovetail/report.py b/dovetail/report.py
index 127c191d..a828d4f3 100644
--- a/dovetail/report.py
+++ b/dovetail/report.py
@@ -30,8 +30,8 @@ class Report:
results = {'functest': {}, 'yardstick': {}}
- @classmethod
- def check_result(cls, testcase, db_result):
+ @staticmethod
+ def check_result(testcase, db_result):
checker = CheckerFactory.create(testcase.script_type())
checker.check(testcase, db_result)
@@ -92,8 +92,8 @@ class Report:
return rpt_text
# save to disk as default
- @classmethod
- def save(cls, report):
+ @staticmethod
+ def save(report):
report_file_name = dovetail_config['report_file']
try:
with open(os.path.join(dovetail_config['result_dir'],
@@ -127,8 +127,8 @@ class Report:
class CrawlerFactory:
- @classmethod
- def create(cls, type):
+ @staticmethod
+ def create(type):
if type == 'functest':
return FunctestCrawler()
@@ -234,8 +234,8 @@ class YardstickCrawler:
class CheckerFactory:
- @classmethod
- def create(cls, type):
+ @staticmethod
+ def create(type):
if type == 'functest':
return FunctestChecker()
@@ -247,13 +247,15 @@ class CheckerFactory:
class ResultChecker:
- def check(cls):
+ @staticmethod
+ def check():
return 'PASS'
class FunctestChecker:
- def check(cls, testcase, db_result):
+ @staticmethod
+ def check(testcase, db_result):
sub_testcase_list = testcase.sub_testcase()
if not db_result:
@@ -286,7 +288,8 @@ class FunctestChecker:
class YardstickChecker:
- def check(cls, testcase, result):
+ @staticmethod
+ def check(testcase, result):
if not result:
testcase.passed(False)
else:
diff --git a/dovetail/testcase.py b/dovetail/testcase.py
index d505420a..b1c3b621 100644
--- a/dovetail/testcase.py
+++ b/dovetail/testcase.py
@@ -27,8 +27,8 @@ class Testcase:
self.testcase['passed'] = False
self.cmds = []
self.sub_testcase_status = {}
- Testcase.update_script_testcase(self.script_type(),
- self.script_testcase())
+ self.update_script_testcase(self.script_type(),
+ self.script_testcase())
def prepare_cmd(self):
for cmd in dovetail_config[self.script_type()]['testcase']['cmds']:
@@ -65,14 +65,13 @@ class Testcase:
def exceed_max_retry_times(self):
# logger.debug('retry times:%d' % self.testcase['retry'])
- return Testcase._exceed_max_retry_times(self.script_type(),
- self.script_testcase())
+ return self._exceed_max_retry_times(self.script_type(),
+ self.script_testcase())
def increase_retry(self):
# self.testcase['retry'] = self.testcase['retry'] + 1
# return self.testcase['retry']
- return Testcase._increase_retry(self.script_type(),
- self.script_testcase())
+ return self._increase_retry(self.script_type(), self.script_testcase())
def passed(self, passed=None):
if passed is not None:
@@ -80,14 +79,14 @@ class Testcase:
return self.testcase['passed']
def script_result_acquired(self, acquired=None):
- return Testcase._result_acquired(self.script_type(),
- self.script_testcase(), acquired)
+ return self._result_acquired(self.script_type(),
+ self.script_testcase(), acquired)
def pre_condition(self):
- return Testcase.pre_condition_cls(self.script_type())
+ return self.pre_condition_cls(self.script_type())
def post_condition(self):
- return Testcase.post_condition_cls(self.script_type())
+ return self.post_condition_cls(self.script_type())
# testcase in upstream testing project
script_testcase_list = {'functest': {}, 'yardstick': {}}
@@ -107,12 +106,12 @@ class Testcase:
cls.scrpit_testcase_list[script_type]['cleaned'] = cleaned
return cls.script_testcase_list[script_type]['cleaned']
- @classmethod
- def pre_condition_cls(cls, script_type):
+ @staticmethod
+ def pre_condition_cls(script_type):
return dovetail_config[script_type]['pre_condition']
- @classmethod
- def post_condition_cls(cls, script_type):
+ @staticmethod
+ def post_condition_cls(script_type):
return dovetail_config[script_type]['post_condition']
@classmethod
@@ -147,7 +146,7 @@ class Testcase:
with open(os.path.join(root, testcase_file)) as f:
testcase_yaml = yaml.safe_load(f)
cls.testcase_list[testcase_yaml.keys()[0]] = \
- Testcase(testcase_yaml)
+ cls(testcase_yaml)
logger.debug(cls.testcase_list)
@classmethod
diff --git a/dovetail/utils/dovetail_logger.py b/dovetail/utils/dovetail_logger.py
index 9cd8719b..8be9c93f 100644
--- a/dovetail/utils/dovetail_logger.py
+++ b/dovetail/utils/dovetail_logger.py
@@ -31,8 +31,8 @@ import dovetail_utils as dt_utils
def clean_results_dir():
result_path = dovetail_config['result_dir']
if os.path.exists(result_path):
- cmd = 'sudo rm -rf %s' % (result_path)
- dt_utils.exec_cmd(cmd)
+ cmd = 'sudo rm -rf %s/*' % (result_path)
+ dt_utils.exec_cmd(cmd, exit_on_error=False)
clean_results_dir()