-
Notifications
You must be signed in to change notification settings - Fork 2.2k
[WIP] MPIIT: Use ExitTrap--PostProcessPrep for CNV (Virt) test mapping #78731
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
0a65565
69a741b
8227a59
2979b40
092735e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,17 +1,42 @@ | ||||||||||
| #!/bin/bash | ||||||||||
|
|
||||||||||
| set -o nounset | ||||||||||
| set -o errexit | ||||||||||
| set -o pipefail | ||||||||||
|
|
||||||||||
| start_time=$SECONDS | ||||||||||
| set -euo pipefail; shopt -s inherit_errexit | ||||||||||
|
|
||||||||||
| # This trap will be executed when the script exits for any reason (successful, error, or signal). | ||||||||||
| trap 'debug_on_exit' EXIT | ||||||||||
| if [ "${MAP_TESTS}" = "true" ]; then | ||||||||||
| # Map results by setting identifier prefix in tests suites names for reporting tools | ||||||||||
| # Merge original results into a single file and compress | ||||||||||
| # Send modified file to shared dir for Data Router Reporter step (run here so EXIT stays debug_on_exit). | ||||||||||
| eval "$( | ||||||||||
| curl -fsSL \ | ||||||||||
| https://raw.githubusercontent.com/RedHatQE/OpenShift-LP-QE--Tools/refs/heads/main/libs/bash/ci-operator/interop/common/ExitTrap--PostProcessPrep.sh | ||||||||||
| )"; trap ' | ||||||||||
| typeset scriptExit=$? | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||||||
| LP_IO__ET_PPP__NEW_TS_NAME="${REPORTPORTAL_CMP}--%s" \ | ||||||||||
| ExitTrap--PostProcessPrep junit--cnv__interop-tests__openshift-virtualization-tests.xml || true | ||||||||||
| debug_on_exit "${scriptExit}" | ||||||||||
| ' EXIT | ||||||||||
|
coderabbitai[bot] marked this conversation as resolved.
|
||||||||||
| else | ||||||||||
| trap 'debug_on_exit' EXIT | ||||||||||
| fi | ||||||||||
|
|
||||||||||
| typeset start_time=${SECONDS} | ||||||||||
| typeset binFolder='' | ||||||||||
| typeset ocUrl='' | ||||||||||
| typeset hcoSubscription='' | ||||||||||
| typeset rc=0 | ||||||||||
| typeset ARTIFACTORY_USER='' | ||||||||||
| typeset ARTIFACTORY_TOKEN='' | ||||||||||
| typeset ARTIFACTORY_SERVER='' | ||||||||||
| typeset ACCESS_TOKEN='' | ||||||||||
| typeset ORGANIZATION_ID='' | ||||||||||
| typeset -x OPENSHIFT_PYTHON_WRAPPER_LOG_FILE="${ARTIFACT_DIR}/openshift_python_wrapper.log" | ||||||||||
| typeset -x JUNIT_RESULTS_FILE="${ARTIFACT_DIR}/junit_results.xml" | ||||||||||
| typeset -x HTML_RESULTS_FILE="${ARTIFACT_DIR}/report.html" | ||||||||||
|
|
||||||||||
| # shellcheck disable=SC2329 | ||||||||||
| debug_on_exit() { | ||||||||||
| local exit_code=$? | ||||||||||
| # First argument is the script exit status when the EXIT trap ran other handlers first (e.g. ExitTrap--PostProcessPrep). | ||||||||||
| local exit_code="${1:-$?}" | ||||||||||
| local end_time=$SECONDS | ||||||||||
| local execution_time=$((end_time - start_time)) | ||||||||||
| local debug_threshold=720 # 12 minutes in seconds | ||||||||||
|
|
@@ -63,7 +88,6 @@ function getMustGatherImage() { | |||||||||
| | .spec.relatedImages[] | ||||||||||
| | select(.name | contains("must-gather")) | ||||||||||
| | .image' | ||||||||||
|
|
||||||||||
| } | ||||||||||
|
|
||||||||||
| # shellcheck disable=SC2329 | ||||||||||
|
|
@@ -90,11 +114,11 @@ function retry() { | |||||||||
| until "$@"; do | ||||||||||
| exit_code=$? | ||||||||||
| count=$((count + 1)) | ||||||||||
| if [ $count -lt $max_retries ]; then | ||||||||||
| echo "Command failed. Attempt $count/$max_retries. Retrying in $delay seconds..." | ||||||||||
| sleep $delay | ||||||||||
| if [ "${count}" -lt "${max_retries}" ]; then | ||||||||||
| # Command failed. Attempt ${count}/${max_retries}. | ||||||||||
| sleep "${delay}" | ||||||||||
| else | ||||||||||
| echo "Command failed after $max_retries attempts." | ||||||||||
| # Command failed after $max_retries attempts. | ||||||||||
| return $exit_code | ||||||||||
| fi | ||||||||||
| done | ||||||||||
|
|
@@ -146,6 +170,7 @@ function cnv::reimport_datavolumes() { | |||||||||
| local retry_count=0 | ||||||||||
| local max_retries=10 | ||||||||||
| local interval=30 | ||||||||||
| local volumesnapshotcontent_name='' | ||||||||||
| while [[ $retry_count -lt $max_retries ]]; do | ||||||||||
| echo "Attempting to delete all volumesnapshots in namespace ${dvnamespace} (Attempt $((retry_count + 1)) of ${max_retries})..." | ||||||||||
|
|
||||||||||
|
|
@@ -182,42 +207,11 @@ function cnv::reimport_datavolumes() { | |||||||||
| oc get pvc -n "${dvnamespace}" | ||||||||||
| } | ||||||||||
|
|
||||||||||
| function install_yq_if_not_exists() { | ||||||||||
| # Install yq manually if not found in image | ||||||||||
| echo "Checking if yq exists" | ||||||||||
| cmd_yq="$(yq --version 2>/dev/null || true)" | ||||||||||
| if [ -n "$cmd_yq" ]; then | ||||||||||
| echo "yq version: $cmd_yq" | ||||||||||
| else | ||||||||||
| echo "Installing yq" | ||||||||||
| mkdir -p /tmp/bin | ||||||||||
| export PATH=$PATH:/tmp/bin/ | ||||||||||
| curl -L "https://github.com/mikefarah/yq/releases/latest/download/yq_linux_$(uname -m | sed 's/aarch64/arm64/;s/x86_64/amd64/')" \ | ||||||||||
| -o /tmp/bin/yq && chmod +x /tmp/bin/yq | ||||||||||
| fi | ||||||||||
| } | ||||||||||
|
|
||||||||||
| function mapTestsForComponentReadiness() { | ||||||||||
|
|
||||||||||
| [[ ${MAP_TESTS:-false} != "true" ]] && return | ||||||||||
|
|
||||||||||
| results_file="${1}" | ||||||||||
| echo "Patching Tests Result File: ${results_file}" | ||||||||||
| if [ -f "${results_file}" ]; then | ||||||||||
| install_yq_if_not_exists | ||||||||||
| echo "Mapping Test Suite Name To: CNV-lp-interop" | ||||||||||
| yq eval -px -ox -iI0 '.testsuites.testsuite.+@name="CNV-lp-interop"' $results_file | ||||||||||
| fi | ||||||||||
| } | ||||||||||
|
|
||||||||||
| BIN_FOLDER=$(mktemp -d /tmp/bin.XXXX) | ||||||||||
| OC_URL="https://mirror.openshift.com/pub/openshift-v4/amd64/clients/ocp/latest/openshift-client-linux.tar.gz" | ||||||||||
| binFolder="$(mktemp -d /tmp/bin.XXXX)" | ||||||||||
| ocUrl='https://mirror.openshift.com/pub/openshift-v4/amd64/clients/ocp/latest/openshift-client-linux.tar.gz' | ||||||||||
|
|
||||||||||
| # Exports | ||||||||||
| export PATH="${BIN_FOLDER}:${PATH}" | ||||||||||
| export OPENSHIFT_PYTHON_WRAPPER_LOG_FILE="${ARTIFACT_DIR}/openshift_python_wrapper.log" | ||||||||||
| export JUNIT_RESULTS_FILE="${ARTIFACT_DIR}/junit_results.xml" | ||||||||||
| export HTML_RESULTS_FILE="${ARTIFACT_DIR}/report.html" | ||||||||||
| export PATH="${binFolder}:${PATH}" | ||||||||||
| set +x # We don't want to see it in the logs | ||||||||||
| ARTIFACTORY_USER=$(head -1 "${BW_PATH}"/artifactory-user || printf ci-read-only-user) | ||||||||||
| ARTIFACTORY_TOKEN=$(head -1 "${BW_PATH}"/artifactory-token) | ||||||||||
|
|
@@ -239,10 +233,10 @@ unset KUBERNETES_PORT_443_TCP_PORT | |||||||||
|
|
||||||||||
| ########################################################################### | ||||||||||
| # Get oc binary | ||||||||||
| curl -sL "${OC_URL}" | tar -C "${BIN_FOLDER}" -xzvf - oc | ||||||||||
| curl -sL "${ocUrl}" | tar -C "${binFolder}" -xzvf - oc | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Harden
Suggested change-curl -sL "${ocUrl}" | tar -C "${binFolder}" -xzvf - oc
+curl --fail --silent --show-error --location \
+ --retry 5 --retry-all-errors --connect-timeout 30 --max-time 300 \
+ "${ocUrl}" | tar -C "${binFolder}" -xzvf - oc📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||
|
|
||||||||||
| oc whoami --show-console | ||||||||||
| HCO_SUBSCRIPTION=$(oc get subscription.operators.coreos.com -n openshift-cnv -o jsonpath='{.items[0].metadata.name}') | ||||||||||
| hcoSubscription="$(oc get subscription.operators.coreos.com -n openshift-cnv -o jsonpath='{.items[0].metadata.name}')" | ||||||||||
|
|
||||||||||
| oc get sc # Before | ||||||||||
| setDefaultStorageClass 'ocs-storagecluster-ceph-rbd-virtualization' | ||||||||||
|
|
@@ -262,7 +256,7 @@ uv --verbose --cache-dir /tmp/uv-cache \ | |||||||||
| --tb=native \ | ||||||||||
| --tc default_storage_class:ocs-storagecluster-ceph-rbd-virtualization \ | ||||||||||
| --tc default_volume_mode:Block \ | ||||||||||
| --tc "hco_subscription:${HCO_SUBSCRIPTION}" \ | ||||||||||
| --tc "hco_subscription:${hcoSubscription}" \ | ||||||||||
| --latest-rhel \ | ||||||||||
| --storage-class-matrix=ocs-storagecluster-ceph-rbd-virtualization \ | ||||||||||
| --leftovers-collector \ | ||||||||||
|
|
@@ -277,10 +271,4 @@ uv --verbose --cache-dir /tmp/uv-cache \ | |||||||||
| # | xmllint --format - > "${JUNIT_RESULTS_FILE}" | ||||||||||
| # fi | ||||||||||
|
|
||||||||||
| # Map tests if needed for related use cases | ||||||||||
| mapTestsForComponentReadiness "${JUNIT_RESULTS_FILE}" | ||||||||||
|
|
||||||||||
| # Send junit file to shared dir for Data Router Reporter step | ||||||||||
| cp "${JUNIT_RESULTS_FILE}" "${SHARED_DIR}" | ||||||||||
|
|
||||||||||
| exit ${rc} | ||||||||||
| exit "${rc}" | ||||||||||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: openshift/release
Length of output: 3352
Don't let the helper fetch gate
make deploy_test.Lines 7-15 fetch and
evala script fromrefs/heads/mainbefore the test run at line 58. Withset -eenabled, any GitHub/raw outage or curl failure will fail this step beforemake deploy_testexecutes, even though this block only provides post-processing. Additionally, the mutable ref (refs/heads/main) makes the step non-reproducible. Defer this fetch to exit time with proper error handling and pin to an immutable commit hash instead.Suggested direction
🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@coderabbitai
This has been discussed over and over again. You are supposed to learn this. See my comment and in any other PR about the the test nature is non-deterministic to begin with.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Length of output: 404
@etirta, thank you for the clarification and apologies for the repeated noise. I now understand:ExitTrap--PostProcessPrepis mandatory for Component Readiness (CR) to pick up results — if the network fetch fails, failing the entire step is the correct and intentional behavior, because silently showing a "successful" test in CR without the post-processing would be misleading and harmful. The earlyeval+curlplacement is a deliberate design decision.I've added a learning to avoid raising this concern in future reviews.