From 820e069a4231e30f413663f195dbd7374632c490 Mon Sep 17 00:00:00 2001 From: Francisco Herrera Date: Fri, 16 Jan 2026 18:59:43 +0100 Subject: [PATCH 1/4] Enable external registry support for OCP e2e tests in CI Signed-off-by: Francisco Herrera Revert "Enable external registry support for OCP e2e tests in CI" This reverts commit 5f331385fbc5cde46d2e91cf93a0e55ec0385278. Enable external registry support for OCP e2e tests in CI Signed-off-by: Francisco Herrera --- tests/e2e/common-operator-integ-suite.sh | 26 ++++++++++++++++++++++ tests/e2e/setup/build-and-push-operator.sh | 6 ++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/tests/e2e/common-operator-integ-suite.sh b/tests/e2e/common-operator-integ-suite.sh index 8a264eae3..c7345099d 100755 --- a/tests/e2e/common-operator-integ-suite.sh +++ b/tests/e2e/common-operator-integ-suite.sh @@ -123,12 +123,38 @@ initialize_variables() { OPERATOR_SDK=${LOCALBIN}/operator-sdk IP_FAMILY=${IP_FAMILY:-ipv4} ISTIO_MANIFEST="chart/samples/istio-sample.yaml" + CI=${CI:-"false"} # export to be sure that the variables are available in the subshell export IMAGE_BASE="${IMAGE_BASE:-sail-operator}" export TAG="${TAG:-latest}" export HUB="${HUB:-localhost:5000}" + # Handle OCP registry scenarios + # Note: Makefile.core.mk sets HUB=quay.io/sail-dev and TAG=1.29-latest by default + if [ "${OCP}" == "true" ]; then + if [ "${CI}" == "true" ] && [ "${HUB}" == "quay.io/sail-dev" ]; then + # Scenario 2: CI mode with default HUB -> use external registry with proper CI tag + echo "CI mode detected for OCP, using external registry quay.io/sail-dev" + + # Use PR_NUMBER if available, otherwise generate timestamp tag + if [ -n "${PR_NUMBER:-}" ]; then + export TAG="pr-${PR_NUMBER}" + echo "Using PR-based tag: ${TAG}" + else + export TAG="ci-test-$(date +%s)" + echo "Using timestamp-based tag: ${TAG}" + fi + elif [ "${HUB}" != "quay.io/sail-dev" ] && [ "${HUB}" != "localhost:5000" ]; then + # Scenario 3: Custom registry provided by user + echo "Using custom registry: ${HUB}" + else + # Scenario 1: Local development -> use internal OCP registry + echo "Local development mode, will use OCP internal registry" + export HUB="localhost:5000" # Reset to trigger internal registry setup + fi + fi + echo "Setting Istio manifest file: ${ISTIO_MANIFEST}" ISTIO_NAME=$(yq eval '.metadata.name' "${WD}/../../$ISTIO_MANIFEST") diff --git a/tests/e2e/setup/build-and-push-operator.sh b/tests/e2e/setup/build-and-push-operator.sh index f4527fa45..4f62071fb 100755 --- a/tests/e2e/setup/build-and-push-operator.sh +++ b/tests/e2e/setup/build-and-push-operator.sh @@ -85,8 +85,12 @@ build_and_push_operator_image() { } # Main logic -if [ "${OCP}" == "true" ]; then +# Only use internal registry for OCP local development (when HUB is localhost:5000) +if [ "${OCP}" == "true" ] && [ "${HUB}" == "localhost:5000" ]; then + echo "Setting up OCP internal registry for local development..." get_internal_registry fi +echo "Registry: ${HUB}" + build_and_push_operator_image \ No newline at end of file From b102e1dd2a7b0c732cf59604dacab68f15f344d7 Mon Sep 17 00:00:00 2001 From: Francisco Herrera Date: Mon, 19 Jan 2026 17:04:46 +0100 Subject: [PATCH 2/4] Fix lint Signed-off-by: Francisco Herrera --- tests/e2e/common-operator-integ-suite.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/e2e/common-operator-integ-suite.sh b/tests/e2e/common-operator-integ-suite.sh index c7345099d..c0aff2ed7 100755 --- a/tests/e2e/common-operator-integ-suite.sh +++ b/tests/e2e/common-operator-integ-suite.sh @@ -142,7 +142,8 @@ initialize_variables() { export TAG="pr-${PR_NUMBER}" echo "Using PR-based tag: ${TAG}" else - export TAG="ci-test-$(date +%s)" + TAG="ci-test-$(date +%s)" + export TAG echo "Using timestamp-based tag: ${TAG}" fi elif [ "${HUB}" != "quay.io/sail-dev" ] && [ "${HUB}" != "localhost:5000" ]; then From dc5f281c9e60c6fc9d423629cf975b3467d1b5f3 Mon Sep 17 00:00:00 2001 From: Francisco Herrera Date: Tue, 20 Jan 2026 13:20:18 +0100 Subject: [PATCH 3/4] Update tests/e2e/common-operator-integ-suite.sh Co-authored-by: Filip Brychta Signed-off-by: Francisco Herrera --- tests/e2e/common-operator-integ-suite.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e/common-operator-integ-suite.sh b/tests/e2e/common-operator-integ-suite.sh index c0aff2ed7..654f38edc 100755 --- a/tests/e2e/common-operator-integ-suite.sh +++ b/tests/e2e/common-operator-integ-suite.sh @@ -135,7 +135,7 @@ initialize_variables() { if [ "${OCP}" == "true" ]; then if [ "${CI}" == "true" ] && [ "${HUB}" == "quay.io/sail-dev" ]; then # Scenario 2: CI mode with default HUB -> use external registry with proper CI tag - echo "CI mode detected for OCP, using external registry quay.io/sail-dev" + echo "CI mode detected for OCP, using external registry ${HUB}" # Use PR_NUMBER if available, otherwise generate timestamp tag if [ -n "${PR_NUMBER:-}" ]; then From cd04d73593f6cc3e202dd0d4a039c1d5915db5c3 Mon Sep 17 00:00:00 2001 From: Francisco Herrera Date: Tue, 20 Jan 2026 17:17:21 +0100 Subject: [PATCH 4/4] Add some improvements around the use of internal registry Signed-off-by: Francisco Herrera --- tests/e2e/README.md | 30 ++++++++++++++++++++++ tests/e2e/common-operator-integ-suite.sh | 16 +++++++----- tests/e2e/setup/build-and-push-operator.sh | 4 +-- 3 files changed, 42 insertions(+), 8 deletions(-) diff --git a/tests/e2e/README.md b/tests/e2e/README.md index e4ee6a3b5..f9abed675 100644 --- a/tests/e2e/README.md +++ b/tests/e2e/README.md @@ -15,6 +15,7 @@ This end-to-end test suite utilizes Ginkgo, a testing framework known for its ex 1. [Pre-requisites](#pre-requisites) 1. [How to Run the test](#how-to-run-the-test) 1. [Running the test locally](#running-the-test-locally) + 1. [Test Run scenarios while running on OCP](#test-run-scenarios-while-running-on-ocp) 1. [Settings for end-to-end test execution](#settings-for-end-to-end-test-execution) 1. [Customizing the test run](#customizing-the-test-run) 1. [Get test definitions for the end-to-end test](#get-test-definitions-for-the-end-to-end-test) @@ -248,6 +249,35 @@ Note: if you are running the test against a cluster that has a different archite TARGET_ARCH=arm64 make test.e2e.ocp ``` +#### Test Run scenarios while running on OCP +When running the E2E test on OpenShift clusters, the framework supports three different registry scenarios: + +**Scenario 1: Test run with Internal Registry (Default behaviour)** +For test run on OpenShift with the default settings, no additional configuration is needed. The test scripts will automatically configure and use the OpenShift internal registry: + +```sh +# No HUB setting needed - uses internal registry by default +make test.e2e.ocp +``` + +**Scenario 2: Test run with CI Mode with External Registry** +In CI environments, set `CI=true` to use external registries with proper tagging: + +```sh +export CI=true +# Uses default HUB=quay.io/sail-dev with auto-generated tags if no PR_NUMBER var is being set +make test.e2e.ocp +``` + +**Scenario 3: Test run with custom External Registry** +For custom external registries, specify your own HUB value: + +```sh +export HUB=your-registry.com/your-namespace +export TAG=your-tag +make test.e2e.ocp +``` + ### Settings for end-to-end test execution The following environment variables define the behavior of the test run: diff --git a/tests/e2e/common-operator-integ-suite.sh b/tests/e2e/common-operator-integ-suite.sh index 654f38edc..abf4c75c2 100755 --- a/tests/e2e/common-operator-integ-suite.sh +++ b/tests/e2e/common-operator-integ-suite.sh @@ -146,13 +146,13 @@ initialize_variables() { export TAG echo "Using timestamp-based tag: ${TAG}" fi - elif [ "${HUB}" != "quay.io/sail-dev" ] && [ "${HUB}" != "localhost:5000" ]; then + elif [ "${HUB}" != "quay.io/sail-dev" ]; then # Scenario 3: Custom registry provided by user echo "Using custom registry: ${HUB}" else # Scenario 1: Local development -> use internal OCP registry echo "Local development mode, will use OCP internal registry" - export HUB="localhost:5000" # Reset to trigger internal registry setup + export USE_INTERNAL_REGISTRY="true" fi fi @@ -242,7 +242,7 @@ parse_flags "$@" initialize_variables # Export necessary vars -export COMMAND OCP HUB IMAGE_BASE TAG NAMESPACE +export COMMAND OCP HUB IMAGE_BASE TAG NAMESPACE USE_INTERNAL_REGISTRY if [ "${SKIP_BUILD}" == "false" ]; then "${WD}/setup/build-and-push-operator.sh" @@ -251,9 +251,13 @@ if [ "${SKIP_BUILD}" == "false" ]; then # This is a workaround when pulling the image from internal registry # To avoid errors of certificates meanwhile we are pulling the operator image from the internal registry # We need to set image $HUB to a fixed known value after the push - # This value always will be equal to the svc url of the internal registry - HUB="image-registry.openshift-image-registry.svc:5000/istio-images" - echo "Using internal registry: ${HUB}" + # Convert from route URL to service URL format for image pulling + if [[ "${HUB}" == *"/istio-images" ]]; then + HUB="image-registry.openshift-image-registry.svc:5000/istio-images" + echo "Using internal registry service URL: ${HUB}" + else + echo "Using external registry: ${HUB}" + fi # Workaround for OCP helm operator installation issues: # To avoid any cleanup issues, after we build and push the image we check if the namespace exists and delete it if it does. diff --git a/tests/e2e/setup/build-and-push-operator.sh b/tests/e2e/setup/build-and-push-operator.sh index 4f62071fb..fadc990c8 100755 --- a/tests/e2e/setup/build-and-push-operator.sh +++ b/tests/e2e/setup/build-and-push-operator.sh @@ -85,8 +85,8 @@ build_and_push_operator_image() { } # Main logic -# Only use internal registry for OCP local development (when HUB is localhost:5000) -if [ "${OCP}" == "true" ] && [ "${HUB}" == "localhost:5000" ]; then +# Only use internal registry for OCP local development (when USE_INTERNAL_REGISTRY is set) +if [ "${OCP}" == "true" ] && [ "${USE_INTERNAL_REGISTRY:-false}" == "true" ]; then echo "Setting up OCP internal registry for local development..." get_internal_registry fi