diff options
author | Cédric Ollivier <cedric.ollivier@orange.com> | 2019-11-16 16:21:44 +0100 |
---|---|---|
committer | Cédric Ollivier <cedric.ollivier@orange.com> | 2019-11-16 16:23:15 +0100 |
commit | e2e7dbe185a552b21315063dbbed8ac4f40f309d (patch) | |
tree | 7c66245213c1224ed76c4dae8c6d7aebb057b123 /xtesting/core | |
parent | a48c62165923be6a37aaff5d54918dbe9cb6ff58 (diff) |
Add ContentType when publishing artifacts
The default value 'application/octet-stream' is mostly
incorrect and forces downloading all links.
https://build.opnfv.org/ci/job/functest-opnfv-functest-healthcheck-hunter-connection_check-run/436/console
Change-Id: Ia680654f5e9f67154504264bc380f0a8d6a74d85
Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
Diffstat (limited to 'xtesting/core')
-rw-r--r-- | xtesting/core/testcase.py | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/xtesting/core/testcase.py b/xtesting/core/testcase.py index 54baaae7..c3b8f61b 100644 --- a/xtesting/core/testcase.py +++ b/xtesting/core/testcase.py @@ -13,6 +13,7 @@ import abc from datetime import datetime import json import logging +import mimetypes import os import re import sys @@ -301,21 +302,33 @@ class TestCase(): self.details["links"] = [] for log_file in [self.output_log_name, self.output_debug_log_name]: if os.path.exists(os.path.join(self.dir_results, log_file)): + abs_file = os.path.join(self.dir_results, log_file) + mime_type = mimetypes.guess_type(abs_file) + self.__logger.debug( + "Publishing %s %s", abs_file, mime_type) # pylint: disable=no-member b3resource.Bucket(bucket_name).upload_file( - os.path.join(self.dir_results, log_file), - os.path.join(path, log_file)) + abs_file, + os.path.join(path, log_file), + ExtraArgs={'ContentType': mime_type[ + 0] or 'application/octet-stream'}) link = os.path.join(dst_http_url, log_file) output_str += "\n{}".format(link) self.details["links"].append(link) for root, _, files in os.walk(self.res_dir): for pub_file in files: + abs_file = os.path.join(root, pub_file) + mime_type = mimetypes.guess_type(abs_file) + self.__logger.debug( + "Publishing %s %s", abs_file, mime_type) # pylint: disable=no-member b3resource.Bucket(bucket_name).upload_file( - os.path.join(root, pub_file), + abs_file, os.path.join(path, os.path.relpath( os.path.join(root, pub_file), - start=self.dir_results))) + start=self.dir_results)), + ExtraArgs={'ContentType': mime_type[ + 0] or 'application/octet-stream'}) link = os.path.join(dst_http_url, os.path.relpath( os.path.join(root, pub_file), start=self.dir_results)) |