[rp-reporter] Add rockoon version to the attributes
Related-Prod: PRODX-48948
Change-Id: Ib666e8357ce8067341d406399c2713516343d412
diff --git a/rp_reporter/rp_reporter/batch_reporter.py b/rp_reporter/rp_reporter/batch_reporter.py
index a38e1b7..9f3be01 100755
--- a/rp_reporter/rp_reporter/batch_reporter.py
+++ b/rp_reporter/rp_reporter/batch_reporter.py
@@ -1,6 +1,11 @@
import click
import logging
+
+import ipdb
+import wget
+import yaml
import itertools
+import jmespath
import jenkins_jinny.main as jj
from copy import deepcopy
@@ -8,17 +13,11 @@
LOG = logging.getLogger("rp_reporter")
-def upload_job(job:str, suite_per_job=False, tags=None):
- if isinstance(job, str):
- job = jj.Build(job)
- if not tags:
- tags = dict()
-
- print(f"│˶˙ᵕ˙˶)꜆ I take {job}")
-
+def get_tags(job: jj.Build):
+ tags = dict()
tags["start_time"] = job.start_time.strftime("%Y-%m-%d-%H-%M-%S")
- if context_name:=job.param.OPENSTACK_CONTEXT_NAME:
+ if context_name := job.param.OPENSTACK_CONTEXT_NAME:
tags["openstack"] = context_name.split("/")[0]
tags["context"] = context_name.split("/")[-1]
@@ -28,6 +27,17 @@
tags["mosk_version"] = "mosk-25.1"
else:
tags["mosk_version"] = "master"
+ return tags
+
+def upload_job(job:str, suite_per_job=False, tags=None):
+ if isinstance(job, str):
+ job = jj.Build(job)
+ if not tags:
+ tags = dict()
+
+ print(f"│˶˙ᵕ˙˶)꜆ I take {job}")
+
+ tags.update(get_tags(job))
# deploy_job = job.get_child_jobs("deploy-openstack-k8s-env")[0]
# for file_location in deploy_job.get_artifacts("deployed.yaml"):
@@ -51,6 +61,7 @@
# item_id=launch_id
)
for child in itertools.chain([job], job.heirs):
+ child: jj.Build
rp_client.log(time=timestamp(),
message=f"{child} {child.status} {child.url}",
# item_id=launch_id
@@ -59,6 +70,25 @@
test_tags = deepcopy(tags)
test_results_files = None
match child.name:
+ case "deploy-openstack-k8s-env":
+ # ipdb.set_trace()
+ osdpl_file = child.get_artifacts("deployed.yaml")
+ if not osdpl_file:
+ LOG.error(f"Can't find osdpl file in {job}")
+ continue
+ osdpl_content = yaml.safe_load(open(osdpl_file[0], "rb"))
+ osdpl_dictionary = yaml.safe_load(osdpl_content)
+ found_osdpl = jmespath.search("items[*].status.version", osdpl_dictionary)
+ if not found_osdpl:
+ LOG.error(f"Can't find osdpl info in {job}")
+ continue
+
+ tags["rockoon_version"] = found_osdpl[0]
+ rp_client.update_test_item(
+ attributes=tags,
+ item_uuid=launch_id
+ )
+
case "tempest-runner-k8s":
title = "Tempest"
test_results_files = [file_url
diff --git a/rp_reporter/rp_reporter/report_from_xml.py b/rp_reporter/rp_reporter/report_from_xml.py
index d55171e..a5cb6ab 100644
--- a/rp_reporter/rp_reporter/report_from_xml.py
+++ b/rp_reporter/rp_reporter/report_from_xml.py
@@ -10,6 +10,7 @@
import wget
import time
import uuid
+import jmespath
from typing import Optional
from xml.etree import ElementTree
@@ -52,6 +53,7 @@
class Reporter:
+ client: RPClient
def __init__(self, client=None):
if not client:
self.client = RPClient(endpoint=RP_ENDPOINT,