diff options
author | xudan <xudan16@huawei.com> | 2018-05-24 04:47:41 -0400 |
---|---|---|
committer | Georg Kunz <georg.kunz@ericsson.com> | 2018-05-27 20:19:34 +0000 |
commit | 01e07c1c56d8a40cff50b077b18157decca39a5c (patch) | |
tree | da7b0e2d72dc8548388272e07db37107833bc8c9 /dovetail/test_runner.py | |
parent | 3c0569b1e16f35d4b14a60ed25113d6d7a398272 (diff) |
Archive all test case result files
1. All detailed tempest test cases results are recorded with
file tempest-report.html rather than tempest.log now.
2. Archive all results files include functest.log, yardstick.log ...
for each test case. Otherwise, they will all be in one log file.
3. Support to set the source files and dest files need to be archived with
the test case config files rather than hardcode with the source code.
4. Give the file which used to be parse the results (PASS/FAIL) with the
test case config files rather than hardcode with the source code.
Change-Id: I30f435d91ab90cf20def47007f177fe98187484d
Signed-off-by: xudan <xudan16@huawei.com>
Diffstat (limited to 'dovetail/test_runner.py')
-rw-r--r-- | dovetail/test_runner.py | 52 |
1 files changed, 23 insertions, 29 deletions
diff --git a/dovetail/test_runner.py b/dovetail/test_runner.py index aba457e5..44eddabd 100644 --- a/dovetail/test_runner.py +++ b/dovetail/test_runner.py @@ -116,8 +116,29 @@ class DockerRunner(object): if not dt_cfg.dovetail_config['noclean']: Container.clean(container_id, self.type) - def save_logs(self): - pass + 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): @@ -170,33 +191,6 @@ class FunctestRunner(DockerRunner): self.type = 'functest' super(FunctestRunner, self).__init__(testcase) - def save_logs(self): - validate_testcase = self.testcase.validate_testcase() - test_area = self.testcase.name().split(".")[1] - result_path = os.path.join(os.environ["DOVETAIL_HOME"], 'results') - dest_path = os.path.join(result_path, test_area + '_logs') - dest_file = os.path.join(dest_path, self.testcase.name() + '.log') - if validate_testcase == 'tempest_custom': - source_file = os.path.join(result_path, 'tempest', 'tempest.log') - elif validate_testcase == 'refstack_defcore': - source_file = os.path.join(result_path, 'refstack', 'tempest.log') - elif validate_testcase == 'bgpvpn': - source_file = os.path.join(result_path, 'bgpvpn.log') - elif validate_testcase == 'patrole': - source_file = os.path.join(result_path, 'patrole', 'tempest.log') - elif validate_testcase == 'neutron_trunk': - source_file = os.path.join(result_path, - 'neutron_trunk', - 'tempest.log') - else: - source_file = None - if source_file: - if os.path.isfile(source_file): - os.renames(source_file, dest_file) - else: - self.logger.error("Tempest log file for test case {} is not " - "found.".format(self.testcase.name())) - class YardstickRunner(DockerRunner): |