From 2a80ce1600fe0444c77f688f816c997fa861e29e Mon Sep 17 00:00:00 2001 From: Catherine Chan-Tse Date: Fri, 15 Aug 2025 15:26:20 -0400 Subject: [PATCH 1/3] Add NetworkPolicy to e2e tests --- test/e2e/bundle_e2e_test.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test/e2e/bundle_e2e_test.go b/test/e2e/bundle_e2e_test.go index 9accdbb9c0..b4985a8010 100644 --- a/test/e2e/bundle_e2e_test.go +++ b/test/e2e/bundle_e2e_test.go @@ -47,7 +47,8 @@ var _ = Describe("Installing bundles with new object types", Label("ObjectTypes" TeardownNamespace(generatedNamespace.GetName()) }) - When("a bundle with a pdb, priorityclass, and VPA object is installed", func() { + When("a bundle that includes supported resources is installed", func() { + // Supported resources installed are a NetworkPolicy, pdb, priorityclass, and VPA object const ( packageName = "busybox" channelName = "alpha" @@ -141,6 +142,7 @@ var _ = Describe("Installing bundles with new object types", Label("ObjectTypes" pdbName = "busybox-pdb" priorityClassName = "super-priority" vpaName = "busybox-vpa" + networkPolicyName = "busybox-networkpolicy" ) var resource = schema.GroupVersionResource{ @@ -164,6 +166,11 @@ var _ = Describe("Installing bundles with new object types", Label("ObjectTypes" _, err := kubeClient.KubernetesInterface().PolicyV1().PodDisruptionBudgets(generatedNamespace.GetName()).Get(context.Background(), pdbName, metav1.GetOptions{}) return err }).Should(Succeed(), "expected no error getting pdb object associated with CSV") + + Eventually(func() error { + _, err := kubeClient.KubernetesInterface().NetworkingV1().NetworkPolicies(generatedNamespace.GetName()).Get(context.Background(), networkPolicyName, metav1.GetOptions{}) + return err + }).Should(Succeed(), "expected no error finding networkpolicy object associated with CSV") }) AfterEach(func() { From f0ece0dd5be358e41f4ea132bd18de3c31cee6b2 Mon Sep 17 00:00:00 2001 From: Catherine Chan-Tse Date: Tue, 26 Aug 2025 16:40:38 +0100 Subject: [PATCH 2/3] Update e2e to test NP support --- .../busybox/1.0.0/manifests/csv.yaml | 6 +++ test/images/single-bundle-image/csv.yaml | 42 +++++++++++++++++++ .../single-bundle-image/networkpolicy.yaml | 8 ++++ .../poddisruptionbudget.yaml | 9 ++++ .../single-bundle-image/priorityclass.yaml | 7 ++++ .../verticalpodautoscaler.yaml | 11 +++++ 6 files changed, 83 insertions(+) create mode 100644 test/images/single-bundle-image/csv.yaml create mode 100644 test/images/single-bundle-image/networkpolicy.yaml create mode 100644 test/images/single-bundle-image/poddisruptionbudget.yaml create mode 100644 test/images/single-bundle-image/priorityclass.yaml create mode 100644 test/images/single-bundle-image/verticalpodautoscaler.yaml diff --git a/test/images/busybox-index/busybox/1.0.0/manifests/csv.yaml b/test/images/busybox-index/busybox/1.0.0/manifests/csv.yaml index 83153df57d..92d804c296 100644 --- a/test/images/busybox-index/busybox/1.0.0/manifests/csv.yaml +++ b/test/images/busybox-index/busybox/1.0.0/manifests/csv.yaml @@ -34,6 +34,12 @@ spec: command: - sleep - "9000" + permissions: + - serviceAccountName: busybox-operator + rules: + - apiGroups: ["networking.k8s.io"] + resources: ["networkpolicies"] + verbs: ["get", "list", "create", "update", "delete"] strategy: deployment installModes: - supported: true diff --git a/test/images/single-bundle-image/csv.yaml b/test/images/single-bundle-image/csv.yaml new file mode 100644 index 0000000000..8ef57b02b3 --- /dev/null +++ b/test/images/single-bundle-image/csv.yaml @@ -0,0 +1,42 @@ +apiVersion: operators.coreos.com/v1alpha1 +kind: ClusterServiceVersion +metadata: + name: busybox.v2.0.0 + namespace: operators +spec: + description: busybox + displayName: busybox + install: + spec: + deployments: + - name: busybox + spec: + replicas: 1 + selector: + matchLabels: + app: busybox + template: + metadata: + labels: + app: busybox + spec: + containers: + - command: + - sleep + - "9000" + image: busybox + name: busybox + strategy: deployment + installModes: + - supported: true + type: OwnNamespace + - supported: true + type: SingleNamespace + - supported: true + type: MultiNamespace + - supported: true + type: AllNamespaces + maturity: alpha + provider: + name: Red Hat + version: 2.0.0 diff --git a/test/images/single-bundle-image/networkpolicy.yaml b/test/images/single-bundle-image/networkpolicy.yaml new file mode 100644 index 0000000000..22df3ca243 --- /dev/null +++ b/test/images/single-bundle-image/networkpolicy.yaml @@ -0,0 +1,8 @@ +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + name: busybox-networkpolicy +spec: + podSelector: {} + policyTypes: + - Ingress \ No newline at end of file diff --git a/test/images/single-bundle-image/poddisruptionbudget.yaml b/test/images/single-bundle-image/poddisruptionbudget.yaml new file mode 100644 index 0000000000..4a1f5317b3 --- /dev/null +++ b/test/images/single-bundle-image/poddisruptionbudget.yaml @@ -0,0 +1,9 @@ +apiVersion: policy/v1 +kind: PodDisruptionBudget +metadata: + name: busybox-pdb +spec: + minAvailable: 2 + selector: + matchLabels: + app: busybox \ No newline at end of file diff --git a/test/images/single-bundle-image/priorityclass.yaml b/test/images/single-bundle-image/priorityclass.yaml new file mode 100644 index 0000000000..33344bd99f --- /dev/null +++ b/test/images/single-bundle-image/priorityclass.yaml @@ -0,0 +1,7 @@ +apiVersion: scheduling.k8s.io/v1 +kind: PriorityClass +metadata: + name: super-priority +description: This priority class should be used for XYZ service pods only. +globalDefault: false +value: 1000 \ No newline at end of file diff --git a/test/images/single-bundle-image/verticalpodautoscaler.yaml b/test/images/single-bundle-image/verticalpodautoscaler.yaml new file mode 100644 index 0000000000..1ee8fc3bc3 --- /dev/null +++ b/test/images/single-bundle-image/verticalpodautoscaler.yaml @@ -0,0 +1,11 @@ +apiVersion: autoscaling.k8s.io/v1 +kind: VerticalPodAutoscaler +metadata: + name: busybox-vpa +spec: + targetRef: + apiVersion: apps/v1 + kind: Deployment + name: busybox + updatePolicy: + updateMode: "Off" \ No newline at end of file From 64d5179290974110b1239278bd3988ecb4232670 Mon Sep 17 00:00:00 2001 From: Tayler Geiger Date: Wed, 27 Aug 2025 14:35:03 -0500 Subject: [PATCH 3/3] Add single-bundle-index build script Adds to script for building the single-bundle-index image used in the e2e tests. Also adds the necessary manifests and Containerfile for the bundle in that index, and adds a note in DEVELOPMENT.md about using the script for updating the images used in e2e tests. Signed-off-by: Tayler Geiger --- DEVELOPMENT.md | 8 +++++ scripts/build_e2e_test_images.sh | 30 +++++++++++++++++++ scripts/build_test_images.sh | 19 ------------ test/e2e/bundle_e2e_test.go | 2 +- test/images/single-bundle-image/Containerfile | 13 ++++++++ .../{ => manifests}/csv.yaml | 0 .../{ => manifests}/networkpolicy.yaml | 2 +- .../{ => manifests}/poddisruptionbudget.yaml | 3 +- .../{ => manifests}/priorityclass.yaml | 2 +- .../verticalpodautoscaler.yaml | 2 +- .../metadata/annotations.yaml | 7 +++++ 11 files changed, 64 insertions(+), 24 deletions(-) create mode 100755 scripts/build_e2e_test_images.sh delete mode 100755 scripts/build_test_images.sh create mode 100644 test/images/single-bundle-image/Containerfile rename test/images/single-bundle-image/{ => manifests}/csv.yaml (100%) rename test/images/single-bundle-image/{ => manifests}/networkpolicy.yaml (90%) rename test/images/single-bundle-image/{ => manifests}/poddisruptionbudget.yaml (86%) rename test/images/single-bundle-image/{ => manifests}/priorityclass.yaml (93%) rename test/images/single-bundle-image/{ => manifests}/verticalpodautoscaler.yaml (89%) create mode 100644 test/images/single-bundle-image/metadata/annotations.yaml diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index f3c2ef0e92..90935f7eb4 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -46,6 +46,14 @@ To run a specific e2e test locally: $ make e2e-local TEST=TestCreateInstallPlanManualApproval ``` +##### Updating test images + +Sometimes you will need to update the index or bundle images used in the unit or e2e tests. To update those images, you will need to be logged into quay.io with membership in the `olmtest` organization. Then simply run `./scripts/build_e2e_test_images.sh` which will build all the required bundle images, push those to quay.io, build all the index images, and push those to quay.io as well. + +Please be aware that these scripts push directly to the image tags used by the actual e2e tests. + +The contents and Containerfiles of these bundles can be found in `./test/images/`. + [controller-runtime instructions]: https://pkg.go.dev/sigs.k8s.io/controller-runtime/tools/setup-envtest#section-readme #### Building diff --git a/scripts/build_e2e_test_images.sh b/scripts/build_e2e_test_images.sh new file mode 100755 index 0000000000..916a07898d --- /dev/null +++ b/scripts/build_e2e_test_images.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash + +QUAY_REPO="${QUAY_REPO:-olmtest}" +SINGLE_BUNDLE_TAG="${BUNDLE_TAG:-objects-pdb-v2}" +SINGLE_BUNDLE_INDEX_TAG="${INDEX_TAG:-pdb-v2}" + +# Busybox Operator Index Image +docker build -t quay.io/${QUAY_REPO}/busybox-bundle:1.0.0 ./test/images/busybox-index/busybox/1.0.0 +docker build -t quay.io/${QUAY_REPO}/busybox-bundle:2.0.0 ./test/images/busybox-index/busybox/2.0.0 + +docker build -t quay.io/${QUAY_REPO}/busybox-dependency-bundle:1.0.0 ./test/images/busybox-index/busybox-dependency/1.0.0 +docker build -t quay.io/${QUAY_REPO}/busybox-dependency-bundle:2.0.0 ./test/images/busybox-index/busybox-dependency/2.0.0 + +docker push quay.io/${QUAY_REPO}/busybox-bundle:1.0.0 +docker push quay.io/${QUAY_REPO}/busybox-bundle:2.0.0 +docker push quay.io/${QUAY_REPO}/busybox-dependency-bundle:1.0.0 +docker push quay.io/${QUAY_REPO}/busybox-dependency-bundle:2.0.0 + +opm index add --bundles quay.io/${QUAY_REPO}/busybox-dependency-bundle:1.0.0,quay.io/olmtest/busybox-bundle:1.0.0 --tag quay.io/olmtest/busybox-dependencies-index:1.0.0-with-ListBundles-method -c docker +docker push quay.io/${QUAY_REPO}/busybox-dependencies-index:1.0.0-with-ListBundles-method + +opm index add --bundles quay.io/${QUAY_REPO}/busybox-dependency-bundle:2.0.0,quay.io/olmtest/busybox-bundle:2.0.0 --tag quay.io/olmtest/busybox-dependencies-index:2.0.0-with-ListBundles-method --from-index quay.io/olmtest/busybox-dependencies-index:1.0.0-with-ListBundles-method -c docker +docker push quay.io/${QUAY_REPO}/busybox-dependencies-index:2.0.0-with-ListBundles-method + +# Single Bundle E2E Test Image +docker build -t quay.io/${QUAY_REPO}/bundle:${BUNDLE_TAG} ./test/images/single-bundle-index +docker push quay.io/${QUAY_REPO}/bundle:${BUNDLE_TAG} + +opm index add --bundles quay.io/${QUAY_REPO}/bundle:${BUNDLE_TAG} --tag quay.io/${QUAY_REPO}/single-bundle-index:${INDEX_TAG} -c docker +docker push quay.io/${QUAY_REPO}/single-bundle-index:${INDEX_TAG} diff --git a/scripts/build_test_images.sh b/scripts/build_test_images.sh deleted file mode 100755 index 32f1fcaa6e..0000000000 --- a/scripts/build_test_images.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash - -# Busybox Operator Index Image -docker build -t quay.io/olmtest/busybox-bundle:1.0.0 ./test/images/busybox-index/busybox/1.0.0 -docker build -t quay.io/olmtest/busybox-bundle:2.0.0 ./test/images/busybox-index/busybox/2.0.0 - -docker build -t quay.io/olmtest/busybox-dependency-bundle:1.0.0 ./test/images/busybox-index/busybox-dependency/1.0.0 -docker build -t quay.io/olmtest/busybox-dependency-bundle:2.0.0 ./test/images/busybox-index/busybox-dependency/2.0.0 - -docker push quay.io/olmtest/busybox-bundle:1.0.0 -docker push quay.io/olmtest/busybox-bundle:2.0.0 -docker push quay.io/olmtest/busybox-dependency-bundle:1.0.0 -docker push quay.io/olmtest/busybox-dependency-bundle:2.0.0 - -opm index add --bundles quay.io/olmtest/busybox-dependency-bundle:1.0.0,quay.io/olmtest/busybox-bundle:1.0.0 --tag quay.io/olmtest/busybox-dependencies-index:1.0.0-with-ListBundles-method -c docker -docker push quay.io/olmtest/busybox-dependencies-index:1.0.0-with-ListBundles-method - -opm index add --bundles quay.io/olmtest/busybox-dependency-bundle:2.0.0,quay.io/olmtest/busybox-bundle:2.0.0 --tag quay.io/olmtest/busybox-dependencies-index:2.0.0-with-ListBundles-method --from-index quay.io/olmtest/busybox-dependencies-index:1.0.0-with-ListBundles-method -c docker -docker push quay.io/olmtest/busybox-dependencies-index:2.0.0-with-ListBundles-method diff --git a/test/e2e/bundle_e2e_test.go b/test/e2e/bundle_e2e_test.go index b4985a8010..365d1cdf27 100644 --- a/test/e2e/bundle_e2e_test.go +++ b/test/e2e/bundle_e2e_test.go @@ -60,7 +60,7 @@ var _ = Describe("Installing bundles with new object types", Label("ObjectTypes" By("first installing the VPA CRD on cluster") const ( sourceName = "test-catalog" - imageName = "quay.io/olmtest/single-bundle-index:pdb-v1" + imageName = "quay.io/olmtest/single-bundle-index:pdb-v2" ) By("create VPA CRD on cluster") diff --git a/test/images/single-bundle-image/Containerfile b/test/images/single-bundle-image/Containerfile new file mode 100644 index 0000000000..94c7d62983 --- /dev/null +++ b/test/images/single-bundle-image/Containerfile @@ -0,0 +1,13 @@ +FROM scratch + +# We are pushing an operator-registry bundle +# that has both metadata and manifests. +LABEL operators.operatorframework.io.bundle.mediatype.v1=registry+v1 +LABEL operators.operatorframework.io.bundle.manifests.v1=manifests/ +LABEL operators.operatorframework.io.bundle.metadata.v1=metadata/ +LABEL operators.operatorframework.io.bundle.package.v1=busybox +LABEL operators.operatorframework.io.bundle.channels.v1=alpha +LABEL operators.operatorframework.io.bundle.channel.default.v1=alpha + +COPY ./manifests/*.yaml /manifests/ +COPY ./metadata/annotations.yaml /metadata/annotations.yaml diff --git a/test/images/single-bundle-image/csv.yaml b/test/images/single-bundle-image/manifests/csv.yaml similarity index 100% rename from test/images/single-bundle-image/csv.yaml rename to test/images/single-bundle-image/manifests/csv.yaml diff --git a/test/images/single-bundle-image/networkpolicy.yaml b/test/images/single-bundle-image/manifests/networkpolicy.yaml similarity index 90% rename from test/images/single-bundle-image/networkpolicy.yaml rename to test/images/single-bundle-image/manifests/networkpolicy.yaml index 22df3ca243..9cfe91985e 100644 --- a/test/images/single-bundle-image/networkpolicy.yaml +++ b/test/images/single-bundle-image/manifests/networkpolicy.yaml @@ -5,4 +5,4 @@ metadata: spec: podSelector: {} policyTypes: - - Ingress \ No newline at end of file + - Ingress diff --git a/test/images/single-bundle-image/poddisruptionbudget.yaml b/test/images/single-bundle-image/manifests/poddisruptionbudget.yaml similarity index 86% rename from test/images/single-bundle-image/poddisruptionbudget.yaml rename to test/images/single-bundle-image/manifests/poddisruptionbudget.yaml index 4a1f5317b3..98f45c8781 100644 --- a/test/images/single-bundle-image/poddisruptionbudget.yaml +++ b/test/images/single-bundle-image/manifests/poddisruptionbudget.yaml @@ -6,4 +6,5 @@ spec: minAvailable: 2 selector: matchLabels: - app: busybox \ No newline at end of file + app: busybox + \ No newline at end of file diff --git a/test/images/single-bundle-image/priorityclass.yaml b/test/images/single-bundle-image/manifests/priorityclass.yaml similarity index 93% rename from test/images/single-bundle-image/priorityclass.yaml rename to test/images/single-bundle-image/manifests/priorityclass.yaml index 33344bd99f..92320d2fdb 100644 --- a/test/images/single-bundle-image/priorityclass.yaml +++ b/test/images/single-bundle-image/manifests/priorityclass.yaml @@ -4,4 +4,4 @@ metadata: name: super-priority description: This priority class should be used for XYZ service pods only. globalDefault: false -value: 1000 \ No newline at end of file +value: 1000 diff --git a/test/images/single-bundle-image/verticalpodautoscaler.yaml b/test/images/single-bundle-image/manifests/verticalpodautoscaler.yaml similarity index 89% rename from test/images/single-bundle-image/verticalpodautoscaler.yaml rename to test/images/single-bundle-image/manifests/verticalpodautoscaler.yaml index 1ee8fc3bc3..1b550efb60 100644 --- a/test/images/single-bundle-image/verticalpodautoscaler.yaml +++ b/test/images/single-bundle-image/manifests/verticalpodautoscaler.yaml @@ -8,4 +8,4 @@ spec: kind: Deployment name: busybox updatePolicy: - updateMode: "Off" \ No newline at end of file + updateMode: "Off" diff --git a/test/images/single-bundle-image/metadata/annotations.yaml b/test/images/single-bundle-image/metadata/annotations.yaml new file mode 100644 index 0000000000..8d4f3fd706 --- /dev/null +++ b/test/images/single-bundle-image/metadata/annotations.yaml @@ -0,0 +1,7 @@ +annotations: + operators.operatorframework.io.bundle.mediatype.v1: "registry+v1" + operators.operatorframework.io.bundle.manifests.v1: "manifests/" + operators.operatorframework.io.bundle.metadata.v1: "metadata/" + operators.operatorframework.io.bundle.package.v1: "busybox" + operators.operatorframework.io.bundle.channels.v1: "alpha" + operators.operatorframework.io.bundle.channel.default.v1: "alpha"