Skip to content

Commit

Permalink
fix: Add step in makefile to get the cluster context and use it to de…
Browse files Browse the repository at this point in the history
…lete namespaces (#2683)

Signed-off-by: Jorge Turrado <jorge_turrado@hotmail.es>
  • Loading branch information
Jorge Turrado Ferrero authored Mar 1, 2022
1 parent 3f82ca8 commit 4e6be90
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/main-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,9 @@ jobs:
- name: Delete all e2e related namespaces
if: ${{ always() }}
run: make e2e-test-clean
env:
AZURE_RESOURCE_GROUP: ${{ secrets.AZURE_RESOURCE_GROUP }}
AZURE_SP_ID: ${{ secrets.AZURE_SP_ID }}
AZURE_SP_KEY: ${{ secrets.AZURE_SP_KEY }}
AZURE_SP_TENANT: ${{ secrets.AZURE_SP_TENANT }}
AZURE_SUBSCRIPTION: ${{ secrets.AZURE_SUBSCRIPTION }}
6 changes: 6 additions & 0 deletions .github/workflows/nightly-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,9 @@ jobs:
- name: Delete all e2e related namespaces
if: ${{ always() }}
run: make e2e-test-clean
env:
AZURE_RESOURCE_GROUP: ${{ secrets.AZURE_RESOURCE_GROUP }}
AZURE_SP_ID: ${{ secrets.AZURE_SP_ID }}
AZURE_SP_KEY: ${{ secrets.AZURE_SP_KEY }}
AZURE_SP_TENANT: ${{ secrets.AZURE_SP_TENANT }}
AZURE_SUBSCRIPTION: ${{ secrets.AZURE_SUBSCRIPTION }}
7 changes: 7 additions & 0 deletions .github/workflows/pr-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,13 @@ jobs:
- name: Delete all e2e related namespaces
if: ${{ always() }}
run: make e2e-test-clean
env:
AZURE_RESOURCE_GROUP: ${{ secrets.AZURE_RESOURCE_GROUP }}
AZURE_SP_ID: ${{ secrets.AZURE_SP_ID }}
AZURE_SP_KEY: ${{ secrets.AZURE_SP_KEY }}
AZURE_SP_TENANT: ${{ secrets.AZURE_SP_TENANT }}
AZURE_SUBSCRIPTION: ${{ secrets.AZURE_SUBSCRIPTION }}
TEST_CLUSTER_NAME: keda-pr-run

- name: React to comment with success
uses: dkershner6/reaction-action@v1
Expand Down
13 changes: 8 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,18 @@ all: build
test: manifests generate fmt vet envtest ## Run tests.
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test ./... -coverprofile cover.out

.PHONY: e2e-test
e2e-test: ## Run e2e tests against Azure cluster.
TERMINFO=/etc/terminfo
TERM=linux
.PHONY: get-cluster-context
get-cluster-context: ## Get Azure cluster context.
@az login --service-principal -u $(AZURE_SP_ID) -p "$(AZURE_SP_KEY)" --tenant $(AZURE_SP_TENANT)
@az aks get-credentials \
--name $(TEST_CLUSTER_NAME) \
--subscription $(AZURE_SUBSCRIPTION) \
--resource-group $(AZURE_RESOURCE_GROUP)

.PHONY: e2e-test
e2e-test: get-cluster-context ## Run e2e tests against Azure cluster.
TERMINFO=/etc/terminfo
TERM=linux
npm install --prefix tests

./tests/run-all.sh
Expand All @@ -88,7 +91,7 @@ e2e-test-local: ## Run e2e tests against Kubernetes cluster configured in ~/.kub
./tests/run-all.sh

.PHONY: e2e-test-clean
e2e-test-clean: ## Delete all namespaces labeled with type=e2e
e2e-test-clean: get-cluster-context ## Delete all namespaces labeled with type=e2e
kubectl delete ns -l type=e2e

##################################################
Expand Down

0 comments on commit 4e6be90

Please sign in to comment.