Skip to content

Commit 0f5f587

Browse files
MTV-4058 - Upload Test results to Report Portal (kubev2v#2139)
* Resolves: MTV-4058 | enable Upload to Report Portal Signed-off-by: Pedro Abreu <[email protected]> * fix linting issues Resolves: MTV-4058 Signed-off-by: Pedro Abreu <[email protected]> --------- Signed-off-by: Pedro Abreu <[email protected]>
1 parent b7beec8 commit 0f5f587

File tree

2 files changed

+103
-9
lines changed

2 files changed

+103
-9
lines changed

testing/PlaywrightContainerFile

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,41 @@ LABEL org.opencontainers.image.created="${BUILD_DATE}" \
1313
ENV LC_ALL=en_US \
1414
IMAGE_VERSION="${VERSION}" \
1515
IMAGE_GIT_COMMIT="${GIT_COMMIT}" \
16-
IMAGE_BUILD_DATE="${BUILD_DATE}"
17-
18-
# NFS mount path for OVA file cleanup
19-
ENV NFS_MOUNT_PATH=""
16+
IMAGE_BUILD_DATE="${BUILD_DATE}" \
17+
NFS_MOUNT_PATH=""
2018

2119
WORKDIR /test-runner
2220

21+
USER root
22+
23+
# Install system dependencies
24+
RUN apt-get update && apt-get install -y --no-install-recommends \
25+
curl ca-certificates python3 python3-pip \
26+
&& apt-get clean && rm -rf /var/lib/apt/lists/*
27+
28+
# Install OpenShift CLI tools
29+
RUN curl -sL https://mirror.openshift.com/pub/openshift-v4/clients/ocp/stable/openshift-client-linux.tar.gz \
30+
| tar -xz -C /usr/local/bin oc kubectl \
31+
&& chmod +x /usr/local/bin/oc /usr/local/bin/kubectl
32+
33+
# Install Python dependencies for Report Portal
34+
RUN pip3 install --no-cache-dir --break-system-packages \
35+
PyYAML requests lxml 'reportportal-client~=5.0.0' \
36+
xmltodict jinja2 packaging setuptools suds-py3
37+
38+
# Clone Report Portal uploader
39+
RUN GIT_SSL_NO_VERIFY=1 git clone \
40+
https://gitlab.cee.redhat.com/migrationqe/rp-uploader.git \
41+
/opt/rp-uploader
42+
2343
COPY package.json yarn.lock ./
24-
RUN corepack enable && \
25-
yarn install --frozen-lockfile --ignore-scripts
44+
RUN corepack enable && yarn install --frozen-lockfile --ignore-scripts
2645

2746
COPY . .
2847

29-
RUN chmod +x run-tests.sh && \
30-
chown -R 1001:0 /test-runner && \
31-
chmod -R g+w /test-runner
48+
RUN chmod +x run-tests.sh upload-to-rp.sh && \
49+
chown -R 1001:0 /test-runner /opt/rp-uploader && \
50+
chmod -R g+w /test-runner /opt/rp-uploader
3251

3352
USER 1001
3453

testing/upload-to-rp.sh

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# ==============================================================================
5+
# Script for uploading test results to Report Portal.
6+
#
7+
# Required Environment Variables:
8+
# - JUNIT_XML: Path to junit.xml file
9+
# - CLUSTER_NAME: OCP cluster name
10+
# - VSPHERE_PROVIDER: vSphere provider version
11+
# - TEST_TYPE: Test type (upstream/downstream/tier1/etc)
12+
# - KUBECONFIG_PATH: Path to kubeconfig file
13+
# - KUBE_PASSWORD: kubeadmin password
14+
# - BUILD_URL: (Optional) Jenkins build URL for launch description
15+
#
16+
# ==============================================================================
17+
18+
log() {
19+
local message="$1"
20+
echo "--- $message ---"
21+
return 0
22+
}
23+
24+
log "Report Portal Upload Script"
25+
26+
# Validate required environment variables
27+
for var in JUNIT_XML CLUSTER_NAME VSPHERE_PROVIDER TEST_TYPE KUBECONFIG_PATH KUBE_PASSWORD; do
28+
if [[ -z "${!var}" ]]; then
29+
echo "ERROR: $var environment variable is not set." >&2
30+
exit 1
31+
fi
32+
done
33+
34+
if [[ ! -f "$JUNIT_XML" ]]; then
35+
echo "ERROR: junit.xml not found at $JUNIT_XML" >&2
36+
exit 1
37+
fi
38+
39+
log "Logging into OpenShift cluster"
40+
SERVER_URL=$(grep 'server:' "$KUBECONFIG_PATH" | awk '{print $2}' | head -n 1)
41+
oc login --insecure-skip-tls-verify=true -u kubeadmin -p "$KUBE_PASSWORD" "$SERVER_URL"
42+
43+
log "Extracting cluster versions"
44+
MTV_VERSION=$(oc get csv -n openshift-mtv -o jsonpath='{.items[*].spec.version}' | awk '{print $NF}')
45+
OCP_VERSION=$(oc get clusterversion | grep -oE '([0-9]+\.)+[0-9]+' | tail -1)
46+
CNV_VERSION=$(oc get csv -n openshift-cnv -o jsonpath='{.items[*].spec.version}')
47+
48+
# Handle empty versions
49+
MTV_VERSION=${MTV_VERSION:-UNKNOWN}
50+
OCP_VERSION=${OCP_VERSION:-UNKNOWN}
51+
CNV_VERSION=${CNV_VERSION:-UNKNOWN}
52+
53+
# Build launch name and tags
54+
LAUNCH_NAME="mtv-ui-${MTV_VERSION}-${VSPHERE_PROVIDER}-${TEST_TYPE}"
55+
TAGS="{OCP_VERSION:${OCP_VERSION},MTV_VERSION:${MTV_VERSION},CNV_VERSION:${CNV_VERSION},VSPHERE_PROVIDER:${VSPHERE_PROVIDER},TEST_TYPE:${TEST_TYPE}}"
56+
57+
log "Report Portal Upload Configuration"
58+
echo " LAUNCH_NAME: $LAUNCH_NAME"
59+
echo " MTV VERSION: $MTV_VERSION"
60+
echo " OCP VERSION: $OCP_VERSION"
61+
echo " CNV VERSION: $CNV_VERSION"
62+
echo " TAGS: $TAGS"
63+
64+
log "Uploading to Report Portal"
65+
cd /opt/rp-uploader
66+
python3 src/rpuploader/rp_cli.py \
67+
--strategy Mtv \
68+
--xunit_feed "$JUNIT_XML" \
69+
--config mtv_conf.yaml \
70+
--launch_name "$LAUNCH_NAME" \
71+
--launch_description "${BUILD_URL:-local}" \
72+
--launch_tags "$TAGS"
73+
74+
log "Upload complete"
75+

0 commit comments

Comments
 (0)