From 2b2862e6115ab04e7cea5d61a700fc3ee75ede26 Mon Sep 17 00:00:00 2001 From: Jeff Roche Date: Wed, 12 Jul 2023 15:44:32 -0400 Subject: [PATCH] chore: decoupling the e2e tests from operator deployment --- Makefile | 23 ++++++++--------------- README.md | 26 +++++++++++++++----------- hack/deploy-local.sh | 15 +++++++++++++++ hack/local-e2e.sh | 17 ----------------- hack/release-local.sh | 2 +- 5 files changed, 39 insertions(+), 44 deletions(-) create mode 100755 hack/deploy-local.sh delete mode 100755 hack/local-e2e.sh diff --git a/Makefile b/Makefile index 660c2d469..73867503c 100644 --- a/Makefile +++ b/Makefile @@ -362,18 +362,11 @@ git-unsanitize: release-local-operator: IMAGE_REPO=$(IMAGE_REPO) hack/release-local.sh -.PHONY: release-local-bundle -release-local-bundle: - IMAGE_REPO=$(IMAGE_REPO) \ - BUNDLE_REPO=$(BUNDLE_REPO) hack/release-local.sh - -.PHONY: release-local-catalog -release-local-catalog: opm - IMAGE_REPO=$(IMAGE_REPO) \ - BUNDLE_REPO=$(BUNDLE_REPO) \ - CATALOG_REPO=$(CATALOG_REPO) \ - OPM=$(OPM) hack/release-local.sh - -.PHONY: local-e2e -local-e2e: - hack/local-e2e.sh \ No newline at end of file +.PHONY: deploy-local +deploy-local: + hack/deploy-local.sh + +.PHONY: e2e +e2e: ginkgo + cd test/e2e && $(GINKGO) build + cd test/e2e && ./e2e.test --lvm-operator-install=false --lvm-operator-uninstall=false -ginkgo.v \ No newline at end of file diff --git a/README.md b/README.md index 0bc50f73b..b37ac0cfd 100644 --- a/README.md +++ b/README.md @@ -321,26 +321,30 @@ To perform a full cleanup, follow these steps: ## E2E Tests -There are a few steps require to run the end-to-end tests for LVMS. +There are a few steps required to run the end-to-end tests for LVMS. You will need the following evironment variables set: ```bash IMAGE_REGISTRY={{REGISTRY_URL}} # Ex: quay.io -REGISTRY_NAMESPACE={{REGISTRY_NAMESPACE}} # Ex: lvms-dev +REGISTRY_NAMESPACE={{REGISTRY_NAMESPACE}} # Ex: lvms-dev, this should be your own personal namespace ``` Once the environment variables are set, you can run ```bash -$ make local-e2e -``` +# build and deploy your local code to the cluster +$ make deploy-local + +# Wait for the lvms-operator to have status=Running +$ oc -n openshift-storage get pods +# NAME READY STATUS RESTARTS AGE +# lvms-operator-579fbf46d5-vjwhp 3/3 Running 0 3m27s -That command will: -- Do any repo sanitization needed (in case changes are made) -- Build the Operator and tag it with the git hash -- Build the Operator Bundle and tag it with the git hash -- Build the Operator Catalog adn tag it with the git hash -- Run the e2e tests against the built images -- Undo any sanitization that was needed for the repo +# run the e2e tests +$ make e2e + +# undeploy the operator from the cluster +$ make undeploy +``` ## Metrics diff --git a/hack/deploy-local.sh b/hack/deploy-local.sh new file mode 100755 index 000000000..f31ed5a24 --- /dev/null +++ b/hack/deploy-local.sh @@ -0,0 +1,15 @@ +#!/bin/bash +set -euo pipefail + +make git-sanitize + +# Build and push the operator +make release-local-operator + +# Run the tests +GITREV=$(git rev-parse HEAD) + +export IMAGE_TAG="${GITREV}" +make deploy + +make git-unsanitize \ No newline at end of file diff --git a/hack/local-e2e.sh b/hack/local-e2e.sh deleted file mode 100755 index d0cf66596..000000000 --- a/hack/local-e2e.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash -set -euo pipefail - -# Sanitize the local repo (there are probably changes if this is being run locally) -make git-sanitize - -# Make sure the operater, bundle, and catalog are fresh -make release-local-catalog - -# Run the tests -GITREV=$(git rev-parse HEAD) - -export IMAGE_TAG="${GITREV}" -make e2e-test - -# Cleanup any sanitization work -make git-unsanitize \ No newline at end of file diff --git a/hack/release-local.sh b/hack/release-local.sh index b5d07c6d1..1a9188c4b 100755 --- a/hack/release-local.sh +++ b/hack/release-local.sh @@ -25,13 +25,13 @@ fi # If BUNDLE_REPO is defined, build the bundle BUNDLE_REPO="${BUNDLE_REPO:-}" +CATALOG_REPO="${CATALOG_REPO:-}" if [ -n "$BUNDLE_REPO" ]; then BUNDLE_IMG=${BUNDLE_REPO}:${GITREV} ${BUILDER} build -f bundle.Dockerfile -t ${BUNDLE_IMG} . ${BUILDER} push ${BUNDLE_REPO}:${GITREV} # If CATALOG_REPO is defined, build the catalog - CATALOG_REPO="${CATALOG_REPO:-}" if [ -n "$CATALOG_REPO" ]; then OPM="${OPM:-}" if [ -z "$OPM" ]; then echo "ERROR: OPM is a required variable"; exit 1; fi