From 90c602f0c5a187483b251507b59e18972c1f29d8 Mon Sep 17 00:00:00 2001 From: Mikalai Radchuk Date: Tue, 2 Jul 2024 16:17:34 +0200 Subject: [PATCH] fixup! Add upgrade E2E Signed-off-by: Mikalai Radchuk --- Makefile | 10 +++++++- hack/post-upgrade-checks.sh | 10 ++++++++ hack/pre-upgrade-setup.sh | 47 +++++++++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+), 1 deletion(-) create mode 100755 hack/post-upgrade-checks.sh create mode 100755 hack/pre-upgrade-setup.sh diff --git a/Makefile b/Makefile index acdabbc9..6142677e 100644 --- a/Makefile +++ b/Makefile @@ -162,9 +162,17 @@ extension-developer-e2e: run image-registry test-ext-dev-e2e kind-clean run-latest-release: curl -L -s https://github.com/operator-framework/operator-controller/releases/latest/download/install.sh | bash -s +.PHONY: pre-upgrade-setup +pre-upgrade-setup: + ./hack/pre-upgrade-setup.sh + +.PHONY: pre-upgrade-setup +post-upgrade-checks: + ./hack/post-upgrade-checks.sh + .PHONY: test-upgrade-e2e test-upgrade-e2e: KIND_CLUSTER_NAME := operator-controller-upgrade-e2e -test-upgrade-e2e: kind-cluster run-latest-release image-registry build-push-e2e-catalog registry-load-bundles docker-build kind-load kind-deploy kind-clean #HELP Run upgrade e2e tests on a local kind cluster +test-upgrade-e2e: kind-cluster run-latest-release image-registry build-push-e2e-catalog registry-load-bundles pre-upgrade-setup docker-build kind-load kind-deploy post-upgrade-checks kind-clean #HELP Run upgrade e2e tests on a local kind cluster .PHONY: e2e-coverage e2e-coverage: diff --git a/hack/post-upgrade-checks.sh b/hack/post-upgrade-checks.sh new file mode 100755 index 00000000..c3be8107 --- /dev/null +++ b/hack/post-upgrade-checks.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +set -euo pipefail + +TEST_CATALOG_NAME="test-catalog" +TEST_EXTENSION_NAME="test-package" + +kubectl wait --for=condition=Available --timeout=60s -n olmv1-system deployment --all +kubectl wait --for=condition=Unpacked --timeout=60s ClusterCatalog $TEST_CATALOG_NAME +kubectl wait --for=condition=Installed --timeout=60s ClusterExtension $TEST_EXTENSION_NAME diff --git a/hack/pre-upgrade-setup.sh b/hack/pre-upgrade-setup.sh new file mode 100755 index 00000000..56e80f7c --- /dev/null +++ b/hack/pre-upgrade-setup.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +set -euo pipefail + +help="pre-upgrade-setup.sh is used to create some basic resources +which will later be used in upgrade testing. + +The following environment variables are required for configuring this script: +- \$CATALOG_IMG - the tag for the catalog image that contains the registry+v1 bundle. +" + +TEST_CATALOG_NAME="test-catalog" +TEST_EXTENSION_NAME="test-package" + +if [[ -z "${CATALOG_IMG}" ]]; then + echo "\$CATALOG_IMG is required to be set" + echo "${help}" + exit 1 +fi + +kubectl apply -f - << EOF +apiVersion: catalogd.operatorframework.io/v1alpha1 +kind: ClusterCatalog +metadata: + name: ${TEST_CATALOG_NAME} +spec: + source: + type: image + image: + ref: ${CATALOG_IMG} + pollInterval: 24h + insecureSkipTLSVerify: true +EOF + + +kubectl apply -f - << EOF +apiVersion: olm.operatorframework.io/v1alpha1 +kind: ClusterExtension +metadata: + name: ${TEST_EXTENSION_NAME} +spec: + installNamespace: default + packageName: prometheus +EOF + +kubectl wait --for=condition=Unpacked --timeout=60s ClusterCatalog $TEST_CATALOG_NAME +kubectl wait --for=condition=Installed --timeout=60s ClusterExtension $TEST_EXTENSION_NAME