Skip to content

Commit 3b383ab

Browse files
joelanfordclaude
andcommitted
e2e: update extension-developer-e2e to use registry library
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 2825c86 commit 3b383ab

File tree

3 files changed

+62
-44
lines changed

3 files changed

+62
-44
lines changed

Makefile

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -259,18 +259,13 @@ E2E_TIMEOUT ?= 10m
259259
e2e: #EXHELP Run the e2e tests.
260260
go test -count=1 -v ./test/e2e/features_test.go -timeout=$(E2E_TIMEOUT)
261261

262-
E2E_REGISTRY_NAME := docker-registry
263-
E2E_REGISTRY_NAMESPACE := operator-controller-e2e
264-
265-
export REG_PKG_NAME := registry-operator
266-
export CLUSTER_REGISTRY_HOST := $(E2E_REGISTRY_NAME).$(E2E_REGISTRY_NAMESPACE).svc:5000
262+
export CLUSTER_REGISTRY_HOST := docker-registry.operator-controller-e2e.svc:5000
267263
export LOCAL_REGISTRY_HOST := localhost:30000
268-
export E2E_TEST_CATALOG_V1 := e2e/test-catalog:v1
269-
export E2E_TEST_CATALOG_V2 := e2e/test-catalog:v2
270-
export CATALOG_IMG := $(CLUSTER_REGISTRY_HOST)/$(E2E_TEST_CATALOG_V1)
271264
.PHONY: extension-developer-e2e
265+
extension-developer-e2e: export OPERATOR_SDK := $(OPERATOR_SDK)
266+
extension-developer-e2e: export CONTAINER_RUNTIME := $(CONTAINER_RUNTIME)
267+
extension-developer-e2e: export KUSTOMIZE := $(KUSTOMIZE)
272268
extension-developer-e2e: $(OPERATOR_SDK) $(KUSTOMIZE) #EXHELP Run extension create, upgrade and delete tests.
273-
test/extension-developer-e2e/setup.sh $(OPERATOR_SDK) $(CONTAINER_RUNTIME) $(KUSTOMIZE) ${LOCAL_REGISTRY_HOST} ${CLUSTER_REGISTRY_HOST}
274269
go test -count=1 -v ./test/extension-developer-e2e/...
275270

276271
UNIT_TEST_DIRS := $(shell go list ./... | grep -vE "/test/|/testutils") $(shell go list ./test/internal/...)
@@ -349,7 +344,7 @@ test-extension-developer-e2e: SOURCE_MANIFEST := $(STANDARD_E2E_MANIFEST)
349344
test-extension-developer-e2e: KIND_CLUSTER_NAME := operator-controller-ext-dev-e2e
350345
test-extension-developer-e2e: export INSTALL_DEFAULT_CATALOGS := false
351346
test-extension-developer-e2e: export MANIFEST := $(STANDARD_RELEASE_MANIFEST)
352-
test-extension-developer-e2e: run-internal image-registry extension-developer-e2e kind-clean #HELP Run extension-developer e2e on local kind cluster
347+
test-extension-developer-e2e: run-internal extension-developer-e2e kind-clean #HELP Run extension-developer e2e on local kind cluster
353348

354349
.PHONY: run-latest-release
355350
run-latest-release:

test/extension-developer-e2e/extension_developer_test.go

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"fmt"
66
"os"
7+
"os/exec"
78
"testing"
89
"time"
910

@@ -19,22 +20,49 @@ import (
1920
"sigs.k8s.io/controller-runtime/pkg/client"
2021

2122
ocv1 "github.com/operator-framework/operator-controller/api/v1"
23+
testregistry "github.com/operator-framework/operator-controller/test/internal/registry"
2224
)
2325

