[rp-reporter] Add image info to the tempest/report suites
Related-Prod: PRODX-53429
Change-Id: I80c1468305171fab301ee88ce363790ed3a76c38
diff --git a/rp_reporter/rp_reporter/batch_reporter.py b/rp_reporter/rp_reporter/batch_reporter.py
index 5cbcc04..7dd60d7 100755
--- a/rp_reporter/rp_reporter/batch_reporter.py
+++ b/rp_reporter/rp_reporter/batch_reporter.py
@@ -1,14 +1,18 @@
#!/usr/bin/python
+import random
+
import click
import jenkins_jinny.main as jj
import jmespath
import itertools
import logging
import yaml
+import uuid
from collections import deque
from time import sleep
from typing import List, Optional
+from pathlib import Path
from pbr.version import VersionInfo
from rp_reporter.settings import TIME_FORMAT
@@ -76,9 +80,8 @@
def add_test_result(self, test_name=None,
testrail_url=None, rp_url=None, statistics=None):
testrail_msg = f"[TestRailURL]({testrail_url})" if testrail_url else ""
-
+ self.rp_url = rp_url
test_result = (f"{test_name} {testrail_msg} "
- f"[RP_URL]({rp_url}) "
f"{statistics}")
self.test_results.append(test_result)
@@ -90,6 +93,7 @@
f"{self.job_link}\n"
f"`{self.rockoon_version}`\n"
f"{test_results}\n"
+ f"[RP_URL]({self.rp_url}) \n"
f"___\n")
def get_tags(job: jj.Build):
@@ -141,6 +145,32 @@
return tags
+def get_image_from_describe(job_obj, describe_file_pattern, image_pattern,
+ from_artifactory=False):
+ if from_artifactory:
+ local_describe_file = job_obj.get_artifacts(describe_file_pattern)
+ if not local_describe_file:
+ LOG.info(f"Can't find {describe_file_pattern} in {job_obj} artifactory")
+ local_describe_file = local_describe_file[0]
+ else:
+ describe_file_url = [file_url
+ for file_url in job_obj.get_link_from_description()
+ if describe_file_pattern in file_url]
+ if not describe_file_url:
+ LOG.info(f"Can't find {describe_file_pattern} in {job_obj} "
+ f"description")
+ return
+ temp_dir = Path("/tmp") / uuid.uuid4().hex.upper()
+ temp_dir.mkdir(parents=True, exist_ok=True)
+ local_describe_file = temp_dir / describe_file_pattern
+ job_obj.download_file(describe_file_url[0], local_describe_file)
+
+ with open(local_describe_file) as file:
+ for line in file.readlines():
+ if image_pattern in line and "Image:" in line:
+ image = line.strip()
+ return image
+
def report_job_status(job: jj.Build, job_suite_id: str, reporter: Reporter):
rp_client = reporter.client
@@ -228,6 +258,11 @@
attributes=tags,
description=f"Deployed job {job.url} by {job.triggered_by}"
)
+ if not rp_client.get_launch_info():
+ LOG.error(f"[FIXME] Launch {launch_id} is not created ")
+ # import ipdb;
+ # ipdb.set_trace()
+ # assert False
print(f"(^-^)_日 report will be here {rp_client.get_launch_ui_url()}")
job_suite_id = rp_client.start_test_item(
name="CI jobs",
@@ -253,6 +288,7 @@
test_tags = dict()
print(f"⫍⌕⫎ tests in {child}")
test_results_files = None
+ suite_description = ""
match child.name:
case "deploy-openstack-k8s-env":
if base_ubuntu := job.param.HEAT_BASE_IMAGE_DISTRO:
@@ -279,24 +315,42 @@
description.rockoon_version = tags.get("rockoon_version")
case "tempest-runner-k8s":
title = "Tempest"
-
test_results_files = [file_url
for file_url in child.get_link_from_description()
if "tempest_report.xml" in file_url]
+
+ image = get_image_from_describe(
+ job_obj=child,
+ describe_file_pattern="tempest_pod.describe",
+ image_pattern="/openstack/tempest:")
+ suite_description += f"{image}<br>"
+
+ if test_scheme := yaml.safe_load(child.param.TEST_SCHEME):
+ suite_description += f"regex: {test_scheme.get('regex')}<br>"
+
case "stepler-runner-k8s":
title = "Stepler"
test_results_files = child.get_artifacts("stepler_test_results.xml")
if not test_results_files:
LOG.error(f"Can't found 'stepler_test_results.xml' in "
f"{child.url} artifacts")
+ import ipdb; ipdb.set_trace()
+ image = get_image_from_describe(
+ job_obj=child,
+ describe_file_pattern="stepler_pod.describe",
+ image_pattern="/openstack/stepler:",
+ from_artifactory=True
+ )
+ suite_description += f"{image}<br>"
+
case "oscore-si-tests-runner-k8s":
title = "SI tests"
- test_tags["test"] = child.param.RUN_TESTS
test_results_files = [file_url
for file_url in child.get_link_from_description()
if "si_test_report.xml" in file_url ]
if not test_results_files:
LOG.error(f"Can't found 'si_test_report.xml' in {child.url}")
+
case "oscore-functional-tests-runner":
title = "Rockoon Functional"
test_results_files = [file_url
@@ -304,6 +358,7 @@
if "si_test_report.xml" in file_url]
if not test_results_files:
LOG.error(f"Can't found 'si_test_report.xml' in {child.url}")
+
case "si-test-check-downtime-statistic":
title = "Downtime tests"
test_results_files = [
@@ -312,10 +367,16 @@
]
if not test_results_files:
LOG.error(f"Can't found 'test_check_downtime_statistic_result.xml' in {child.url}")
+
case "collect-openstack-kaas-artifacts":
artifactory_url = child.description.split("url: ")[-1]
rp_client.log(time=timestamp(),
message=f"Pod Logs {artifactory_url}/pod-logs.tar.gz")
+
+ if child.param.RUN_TESTS:
+ suite_description += f"RUN_TESTS = {child.param.RUN_TESTS}<br>"
+ test_tags["test"] = child.param.RUN_TESTS
+
if not test_results_files:
# We can iterate by child jobs which don't contain any reports
continue
@@ -332,6 +393,7 @@
title = title,
attributes=test_tags,
link=job.url,
+ description=suite_description,
to_specific_launch=launch_id))
)
@@ -341,10 +403,11 @@
title = title,
attributes=test_tags,
link=job.url,
+ description=suite_description,
to_specific_launch=launch_id,
)
description.add_test_result(
- test_name=f"{title} {test_tags.get('test', '')}",
+ test_name=f"{title} {test_tags.get('test', '')} ",
testrail_url=testrail_url[0] if testrail_url else None,
rp_url=rp_client.get_launch_ui_url(),
statistics=stats
diff --git a/rp_reporter/rp_reporter/report_from_xml.py b/rp_reporter/rp_reporter/report_from_xml.py
index 652907f..2b044b6 100644
--- a/rp_reporter/rp_reporter/report_from_xml.py
+++ b/rp_reporter/rp_reporter/report_from_xml.py
@@ -91,7 +91,8 @@
project=RP_PROJECT,
api_key=RP_APIKEY,
is_skipped_an_issue=False,
- truncate_attributes=False
+ truncate_attributes=False,
+ retries=15
)
self.scheduled = list()
self.uuid_by_subfolder = dict()
@@ -141,7 +142,7 @@
return parent_folder
def report_xml(self, report_path, title, attributes=None,
- link=None, to_specific_launch=None):
+ link=None, description="", to_specific_launch=None):
ts: xunitparser.TestSuite
tr: xunitparser.TestResult
tc: xunitparser.TestCase
@@ -173,7 +174,10 @@
start_time=timestamp(),
attributes=attributes or None,
item_type="suite",
- description=f"{link} \n uploaded from report {report_path} ",
+ description=f"{description} <br>"
+ f"<a href='{link}'>Jenkins Job</a><br> "
+ f"Uploaded from <a href='{report_path}'>report</a>"
+
)
LOG.debug(
f"start_test_item {test_suite=} item_type=suite name={title}")