self.start_time = 0
self.stop_time = 0
self.is_skipped = False
+ self.output_log_name = 'xtesting.log'
+ self.output_debug_log_name = 'xtesting.debug.log'
self.res_dir = "{}/{}".format(self.dir_results, self.case_name)
def __str__(self):
typ, value, traceback = sys.exc_info()
six.reraise(typ, value, traceback)
path = urllib.parse.urlparse(dst_s3_url).path.strip("/")
+ dst_http_url = os.environ["HTTP_DST_URL"]
output_str = "\n"
self.details["links"] = []
- for root, _, files in os.walk(self.dir_results):
+ 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)):
+ # pylint: disable=no-member
+ b3resource.Bucket(bucket_name).upload_file(
+ os.path.join(self.dir_results, log_file),
+ os.path.join(path, log_file))
+ 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:
# pylint: disable=no-member
b3resource.Bucket(bucket_name).upload_file(
os.path.join(path, os.path.relpath(
os.path.join(root, pub_file),
start=self.dir_results)))
- dst_http_url = os.environ["HTTP_DST_URL"]
link = os.path.join(dst_http_url, os.path.relpath(
os.path.join(root, pub_file),
start=self.dir_results))
def test_publish_artifacts1(self, *args):
self.assertEqual(self.test.publish_artifacts(),
testcase.TestCase.EX_OK)
- args[0].assert_called_once_with(self.test.dir_results)
+ args[0].assert_called_once_with(self.test.res_dir)
args[1].assert_called_once_with(
's3', endpoint_url=os.environ['S3_ENDPOINT_URL'])
error_response, 'NoSuchBucket')
self.assertEqual(self.test.publish_artifacts(),
testcase.TestCase.EX_OK)
- args[0].assert_called_once_with(self.test.dir_results)
+ args[0].assert_called_once_with(self.test.res_dir)
args[1].assert_called_once_with(
's3', endpoint_url=os.environ['S3_ENDPOINT_URL'])
+ @mock.patch('os.path.exists', return_value=True)
@mock.patch('boto3.resource')
@mock.patch('os.walk',
return_value=[
def test_publish_artifacts3(self, *args):
self.assertEqual(self.test.publish_artifacts(),
testcase.TestCase.EX_OK)
- args[0].assert_called_once_with(self.test.dir_results)
+ args[0].assert_called_once_with(self.test.res_dir)
expected = [
mock.call('s3', endpoint_url=os.environ['S3_ENDPOINT_URL']),
mock.call().meta.client.head_bucket(Bucket='xtesting'),
mock.call().Bucket('xtesting'),
+ mock.call().Bucket().upload_file(
+ '/var/lib/xtesting/results/xtesting.log',
+ 'prefix/xtesting.log'),
+ mock.call().Bucket('xtesting'),
+ mock.call().Bucket().upload_file(
+ '/var/lib/xtesting/results/xtesting.debug.log',
+ 'prefix/xtesting.debug.log'),
+ mock.call().Bucket('xtesting'),
mock.call().Bucket().upload_file(
'/var/lib/xtesting/results/bar', 'prefix/bar')]
self.assertEqual(args[1].mock_calls, expected)