26+
const (
27+
catalogTag = "e2e/test-catalog:v1"
28+
regPkgName = "registry-operator"
29+
)
30+
31+
func TestMain(m *testing.M) {
32+
cfg := ctrl.GetConfigOrDie()
33+
if err := testregistry.Deploy(context.Background(), cfg, testregistry.DefaultNamespace, testregistry.DefaultName); err != nil {
34+
panic(fmt.Sprintf("failed to deploy image registry: %v", err))
35+
}
36+
37+
clusterRegistryHost := os.Getenv("CLUSTER_REGISTRY_HOST")
38+
if clusterRegistryHost == "" {
39+
panic("CLUSTER_REGISTRY_HOST environment variable must be set")
40+
}
41+
42+
// Set env vars for setup.sh — single source of truth
43+
os.Setenv("CATALOG_TAG", catalogTag)
44+
os.Setenv("REG_PKG_NAME", regPkgName)
45+
46+
cmd := exec.Command("./setup.sh") //nolint:gosec // test-only setup script
47+
cmd.Stdout = os.Stdout
48+
cmd.Stderr = os.Stderr
49+
if err := cmd.Run(); err != nil {
50+
panic(fmt.Sprintf("failed to run setup.sh: %v", err))
51+
}
52+
53+
os.Exit(m.Run())
54+
}
55+
2456
func TestExtensionDeveloper(t *testing.T) {
2557
t.Parallel()
2658
cfg := ctrl.GetConfigOrDie()
2759

2860
scheme := runtime.NewScheme()
2961

30-
require.NoError(t, ocv1.AddToScheme(scheme))
3162
require.NoError(t, ocv1.AddToScheme(scheme))
3263
require.NoError(t, corev1.AddToScheme(scheme))
3364
require.NoError(t, rbacv1.AddToScheme(scheme))
3465

35-
require.NotEmpty(t, os.Getenv("CATALOG_IMG"), "environment variable CATALOG_IMG must be set")
36-
require.NotEmpty(t, os.Getenv("REG_PKG_NAME"), "environment variable REG_PKG_NAME must be set")
37-
3866
c, err := client.New(cfg, client.Options{Scheme: scheme})
3967
require.NoError(t, err)
4068

@@ -48,7 +76,7 @@ func TestExtensionDeveloper(t *testing.T) {
4876
Source: ocv1.CatalogSource{
4977
Type: ocv1.SourceTypeImage,
5078
Image: &ocv1.ImageSource{
51-
Ref: os.Getenv("CATALOG_IMG"),
79+
Ref: os.Getenv("CLUSTER_REGISTRY_HOST") + "/" + catalogTag,
5280
},
5381
},
5482
},
@@ -73,7 +101,7 @@ func TestExtensionDeveloper(t *testing.T) {
73101
Source: ocv1.SourceConfig{
74102
SourceType: "Catalog",
75103
Catalog: &ocv1.CatalogFilter{
76-
PackageName: os.Getenv("REG_PKG_NAME"),
104+
PackageName: regPkgName,
77105
},
78106
},
79107
Namespace: installNamespace,

test/extension-developer-e2e/setup.sh

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11,35 +11,29 @@ following bundle formats:
1111
This script will ensure that all images built are loaded onto
1212
a KinD cluster with the name specified in the arguments.
1313
The following environment variables are required for configuring this script:
14-
- \$E2E_TEST_CATALOG_V1 - the tag for the catalog image that contains the registry+v1 bundle.
15-
- \$REG_PKG_NAME - the name of the package for the extension that uses the registry+v1 bundle format.
16-
setup.sh also takes 5 arguments.
14+
- \$OPERATOR_SDK - path to the operator-sdk binary.
15+
- \$CONTAINER_RUNTIME - container runtime to use (e.g. docker, podman).
16+
- \$KUSTOMIZE - path to the kustomize binary.
17+
- \$LOCAL_REGISTRY_HOST - registry address accessible from the test process.
18+
- \$CLUSTER_REGISTRY_HOST - registry address accessible from inside the cluster.
19+
- \$CATALOG_TAG - OCI tag for the catalog image (e.g. e2e/test-catalog:v1).
20+
- \$REG_PKG_NAME - the name of the package for the extension.
1721
1822
Usage:
19-
setup.sh [OPERATOR_SDK] [CONTAINER_RUNTIME] [KUSTOMIZE] [LOCAL_REGISTRY_HOST] [CLUSTER_REGISTRY_HOST]
23+
setup.sh
2024
"
2125

2226
########################################
2327
# Input validation
2428
########################################
2529

26-
if [[ "$#" -ne 5 ]]; then
27-
echo "Illegal number of arguments passed"
28-
echo "${help}"
29-
exit 1
30-
fi
31-
32-
if [[ -z "${E2E_TEST_CATALOG_V1}" ]]; then
33-
echo "\$E2E_TEST_CATALOG_V1 is required to be set"
34-
echo "${help}"
35-
exit 1
36-
fi
37-
38-
if [[ -z "${REG_PKG_NAME}" ]]; then
39-
echo "\$REG_PKG_NAME is required to be set"
40-
echo "${help}"
41-
exit 1
42-
fi
30+
for var in OPERATOR_SDK CONTAINER_RUNTIME KUSTOMIZE LOCAL_REGISTRY_HOST CLUSTER_REGISTRY_HOST CATALOG_TAG REG_PKG_NAME; do
31+
if [[ -z "${!var:-}" ]]; then
32+
echo "\$$var is required to be set"
33+
echo "${help}"
34+
exit 1
35+
fi
36+
done
4337

4438
########################################
4539
# Setup temp dir and local variables
@@ -54,21 +48,21 @@ DOMAIN=oc-opdev-e2e.operatorframework.io
5448
REG_DIR="${TMP_ROOT}/registry"
5549
mkdir -p "${REG_DIR}"
5650

57-
operator_sdk=$1
58-
container_tool=$2
59-
kustomize=$3
51+
operator_sdk="${OPERATOR_SDK}"
52+
container_tool="${CONTAINER_RUNTIME}"
53+
kustomize="${KUSTOMIZE}"
6054
# The path we use to push the image from _outside_ the cluster
61-
local_registry_host=$4
55+
local_registry_host="${LOCAL_REGISTRY_HOST}"
6256
# The path we use _inside_ the cluster
63-
cluster_registry_host=$5
57+
cluster_registry_host="${CLUSTER_REGISTRY_HOST}"
6458

6559
tls_flag=""
6660
if [[ "$container_tool" == "podman" ]]; then
6761
echo "Using podman container runtime; adding tls disable flag"
6862
tls_flag="--tls-verify=false"
6963
fi
7064

71-
catalog_push_tag="${local_registry_host}/${E2E_TEST_CATALOG_V1}"
65+
catalog_push_tag="${local_registry_host}/${CATALOG_TAG}"
7266
reg_pkg_name="${REG_PKG_NAME}"
7367

7468
reg_img="${DOMAIN}/registry:v0.0.1"
@@ -102,6 +96,7 @@ reg_bundle_push_tag="${local_registry_host}/${reg_bundle_path}"
10296
--resource --controller && \
10397
export OPERATOR_SDK="${operator_sdk}" && \
10498
make generate manifests && \
99+
sed -i -e 's/$(CONTAINER_TOOL) build/$(CONTAINER_TOOL) build --provenance=false/' Makefile && \
105100
make docker-build IMG="${reg_img}" && \
106101
sed -i -e 's/$(OPERATOR_SDK) generate kustomize manifests -q/$(OPERATOR_SDK) generate kustomize manifests -q --interactive=false/g' Makefile && \
107102
make bundle IMG="${reg_img}" VERSION=0.0.1 && \
@@ -153,5 +148,5 @@ cat <<EOF > "${TMP_ROOT}"/catalog/index.yaml
153148
}
154149
EOF
155150

156-
${container_tool} build -f "${TMP_ROOT}/catalog.Dockerfile" -t "${catalog_push_tag}" "${TMP_ROOT}/"
151+
${container_tool} build --provenance=false -f "${TMP_ROOT}/catalog.Dockerfile" -t "${catalog_push_tag}" "${TMP_ROOT}/"
157152
${container_tool} push ${catalog_push_tag} ${tls_flag}

0 commit comments

Comments
 (0)