diff --git a/ci-operator/config/RedHatQE/interop-testing/RedHatQE-interop-testing-master__cnv-odf-ocp-4.22-lp-interop.yaml b/ci-operator/config/RedHatQE/interop-testing/RedHatQE-interop-testing-master__cnv-odf-ocp-4.22-lp-interop.yaml index e8f066500514d..65ccebd803756 100644 --- a/ci-operator/config/RedHatQE/interop-testing/RedHatQE-interop-testing-master__cnv-odf-ocp-4.22-lp-interop.yaml +++ b/ci-operator/config/RedHatQE/interop-testing/RedHatQE-interop-testing-master__cnv-odf-ocp-4.22-lp-interop.yaml @@ -66,7 +66,7 @@ tests: OCP_VERSION: "4.22" ODF_OPERATOR_CHANNEL: stable-4.20 ODF_VERSION_MAJOR_MINOR: "4.20" - REPORTPORTAL_CMP: CNV-lp-interop + REPORTPORTAL_CMP: lp-ocp-compat--CNV USER_TAGS: | scenario cnv test: @@ -109,7 +109,7 @@ tests: ODF_OPERATOR_CHANNEL: stable-4.20 ODF_VERSION_MAJOR_MINOR: "4.20" REPORT_TO_DR: "true" - REPORTPORTAL_CMP: CNV-lp-interop + REPORTPORTAL_CMP: lp-ocp-compat--CNV USER_TAGS: | scenario cnv test: diff --git a/ci-operator/step-registry/interop-tests/cnv-tests-e2e-deploy/interop-tests-cnv-tests-e2e-deploy-commands.sh b/ci-operator/step-registry/interop-tests/cnv-tests-e2e-deploy/interop-tests-cnv-tests-e2e-deploy-commands.sh index f95a7a6da414d..ac769bb72263d 100644 --- a/ci-operator/step-registry/interop-tests/cnv-tests-e2e-deploy/interop-tests-cnv-tests-e2e-deploy-commands.sh +++ b/ci-operator/step-registry/interop-tests/cnv-tests-e2e-deploy/interop-tests-cnv-tests-e2e-deploy-commands.sh @@ -1,48 +1,29 @@ #!/bin/bash - -set -o nounset -set -o errexit -set -o pipefail - -# Ensure Requirements. -# yq should be installed within the container of openshift-cnv/cnv-ci -# as fallback we check if it is missing and install it if necessary -PATH="$(exec 3>&1 1>&2 - typeset binDir="/tmp/bin" - mkdir -p "${binDir}" - yq --version || { - curl -sLo "${binDir}/yq" \ - "https://github.com/mikefarah/yq/releases/latest/download/yq_$( - uname -s | tr '[:upper:]' '[:lower:]' - )_$( - uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/' - )" && - chmod a+x "${binDir}/yq" - "${binDir}/yq" --version - } -echo "${binDir}" 1>&3):${PATH}" - -function mapTestsForComponentReadiness() { - if [[ $MAP_TESTS == "true" ]]; then - results_file="${1}" - echo "Patching Tests Result File: ${results_file}" - if [ -f "${results_file}" ]; then - echo "Mapping Test Suite Name To: CNV-lp-interop" - yq eval -px -ox -iI0 '.testsuite."+@name" = "CNV-lp-interop"' "${results_file}" - fi - fi -} +set -euxo pipefail; shopt -s inherit_errexit + +# 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 +if [ "${MAP_TESTS}" = "true" ]; then + 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 ' + LP_IO__ET_PPP__NEW_TS_NAME="${REPORTPORTAL_CMP}--%s" \ + ExitTrap--PostProcessPrep junit--cnv__interop-tests__cnv-tests-e2e-deploy.xml + ' EXIT +fi # Set cluster variables # CLUSTER_NAME=$(cat "${SHARED_DIR}/CLUSTER_NAME") # CLUSTER_DOMAIN="${CLUSTER_DOMAIN:-release-ci.cnv-qe.rhood.us}" -BIN_FOLDER=$(mktemp -d /tmp/bin.XXXX) +typeset binFolder='' +typeset exit_code=0 +binFolder="$(mktemp -d /tmp/bin.XXXX)" # Exports # export CLUSTER_NAME CLUSTER_DOMAIN -export ARTIFACTS="${ARTIFACT_DIR}" -export PATH="${BIN_FOLDER}:${PATH}" -export KUBEVIRT_TESTING_CONFIGURATION_FILE=${KUBEVIRT_TESTING_CONFIGURATION_FILE:-'kubevirt-tier1-ocs.json'} +export PATH="${binFolder}:${PATH}" # Unset the following environment variables to avoid issues with oc command unset KUBERNETES_SERVICE_PORT_HTTPS @@ -58,8 +39,8 @@ unset KUBERNETES_PORT_443_TCP_PORT set -x # Get oc binary -# curl -sL "${OC_URL}" | tar -C "${BIN_FOLDER}" -xzvf - oc -curl -L "https://github.com/openshift-cnv/cnv-ci/tarball/release-${OCP_VERSION}" -o /tmp/cnv-ci.tgz +# curl -sL "${OC_URL}" | tar -C "${binFolder}" -xzvf - oc +curl -fsSL "https://github.com/openshift-cnv/cnv-ci/tarball/release-${OCP_VERSION}" -o /tmp/cnv-ci.tgz mkdir -p /tmp/cnv-ci tar -xvzf /tmp/cnv-ci.tgz -C /tmp/cnv-ci --strip-components=1 cd /tmp/cnv-ci || exit 1 @@ -68,8 +49,8 @@ cd /tmp/cnv-ci || exit 1 # If KUBEVIRT_TESTING_CONFIGURATION is set and not empty, is has higher priority over KUBEVIRT_TESTING_CONFIGURATION_FILE if [[ -n "${KUBEVIRT_TESTING_CONFIGURATION:-}" ]]; then export KUBEVIRT_TESTING_CONFIGURATION_FILE="${ARTIFACT_DIR}/kubevirt-testing-configuration.json" - echo "${KUBEVIRT_TESTING_CONFIGURATION}" | tee "${KUBEVIRT_TESTING_CONFIGURATION_FILE}" - echo "🔄 KUBEVIRT_TESTING_CONFIGURATION_FILE set to ${KUBEVIRT_TESTING_CONFIGURATION_FILE}" + # Write inline JSON to the artifact path (avoid echo for xtrace log noise; tee preserves a traceable redirect). + tee "${KUBEVIRT_TESTING_CONFIGURATION_FILE}" <<< "${KUBEVIRT_TESTING_CONFIGURATION}" fi @@ -78,24 +59,18 @@ make deploy_test || exit_code=$? set +x - # Map tests if needed for related use cases -mapTestsForComponentReadiness "${ARTIFACT_DIR}/junit.functest.xml" - - # Send junit files to shared dir for Data Router Reporter step -cp "${ARTIFACT_DIR}"/*.xml "${SHARED_DIR}" - - if [ "${exit_code:-0}" -ne 0 ]; then - echo "deploy_test failed with exit code $exit_code" + # deploy_test failed; exit status is propagated below (xtrace is off in this block). if [[ -n "${CNV_WAIT_FOR_LIVE_DEBUG:-}" ]]; then - echo "Waiting to allow interactive debugging" - if ((CNV_WAIT_FOR_LIVE_DEBUG > 0)); then + # Hold for live debugging: positive CNV_WAIT_FOR_LIVE_DEBUG = bounded sleep; otherwise sleep inf. + if ((${CNV_WAIT_FOR_LIVE_DEBUG} > 0)); then sleep "${CNV_WAIT_FOR_LIVE_DEBUG}" else sleep inf fi fi exit "${exit_code}" -else - echo "deploy_test succeeded" fi + +# deploy_test succeeded when execution reaches here (step outcome from exit status). +true diff --git a/ci-operator/step-registry/interop-tests/cnv-tests-e2e-deploy/interop-tests-cnv-tests-e2e-deploy-ref.yaml b/ci-operator/step-registry/interop-tests/cnv-tests-e2e-deploy/interop-tests-cnv-tests-e2e-deploy-ref.yaml index a1fa4c69b26df..def97d073c3a5 100644 --- a/ci-operator/step-registry/interop-tests/cnv-tests-e2e-deploy/interop-tests-cnv-tests-e2e-deploy-ref.yaml +++ b/ci-operator/step-registry/interop-tests/cnv-tests-e2e-deploy/interop-tests-cnv-tests-e2e-deploy-ref.yaml @@ -5,6 +5,7 @@ ref: from: cnv-ci commands: interop-tests-cnv-tests-e2e-deploy-commands.sh timeout: 4h0m0s + grace_period: 10m credentials: - namespace: test-credentials name: cluster-secrets-aws-interop-qe @@ -57,3 +58,6 @@ ref: - name: CNV_WAIT_FOR_LIVE_DEBUG default: "0" documentation: Specify whether to wait for live debug + - name: REPORTPORTAL_CMP + default: "lp-ocp-compat--CNV" + documentation: If test mapping is applied, differentiate between the CNV and ODF jobs diff --git a/ci-operator/step-registry/interop-tests/openshift-virtualization-tests/interop-tests-openshift-virtualization-tests-commands.sh b/ci-operator/step-registry/interop-tests/openshift-virtualization-tests/interop-tests-openshift-virtualization-tests-commands.sh index c43eca1187492..be90390db3690 100644 --- a/ci-operator/step-registry/interop-tests/openshift-virtualization-tests/interop-tests-openshift-virtualization-tests-commands.sh +++ b/ci-operator/step-registry/interop-tests/openshift-virtualization-tests/interop-tests-openshift-virtualization-tests-commands.sh @@ -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=$? + 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 +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 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}" diff --git a/ci-operator/step-registry/interop-tests/openshift-virtualization-tests/interop-tests-openshift-virtualization-tests-ref.yaml b/ci-operator/step-registry/interop-tests/openshift-virtualization-tests/interop-tests-openshift-virtualization-tests-ref.yaml index 0ad61a77c3293..49ce5d4d0a3c4 100644 --- a/ci-operator/step-registry/interop-tests/openshift-virtualization-tests/interop-tests-openshift-virtualization-tests-ref.yaml +++ b/ci-operator/step-registry/interop-tests/openshift-virtualization-tests/interop-tests-openshift-virtualization-tests-ref.yaml @@ -44,3 +44,6 @@ ref: - name: MAP_TESTS default: "false" documentation: Specify whether to update the test suite name for reporting tools + - name: REPORTPORTAL_CMP + default: "lp-ocp-compat--CNV" + documentation: If test mapping is applied, differentiate between the CNV and ODF jobs