Skip to content

Commit 88eedc6

Browse files
istio-testingfjgliraFilipB
authored
[release-1.28] Enable external registry support for OCP e2e tests in CI (#1540)
* Enable external registry support for OCP e2e tests in CI Signed-off-by: Francisco Herrera <fjglira@gmail.com> Revert "Enable external registry support for OCP e2e tests in CI" This reverts commit 5f33138. Enable external registry support for OCP e2e tests in CI Signed-off-by: Francisco Herrera <fjglira@gmail.com> * Fix lint Signed-off-by: Francisco Herrera <fjglira@gmail.com> * Update tests/e2e/common-operator-integ-suite.sh Co-authored-by: Filip Brychta <fbrychta@redhat.com> Signed-off-by: Francisco Herrera <fjglira@gmail.com> * Add some improvements around the use of internal registry Signed-off-by: Francisco Herrera <fjglira@gmail.com> --------- Signed-off-by: Francisco Herrera <fjglira@gmail.com> Co-authored-by: Francisco Herrera <fjglira@gmail.com> Co-authored-by: Filip Brychta <fbrychta@redhat.com>
1 parent 33df6cd commit 88eedc6

File tree

3 files changed

+70
-5
lines changed

3 files changed

+70
-5
lines changed

tests/e2e/README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ This end-to-end test suite utilizes Ginkgo, a testing framework known for its ex
1515
1. [Pre-requisites](#pre-requisites)
1616
1. [How to Run the test](#how-to-run-the-test)
1717
1. [Running the test locally](#running-the-test-locally)
18+
1. [Test Run scenarios while running on OCP](#test-run-scenarios-while-running-on-ocp)
1819
1. [Settings for end-to-end test execution](#settings-for-end-to-end-test-execution)
1920
1. [Customizing the test run](#customizing-the-test-run)
2021
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
248249
TARGET_ARCH=arm64 make test.e2e.ocp
249250
```
250251

252+
#### Test Run scenarios while running on OCP
253+
When running the E2E test on OpenShift clusters, the framework supports three different registry scenarios:
254+
255+
**Scenario 1: Test run with Internal Registry (Default behaviour)**
256+
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:
257+
258+
```sh
259+
# No HUB setting needed - uses internal registry by default
260+
make test.e2e.ocp
261+
```
262+
263+
**Scenario 2: Test run with CI Mode with External Registry**
264+
In CI environments, set `CI=true` to use external registries with proper tagging:
265+
266+
```sh
267+
export CI=true
268+
# Uses default HUB=quay.io/sail-dev with auto-generated tags if no PR_NUMBER var is being set
269+
make test.e2e.ocp
270+
```
271+
272+
**Scenario 3: Test run with custom External Registry**
273+
For custom external registries, specify your own HUB value:
274+
275+
```sh
276+
export HUB=your-registry.com/your-namespace
277+
export TAG=your-tag
278+
make test.e2e.ocp
279+
```
280+
251281
### Settings for end-to-end test execution
252282

253283
The following environment variables define the behavior of the test run:

tests/e2e/common-operator-integ-suite.sh

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,39 @@ initialize_variables() {
123123
OPERATOR_SDK=${LOCALBIN}/operator-sdk
124124
IP_FAMILY=${IP_FAMILY:-ipv4}
125125
ISTIO_MANIFEST="chart/samples/istio-sample.yaml"
126+
CI=${CI:-"false"}
126127

127128
# export to be sure that the variables are available in the subshell
128129
export IMAGE_BASE="${IMAGE_BASE:-sail-operator}"
129130
export TAG="${TAG:-latest}"
130131
export HUB="${HUB:-localhost:5000}"
131132

133+
# Handle OCP registry scenarios
134+
# Note: Makefile.core.mk sets HUB=quay.io/sail-dev and TAG=1.29-latest by default
135+
if [ "${OCP}" == "true" ]; then
136+
if [ "${CI}" == "true" ] && [ "${HUB}" == "quay.io/sail-dev" ]; then
137+
# Scenario 2: CI mode with default HUB -> use external registry with proper CI tag
138+
echo "CI mode detected for OCP, using external registry ${HUB}"
139+
140+
# Use PR_NUMBER if available, otherwise generate timestamp tag
141+
if [ -n "${PR_NUMBER:-}" ]; then
142+
export TAG="pr-${PR_NUMBER}"
143+
echo "Using PR-based tag: ${TAG}"
144+
else
145+
TAG="ci-test-$(date +%s)"
146+
export TAG
147+
echo "Using timestamp-based tag: ${TAG}"
148+
fi
149+
elif [ "${HUB}" != "quay.io/sail-dev" ]; then
150+
# Scenario 3: Custom registry provided by user
151+
echo "Using custom registry: ${HUB}"
152+
else
153+
# Scenario 1: Local development -> use internal OCP registry
154+
echo "Local development mode, will use OCP internal registry"
155+
export USE_INTERNAL_REGISTRY="true"
156+
fi
157+
fi
158+
132159
echo "Setting Istio manifest file: ${ISTIO_MANIFEST}"
133160
ISTIO_NAME=$(yq eval '.metadata.name' "${WD}/../../$ISTIO_MANIFEST")
134161

@@ -215,7 +242,7 @@ parse_flags "$@"
215242
initialize_variables
216243

217244
# Export necessary vars
218-
export COMMAND OCP HUB IMAGE_BASE TAG NAMESPACE
245+
export COMMAND OCP HUB IMAGE_BASE TAG NAMESPACE USE_INTERNAL_REGISTRY
219246

220247
if [ "${SKIP_BUILD}" == "false" ]; then
221248
"${WD}/setup/build-and-push-operator.sh"
@@ -224,9 +251,13 @@ if [ "${SKIP_BUILD}" == "false" ]; then
224251
# This is a workaround when pulling the image from internal registry
225252
# To avoid errors of certificates meanwhile we are pulling the operator image from the internal registry
226253
# We need to set image $HUB to a fixed known value after the push
227-
# This value always will be equal to the svc url of the internal registry
228-
HUB="image-registry.openshift-image-registry.svc:5000/istio-images"
229-
echo "Using internal registry: ${HUB}"
254+
# Convert from route URL to service URL format for image pulling
255+
if [[ "${HUB}" == *"/istio-images" ]]; then
256+
HUB="image-registry.openshift-image-registry.svc:5000/istio-images"
257+
echo "Using internal registry service URL: ${HUB}"
258+
else
259+
echo "Using external registry: ${HUB}"
260+
fi
230261

231262
# Workaround for OCP helm operator installation issues:
232263
# To avoid any cleanup issues, after we build and push the image we check if the namespace exists and delete it if it does.

tests/e2e/setup/build-and-push-operator.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,12 @@ build_and_push_operator_image() {
8585
}
8686

8787
# Main logic
88-
if [ "${OCP}" == "true" ]; then
88+
# Only use internal registry for OCP local development (when USE_INTERNAL_REGISTRY is set)
89+
if [ "${OCP}" == "true" ] && [ "${USE_INTERNAL_REGISTRY:-false}" == "true" ]; then
90+
echo "Setting up OCP internal registry for local development..."
8991
get_internal_registry
9092
fi
9193

94+
echo "Registry: ${HUB}"
95+
9296
build_and_push_operator_image

0 commit comments

Comments
 (0)