summaryrefslogtreecommitdiffstats
path: root/dovetail/test_runner.py
diff options
context:
space:
mode:
authorxudan <xudan16@huawei.com>2018-12-11 01:41:15 -0500
committerxudan <xudan16@huawei.com>2018-12-11 02:03:31 -0500
commit13e644d0ba893ddc5e2944c2e827fde7cd58ae72 (patch)
treecb4bc6a43179593a7ec7a1dfc3b3e5c7cfcc9ea6 /dovetail/test_runner.py
parentbdbd7d405ac8603deed456e038cd13b0fde02b62 (diff)
Enable ShellRunner
1. fix the bug 'ShellRunner' object has no attribute 'archive_logs' 2. remove the testarea_supported because it's not very necessary for the test cases themselves and can make it a little more simple to add a test case with new test area JIRA: DOVETAIL-750 Change-Id: I71ee74615200376adca2a0db040753e5fce329bc Signed-off-by: xudan <xudan16@huawei.com>
Diffstat (limited to 'dovetail/test_runner.py')
-rw-r--r--dovetail/test_runner.py64
1 files changed, 33 insertions, 31 deletions
diff --git a/dovetail/test_runner.py b/dovetail/test_runner.py
index d77c3c65..884ce1ad 100644
--- a/dovetail/test_runner.py
+++ b/dovetail/test_runner.py
@@ -21,7 +21,7 @@ import utils.dovetail_utils as dt_utils
import utils.dovetail_logger as dt_logger
-class DockerRunner(object):
+class Runner(object):
logger = None
@@ -29,6 +29,36 @@ class DockerRunner(object):
self.testcase = testcase
self.logger.debug('Create runner: {}'.format(self.type))
+ def archive_logs(self):
+ result_path = os.path.join(os.environ['DOVETAIL_HOME'], 'results')
+ src_files = dt_utils.get_value_from_dict(
+ 'report.source_archive_files', self.testcase.testcase)
+ dest_files = dt_utils.get_value_from_dict(
+ 'report.dest_archive_files', self.testcase.testcase)
+ if not src_files and not dest_files:
+ return True
+ if not (src_files and dest_files) or len(src_files) != len(dest_files):
+ self.logger.error("Can't find corresponding 'result_dest_files' "
+ "for 'result_source_files' with testcase {}"
+ .format(self.testcase.name()))
+ return False
+ res = True
+ for index in range(0, len(src_files)):
+ src_file_path = os.path.join(result_path, src_files[index])
+ dest_file_path = os.path.join(result_path, dest_files[index])
+ if os.path.isfile(src_file_path):
+ os.renames(src_file_path, dest_file_path)
+ else:
+ self.logger.error("Can't find file {}.".format(src_file_path))
+ res = False
+ return res
+
+
+class DockerRunner(Runner):
+
+ def __init__(self, testcase):
+ super(DockerRunner, self).__init__(testcase)
+
@classmethod
def create_log(cls):
cls.logger = dt_logger.Logger(__name__ + '.DockerRunner').getLogger()
@@ -110,30 +140,6 @@ class DockerRunner(object):
if not dt_cfg.dovetail_config['noclean']:
container.clean()
- def archive_logs(self):
- result_path = os.path.join(os.environ['DOVETAIL_HOME'], 'results')
- src_files = dt_utils.get_value_from_dict(
- 'report.source_archive_files', self.testcase.testcase)
- dest_files = dt_utils.get_value_from_dict(
- 'report.dest_archive_files', self.testcase.testcase)
- if not src_files and not dest_files:
- return True
- if not (src_files and dest_files) or len(src_files) != len(dest_files):
- self.logger.error("Can't find corresponding 'result_dest_files' "
- "for 'result_source_files' with testcase {}"
- .format(self.testcase.name()))
- return False
- res = True
- for index in range(0, len(src_files)):
- src_file_path = os.path.join(result_path, src_files[index])
- dest_file_path = os.path.join(result_path, dest_files[index])
- if os.path.isfile(src_file_path):
- os.renames(src_file_path, dest_file_path)
- else:
- self.logger.error("Can't find file {}.".format(src_file_path))
- res = False
- return res
-
@staticmethod
def _render(task_template, **kwargs):
return jinja2.Template(task_template).render(**kwargs)
@@ -239,19 +245,15 @@ class BottlenecksRunner(DockerRunner):
self._update_config(testcase)
-class ShellRunner(object):
-
- logger = None
+class ShellRunner(Runner):
@classmethod
def create_log(cls):
cls.logger = dt_logger.Logger(__name__ + '.ShellRunner').getLogger()
def __init__(self, testcase):
- super(ShellRunner, self).__init__()
- self.testcase = testcase
self.type = 'shell'
- self.logger.debug('Create runner: {}'.format(self.type))
+ super(ShellRunner, self).__init__(testcase)
def run(self):
testcase_passed = 'PASS'