diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index ca3b4645..58ca89ed 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -19,8 +19,7 @@ jobs: go-version-file: go.mod - name: Run the extension developer e2e test - run: | - make extension-developer-e2e + run: make extension-developer-e2e e2e-kind: runs-on: ubuntu-latest @@ -48,3 +47,15 @@ jobs: files: e2e-cover.out flags: e2e token: ${{ secrets.CODECOV_TOKEN }} + + upgrade-e2e: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-go@v5 + with: + go-version-file: go.mod + + - name: Run the upgrade e2e test + run: make test-upgrade-e2e diff --git a/Makefile b/Makefile index c2af631b..a5db041e 100644 --- a/Makefile +++ b/Makefile @@ -158,6 +158,24 @@ test-e2e: run image-registry build-push-e2e-catalog registry-load-bundles e2e e2 extension-developer-e2e: KIND_CLUSTER_NAME := operator-controller-ext-dev-e2e #EXHELP Run extension-developer e2e on local kind cluster extension-developer-e2e: run image-registry test-ext-dev-e2e kind-clean +.PHONY: run-latest-release +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 $(CATALOG_IMG) $(TEST_CLUSTER_CATALOG_NAME) $(TEST_CLUSTER_EXTENSION_NAME) + +.PHONY: post-upgrade-checks +post-upgrade-checks: + ./hack/post-upgrade-checks.sh $(TEST_CLUSTER_CATALOG_NAME) $(TEST_CLUSTER_EXTENSION_NAME) + +.PHONY: test-upgrade-e2e +test-upgrade-e2e: KIND_CLUSTER_NAME := operator-controller-upgrade-e2e +test-upgrade-e2e: TEST_CLUSTER_CATALOG_NAME := test-catalog +test-upgrade-e2e: TEST_CLUSTER_EXTENSION_NAME := test-package +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: COVERAGE_OUTPUT=./e2e-cover.out ./hack/e2e-coverage.sh diff --git a/hack/post-upgrade-checks.sh b/hack/post-upgrade-checks.sh new file mode 100755 index 00000000..78fe04f5 --- /dev/null +++ b/hack/post-upgrade-checks.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +set -euo pipefail + +help="post-upgrade-checks.sh is used to perform tests after upgrade from the previous release. + +Usage: + post-upgrade-checks.sh [TEST_CLUSTER_CATALOG_NAME] [TEST_CLUSTER_EXTENSION_NAME] +" + +if [[ "$#" -ne 2 ]]; then + echo "Illegal number of arguments passed" + echo "${help}" + exit 1 +fi + +TEST_CLUSTER_CATALOG_NAME=$1 +TEST_CLUSTER_EXTENSION_NAME=$2 + +kubectl wait --for=condition=Available --timeout=60s -n olmv1-system deployment --all +kubectl wait --for=condition=Unpacked --timeout=60s ClusterCatalog $TEST_CLUSTER_CATALOG_NAME +kubectl wait --for=condition=Installed --timeout=60s ClusterExtension $TEST_CLUSTER_EXTENSION_NAME diff --git a/hack/pre-upgrade-setup.sh b/hack/pre-upgrade-setup.sh new file mode 100755 index 00000000..07243c0e --- /dev/null +++ b/hack/pre-upgrade-setup.sh @@ -0,0 +1,48 @@ +#!/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. + +Usage: + post-upgrade-checks.sh [TEST_CATALOG_IMG] [TEST_CATALOG_NAME] [TEST_CLUSTER_EXTENSION_NAME] +" + +if [[ "$#" -ne 3 ]]; then + echo "Illegal number of arguments passed" + echo "${help}" + exit 1 +fi + +TEST_CATALOG_IMG=$1 +TEST_CLUSTER_CATALOG_NAME=$2 +TEST_CLUSTER_EXTENSION_NAME=$3 + +kubectl apply -f - << EOF +apiVersion: catalogd.operatorframework.io/v1alpha1 +kind: ClusterCatalog +metadata: + name: ${TEST_CLUSTER_CATALOG_NAME} +spec: + source: + type: image + image: + ref: ${TEST_CATALOG_IMG} + pollInterval: 24h + insecureSkipTLSVerify: true +EOF + + +kubectl apply -f - << EOF +apiVersion: olm.operatorframework.io/v1alpha1 +kind: ClusterExtension +metadata: + name: ${TEST_CLUSTER_EXTENSION_NAME} +spec: + installNamespace: default + packageName: prometheus +EOF + +kubectl wait --for=condition=Unpacked --timeout=60s ClusterCatalog $TEST_CLUSTER_CATALOG_NAME +kubectl wait --for=condition=Installed --timeout=60s ClusterExtension $TEST_CLUSTER_EXTENSION_NAME