Skip to content

Commit

Permalink
chore: Add logic to scale out/in the AKS cluster on every e2e test ex…
Browse files Browse the repository at this point in the history
…ecution (kedacore#4456)
  • Loading branch information
JorTurFer committed May 2, 2023
1 parent 9b48588 commit fde5fa3
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/pr-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/template-main-e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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() }}
Expand Down
16 changes: 14 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit fde5fa3

Please sign in to comment.