diff --git a/tests/e2e/README.md b/tests/e2e/README.md index e4ee6a3b5a..f9abed6750 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 8a264eae3b..abf4c75c2c 100755 --- a/tests/e2e/common-operator-integ-suite.sh +++ b/tests/e2e/common-operator-integ-suite.sh @@ -123,12 +123,39 @@ 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 ${HUB}" + + # 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 + TAG="ci-test-$(date +%s)" + export TAG + echo "Using timestamp-based tag: ${TAG}" + fi + 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 USE_INTERNAL_REGISTRY="true" + fi + fi + echo "Setting Istio manifest file: ${ISTIO_MANIFEST}" ISTIO_NAME=$(yq eval '.metadata.name' "${WD}/../../$ISTIO_MANIFEST") @@ -215,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" @@ -224,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 f4527fa45d..fadc990c83 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 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 +echo "Registry: ${HUB}" + build_and_push_operator_image \ No newline at end of file