From 50fda656e8fce3658dae13e3a747091559df7924 Mon Sep 17 00:00:00 2001 From: Adem Baccara <71262172+Adembc@users.noreply.github.com> Date: Mon, 5 Aug 2024 17:42:39 +0100 Subject: [PATCH] test(ws): add safety prompt for E2E test execution (#28) * test(ws): add safety prompt for E2E test execution Signed-off-by: Adem Baccara <71262172+Adembc@users.noreply.github.com> * mathew updates 1 Signed-off-by: Mathew Wicks <5735406+thesuperzapper@users.noreply.github.com> --------- Signed-off-by: Adem Baccara <71262172+Adembc@users.noreply.github.com> Signed-off-by: Mathew Wicks <5735406+thesuperzapper@users.noreply.github.com> Co-authored-by: Mathew Wicks <5735406+thesuperzapper@users.noreply.github.com> --- workspaces/controller/Makefile | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/workspaces/controller/Makefile b/workspaces/controller/Makefile index c78348a1..2178694e 100644 --- a/workspaces/controller/Makefile +++ b/workspaces/controller/Makefile @@ -66,8 +66,8 @@ test: manifests generate fmt vet envtest ## Run tests. # Utilize Kind or modify the e2e tests to load the image locally, enabling compatibility with other vendors. .PHONY: test-e2e # Run the e2e tests against a Kind k8s instance that is spun up. test-e2e: + @$(prompt_for_e2e_test_execution) go test ./test/e2e/ -v -ginkgo.v - .PHONY: lint lint: golangci-lint ## Run golangci-lint linter & yamllint $(GOLANGCI_LINT) run @@ -196,3 +196,25 @@ GOBIN=$(LOCALBIN) go install $${package} ;\ mv "$$(echo "$(1)" | sed "s/-$(3)$$//")" $(1) ;\ } endef + +define prompt_for_e2e_test_execution + if [ "$$(echo "$(KUBEFLOW_TEST_PROMPT)" | tr '[:upper:]' '[:lower:]')" = "false" ]; then \ + echo "Skipping E2E test confirmation prompt (KUBEFLOW_TEST_PROMPT is set to true)"; \ + else \ + current_k8s_context=$$(kubectl config current-context); \ + echo "================================ WARNING ================================"; \ + echo "E2E tests use your current Kubernetes context!"; \ + echo "This will DELETE EXISTING RESOURCES such as cert-manager!"; \ + echo "Current context: '$$current_k8s_context'"; \ + echo "========================================================================="; \ + echo "Proceed with E2E tests? (yes/NO)"; \ + read user_confirmation; \ + case $$user_confirmation in \ + [yY] | [yY][eE][sS] ) \ + echo "Running E2E tests...";; \ + [nN] | [nN][oO] | * ) \ + echo "Aborting E2E tests..."; \ + exit 1; \ + esac \ + fi +endef