From fde5fa3fb00198d13cc758dc77de48fe1ca64c61 Mon Sep 17 00:00:00 2001 From: Jorge Turrado Ferrero Date: Tue, 2 May 2023 10:43:47 +0200 Subject: [PATCH] chore: Add logic to scale out/in the AKS cluster on every e2e test execution (#4456) --- .github/workflows/pr-e2e.yml | 11 +++++++++++ .github/workflows/template-main-e2e-test.yml | 11 +++++++++++ Makefile | 16 ++++++++++++++-- 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr-e2e.yml b/.github/workflows/pr-e2e.yml index cf5a2c8c035..fa06a83d6cd 100644 --- a/.github/workflows/pr-e2e.yml +++ b/.github/workflows/pr-e2e.yml @@ -126,6 +126,11 @@ jobs: with: secrets: ${{ toJSON(secrets) }} + - name: Scale cluster + run: make scale-node-pool + env: + NODE_POOL_SIZE: 4 + - name: Run end to end tests continue-on-error: true id: test @@ -152,6 +157,12 @@ jobs: env: TEST_CLUSTER_NAME: keda-pr-run + - name: Scale cluster + if: ${{ always() }} + run: make scale-node-pool + env: + NODE_POOL_SIZE: 1 + - name: React to comment with success uses: dkershner6/reaction-action@v1 if: steps.test.outcome == 'success' diff --git a/.github/workflows/template-main-e2e-test.yml b/.github/workflows/template-main-e2e-test.yml index e7ef145de9b..b99e6d4deee 100644 --- a/.github/workflows/template-main-e2e-test.yml +++ b/.github/workflows/template-main-e2e-test.yml @@ -23,6 +23,11 @@ jobs: with: secrets: ${{ toJSON(secrets) }} + - name: Scale cluster + run: make scale-node-pool + env: + NODE_POOL_SIZE: 4 + - name: Run end to end tests env: AWS_RUN_IDENTITY_TESTS: true @@ -35,6 +40,12 @@ jobs: if: ${{ always() }} run: make e2e-test-clean + - name: Scale cluster + if: ${{ always() }} + run: make scale-node-pool + env: + NODE_POOL_SIZE: 1 + - name: Upload test logs uses: actions/upload-artifact@v3 if: ${{ always() }} diff --git a/Makefile b/Makefile index 25077be6180..108644c6ad6 100644 --- a/Makefile +++ b/Makefile @@ -37,6 +37,7 @@ GIT_COMMIT ?= $(shell git rev-list -1 HEAD) DATE = $(shell date -u +"%Y.%m.%d.%H.%M.%S") TEST_CLUSTER_NAME ?= keda-nightly-run-3 +NODE_POOL_SIZE ?= 1 NON_ROOT_USER_ID ?= 1000 GCP_WI_PROVIDER ?= projects/${TF_GCP_PROJECT_NUMBER}/locations/global/workloadIdentityPools/${TEST_CLUSTER_NAME}/providers/${TEST_CLUSTER_NAME} @@ -81,14 +82,25 @@ install-test-deps: test: manifests generate fmt vet envtest install-test-deps ## Run tests and export the result to junit format. KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test -v 2>&1 ./... -coverprofile cover.out | go-junit-report -iocopy -set-exit-code -out report.xml -.PHONY: get-cluster-context -get-cluster-context: ## Get Azure cluster context. +.PHONY: +az-login: @az login --service-principal -u $(TF_AZURE_SP_APP_ID) -p "$(AZURE_SP_KEY)" --tenant $(TF_AZURE_SP_TENANT) + +.PHONY: get-cluster-context +get-cluster-context: az-login ## Get Azure cluster context. @az aks get-credentials \ --name $(TEST_CLUSTER_NAME) \ --subscription $(TF_AZURE_SUBSCRIPTION) \ --resource-group $(TF_AZURE_RESOURCE_GROUP) +.PHONY: scale-node-pool +scale-node-pool: az-login ## Scale nodepool. + @az aks scale \ + --name $(TEST_CLUSTER_NAME) \ + --subscription $(TF_AZURE_SUBSCRIPTION) \ + --resource-group $(TF_AZURE_RESOURCE_GROUP) \ + --node-count $(NODE_POOL_SIZE) + .PHONY: e2e-test e2e-test: get-cluster-context ## Run e2e tests against Azure cluster. TERMINFO=/etc/terminfo