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'])
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)
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)
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'],
class CrawlerFactory:
- @classmethod
- def create(cls, type):
+ @staticmethod
+ def create(type):
if type == 'functest':
return FunctestCrawler()
class CheckerFactory:
- @classmethod
- def create(cls, type):
+ @staticmethod
+ def create(type):
if type == 'functest':
return FunctestChecker()
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:
class YardstickChecker:
- def check(cls, testcase, result):
+ @staticmethod
+ def check(testcase, result):
if not result:
testcase.passed(False)
else:
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']:
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:
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': {}}
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
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