From 49ef877a4f7224159aa585f2b913975c4764d40d Mon Sep 17 00:00:00 2001 From: Francisco Herrera Date: Thu, 18 Sep 2025 22:04:35 +0200 Subject: [PATCH 1/5] fix(e2e): Add cleanup trap to prevent false positives in CI test runs The e2e test script was storing the Ginkgo exit code but could still exit unexpectedly before cleanup, causing CI to mark incomplete test runs as successful (false positives). Signed-off-by: Francisco Herrera --- tests/e2e/common-operator-integ-suite.sh | 35 ++++++++++++++---------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/tests/e2e/common-operator-integ-suite.sh b/tests/e2e/common-operator-integ-suite.sh index 3fc06c40d..469cc1433 100755 --- a/tests/e2e/common-operator-integ-suite.sh +++ b/tests/e2e/common-operator-integ-suite.sh @@ -152,6 +152,23 @@ uninstall_operator() { "${COMMAND}" delete namespace "${NAMESPACE}" } +# Ensure cleanup always runs and that the original test exit code is preserved +cleanup() { + # Do not let cleanup errors affect the final exit code + set +e + if [ "${OLM}" != "true" ] && [ "${SKIP_DEPLOY}" != "true" ]; then + if [ "${MULTICLUSTER}" == true ]; then + KUBECONFIG="${KUBECONFIG}" uninstall_operator || true + KUBECONFIG="${KUBECONFIG2}" uninstall_operator || true + else + uninstall_operator || true + fi + fi + echo "JUnit report: ${ARTIFACTS}/report.xml" +} + +trap cleanup EXIT INT TERM + # Main script flow check_arguments "$@" parse_flags "$@" @@ -231,24 +248,12 @@ if [ "${OLM}" != "true" ] && [ "${SKIP_DEPLOY}" != "true" ]; then fi set +e -# Disable to avoid fail the test run and not generate the report.xml -# We need to catch the exit code to be able to generate the report +# Disable to avoid failing the test run before generating the report.xml +# Capture the test exit code and allow cleanup via trap to run # shellcheck disable=SC2086 IMAGE="${HUB}/${IMAGE_BASE}:${TAG}" \ go run github.com/onsi/ginkgo/v2/ginkgo -tags e2e \ --timeout 60m --junit-report="${ARTIFACTS}/report.xml" ${GINKGO_FLAGS:-} "${WD}"/... TEST_EXIT_CODE=$? -set -e - -if [ "${OLM}" != "true" ] && [ "${SKIP_DEPLOY}" != "true" ]; then - if [ "${MULTICLUSTER}" == true ]; then - KUBECONFIG="${KUBECONFIG}" uninstall_operator - KUBECONFIG="${KUBECONFIG2}" uninstall_operator - else - uninstall_operator - fi -fi - -echo "JUnit report: ${ARTIFACTS}/report.xml" -exit ${TEST_EXIT_CODE} +exit "${TEST_EXIT_CODE}" From 2f35b72e2c1f3244785a830b99f69ba7905cc689 Mon Sep 17 00:00:00 2001 From: Francisco Herrera Date: Thu, 18 Sep 2025 22:10:49 +0200 Subject: [PATCH 2/5] TEMPORARY FAILURE TEMPORARY FAILURE: check failure test on CI Signed-off-by: Francisco Herrera --- tests/e2e/operator/operator_install_test.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/e2e/operator/operator_install_test.go b/tests/e2e/operator/operator_install_test.go index 9899437c2..713d1b09f 100644 --- a/tests/e2e/operator/operator_install_test.go +++ b/tests/e2e/operator/operator_install_test.go @@ -93,6 +93,11 @@ var _ = Describe("Operator", Label("smoke", "operator"), Ordered, func() { Should(HaveConditionStatus(appsv1.DeploymentAvailable, metav1.ConditionTrue), "Error getting Deployment status") }) + // TODO: TEMPORARY TEST - Remove this test after verifying CI error handling + It("TEMPORARY: should fail to test CI error handling", func(ctx SpecContext) { + Fail("This test intentionally fails to verify CI correctly reports test failures") + }) + It("serves metrics securely", func(ctx SpecContext) { metricsReaderRoleName := "metrics-reader" metricsServiceName := deploymentName + "-metrics-service" From 6b22ca1861ed9f2f0fb99f841c401d7f2ae1f278 Mon Sep 17 00:00:00 2001 From: Francisco Herrera Date: Thu, 18 Sep 2025 22:21:21 +0200 Subject: [PATCH 3/5] Fix lint Fix lint messages Signed-off-by: Francisco Herrera --- tests/e2e/common-operator-integ-suite.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/e2e/common-operator-integ-suite.sh b/tests/e2e/common-operator-integ-suite.sh index 469cc1433..af0a88940 100755 --- a/tests/e2e/common-operator-integ-suite.sh +++ b/tests/e2e/common-operator-integ-suite.sh @@ -146,6 +146,7 @@ await_operator() { "${COMMAND}" wait --for=condition=available deployment/"${DEPLOYMENT_NAME}" -n "${NAMESPACE}" --timeout=5m } +# shellcheck disable=SC2329 # Function is invoked indirectly via trap uninstall_operator() { echo "Uninstalling sail-operator (KUBECONFIG=${KUBECONFIG})" helm uninstall sail-operator --namespace "${NAMESPACE}" @@ -153,12 +154,14 @@ uninstall_operator() { } # Ensure cleanup always runs and that the original test exit code is preserved +# shellcheck disable=SC2329 # Function is invoked indirectly via trap cleanup() { # Do not let cleanup errors affect the final exit code set +e if [ "${OLM}" != "true" ] && [ "${SKIP_DEPLOY}" != "true" ]; then if [ "${MULTICLUSTER}" == true ]; then KUBECONFIG="${KUBECONFIG}" uninstall_operator || true + # shellcheck disable=SC2153 # KUBECONFIG2 is set by multicluster setup scripts KUBECONFIG="${KUBECONFIG2}" uninstall_operator || true else uninstall_operator || true From 62ca7feeb67e4acb509de520a34d19c3ad543266 Mon Sep 17 00:00:00 2001 From: Francisco Herrera Date: Thu, 18 Sep 2025 22:36:20 +0200 Subject: [PATCH 4/5] Revert "TEMPORARY FAILURE" This reverts commit 5346be91ff80cd471d0914c283fa07c9498552a6. Signed-off-by: Francisco Herrera --- tests/e2e/operator/operator_install_test.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tests/e2e/operator/operator_install_test.go b/tests/e2e/operator/operator_install_test.go index 713d1b09f..9899437c2 100644 --- a/tests/e2e/operator/operator_install_test.go +++ b/tests/e2e/operator/operator_install_test.go @@ -93,11 +93,6 @@ var _ = Describe("Operator", Label("smoke", "operator"), Ordered, func() { Should(HaveConditionStatus(appsv1.DeploymentAvailable, metav1.ConditionTrue), "Error getting Deployment status") }) - // TODO: TEMPORARY TEST - Remove this test after verifying CI error handling - It("TEMPORARY: should fail to test CI error handling", func(ctx SpecContext) { - Fail("This test intentionally fails to verify CI correctly reports test failures") - }) - It("serves metrics securely", func(ctx SpecContext) { metricsReaderRoleName := "metrics-reader" metricsServiceName := deploymentName + "-metrics-service" From 8ff0e846cacd2d608e8c0a79f9850311f0ccbcf6 Mon Sep 17 00:00:00 2001 From: Francisco Herrera Date: Mon, 6 Oct 2025 10:46:29 +0200 Subject: [PATCH 5/5] Fix lint issues Fix lint issues in branch 1.27 Signed-off-by: Francisco Herrera --- tests/e2e/common-operator-integ-suite.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/e2e/common-operator-integ-suite.sh b/tests/e2e/common-operator-integ-suite.sh index b9c1ef21f..317c3399c 100755 --- a/tests/e2e/common-operator-integ-suite.sh +++ b/tests/e2e/common-operator-integ-suite.sh @@ -183,7 +183,7 @@ await_operator() { "${COMMAND}" wait --for=condition=available deployment/"${DEPLOYMENT_NAME}" -n "${NAMESPACE}" --timeout=5m } -# shellcheck disable=SC2329 # Function is invoked indirectly via trap +# shellcheck disable=SC2329,SC2317 # Function is invoked indirectly via trap uninstall_operator() { echo "Uninstalling sail-operator (KUBECONFIG=${KUBECONFIG})" helm uninstall sail-operator --namespace "${NAMESPACE}" @@ -191,7 +191,7 @@ uninstall_operator() { } # Ensure cleanup always runs and that the original test exit code is preserved -# shellcheck disable=SC2329 # Function is invoked indirectly via trap +# shellcheck disable=SC2329,SC2317 # Function is invoked indirectly via trap cleanup() { # Do not let cleanup errors affect the final exit code set +e