From 3115d7147116bf12495d184845a5ed15a0609226 Mon Sep 17 00:00:00 2001 From: Yusuke Kuoka Date: Sun, 27 Feb 2022 11:43:07 +0000 Subject: [PATCH] acceptance,e2e: Enhance deploy.sh to support more types of runnersets --- acceptance/deploy.sh | 29 ++++++++++++----- ...runnerset.yaml => runnerset.envsubst.yaml} | 31 ++++++++++++++++--- test/e2e/e2e_test.go | 2 ++ 3 files changed, 51 insertions(+), 11 deletions(-) rename acceptance/testdata/{repo.runnerset.yaml => runnerset.envsubst.yaml} (71%) diff --git a/acceptance/deploy.sh b/acceptance/deploy.sh index 953293e8..80793301 100755 --- a/acceptance/deploy.sh +++ b/acceptance/deploy.sh @@ -70,9 +70,8 @@ sleep 20 RUNNER_LABEL=${RUNNER_LABEL:-self-hosted} if [ -n "${TEST_REPO}" ]; then - if [ "${USE_RUNNERSET}" -ne "false" ]; then - cat acceptance/testdata/repo.runnerset.yaml | envsubst | kubectl apply -f - - cat acceptance/testdata/repo.runnerset.hra.yaml | envsubst | kubectl apply -f - + if [ "${USE_RUNNERSET}" != "false" ]; then + cat acceptance/testdata/runnerset.envsubst.yaml | TEST_ENTERPRISE= TEST_ORG= RUNNER_MIN_REPLICAS=${REPO_RUNNER_MIN_REPLICAS} NAME=repo-runnerset envsubst | kubectl apply -f - else echo 'Deploying runnerdeployment and hra. Set USE_RUNNERSET if you want to deploy runnerset instead.' cat acceptance/testdata/repo.runnerdeploy.yaml | envsubst | kubectl apply -f - @@ -83,10 +82,18 @@ else fi if [ -n "${TEST_ORG}" ]; then - cat acceptance/testdata/runnerdeploy.envsubst.yaml | TEST_ENTERPRISE= TEST_REPO= RUNNER_MIN_REPLICAS=${ORG_RUNNER_MIN_REPLICAS} NAME=org-runnerdeploy envsubst | kubectl apply -f - + if [ "${USE_RUNNERSET}" != "false" ]; then + cat acceptance/testdata/runnerset.envsubst.yaml | TEST_ENTERPRISE= TEST_REPO= RUNNER_MIN_REPLICAS=${ORG_RUNNER_MIN_REPLICAS} NAME=org-runnerset envsubst | kubectl apply -f - + else + cat acceptance/testdata/runnerdeploy.envsubst.yaml | TEST_ENTERPRISE= TEST_REPO= RUNNER_MIN_REPLICAS=${ORG_RUNNER_MIN_REPLICAS} NAME=org-runnerdeploy envsubst | kubectl apply -f - + fi if [ -n "${TEST_ORG_GROUP}" ]; then - cat acceptance/testdata/runnerdeploy.envsubst.yaml | TEST_ENTERPRISE= TEST_REPO= TEST_GROUP=${TEST_ORG_GROUP} NAME=orggroup-runnerdeploy envsubst | kubectl apply -f - + if [ "${USE_RUNNERSET}" != "false" ]; then + cat acceptance/testdata/runnerset.envsubst.yaml | TEST_ENTERPRISE= TEST_REPO= RUNNER_MIN_REPLICAS=${ORG_RUNNER_MIN_REPLICAS} TEST_GROUP=${TEST_ORG_GROUP} NAME=orgroupg-runnerset envsubst | kubectl apply -f - + else + cat acceptance/testdata/runnerdeploy.envsubst.yaml | TEST_ENTERPRISE= TEST_REPO= RUNNER_MIN_REPLICAS=${ORG_RUNNER_MIN_REPLICAS} TEST_GROUP=${TEST_ORG_GROUP} NAME=orggroup-runnerdeploy envsubst | kubectl apply -f - + fi else echo 'Skipped deploying enterprise runnerdeployment. Set TEST_ORG_GROUP to deploy.' fi @@ -95,10 +102,18 @@ else fi if [ -n "${TEST_ENTERPRISE}" ]; then - cat acceptance/testdata/runnerdeploy.envsubst.yaml | TEST_ORG= TEST_REPO= NAME=enterprise-runnerdeploy envsubst | kubectl apply -f - + if [ "${USE_RUNNERSET}" != "false" ]; then + cat acceptance/testdata/runnerset.envsubst.yaml | TEST_ORG= TEST_REPO= RUNNER_MIN_REPLICAS=${ENTERPRISE_RUNNER_MIN_REPLICAS} NAME=enterprise-runnerset envsubst | kubectl apply -f - + else + cat acceptance/testdata/runnerdeploy.envsubst.yaml | TEST_ORG= TEST_REPO= RUNNER_MIN_REPLICAS=${ENTERPRISE_RUNNER_MIN_REPLICAS} NAME=enterprise-runnerdeploy envsubst | kubectl apply -f - + fi if [ -n "${TEST_ENTERPRISE_GROUP}" ]; then - cat acceptance/testdata/runnerdeploy.envsubst.yaml | TEST_ORG= TEST_REPO= TEST_GROUP=${TEST_ENTERPRISE_GROUP} NAME=enterprisegroup-runnerdeploy envsubst | kubectl apply -f - + if [ "${USE_RUNNERSET}" != "false" ]; then + cat acceptance/testdata/runnerset.envsubst.yaml | TEST_ORG= TEST_REPO= RUNNER_MIN_REPLICAS=${ENTERPRISE_RUNNER_MIN_REPLICAS} TEST_GROUP=${TEST_ENTERPRISE_GROUP} NAME=enterprisegroup-runnerset envsubst | kubectl apply -f - + else + cat acceptance/testdata/runnerdeploy.envsubst.yaml | TEST_ORG= TEST_REPO= RUNNER_MIN_REPLICAS=${ENTERPRISE_RUNNER_MIN_REPLICAS} TEST_GROUP=${TEST_ENTERPRISE_GROUP} NAME=enterprisegroup-runnerdeploy envsubst | kubectl apply -f - + fi else echo 'Skipped deploying enterprise runnerdeployment. Set TEST_ENTERPRISE_GROUP to deploy.' fi diff --git a/acceptance/testdata/repo.runnerset.yaml b/acceptance/testdata/runnerset.envsubst.yaml similarity index 71% rename from acceptance/testdata/repo.runnerset.yaml rename to acceptance/testdata/runnerset.envsubst.yaml index d9ae68de..cf39378f 100644 --- a/acceptance/testdata/repo.runnerset.yaml +++ b/acceptance/testdata/runnerset.envsubst.yaml @@ -1,17 +1,17 @@ apiVersion: actions.summerwind.dev/v1alpha1 kind: RunnerSet metadata: - name: example-runnerset + name: ${NAME} spec: # MANDATORY because it is based on StatefulSet: Results in a below error when omitted: # missing required field "selector" in dev.summerwind.actions.v1alpha1.RunnerSet.spec selector: matchLabels: - app: example-runnerset + app: ${NAME} # MANDATORY because it is based on StatefulSet: Results in a below error when omitted: # missing required field "serviceName" in dev.summerwind.actions.v1alpha1.RunnerSet.spec] - serviceName: example-runnerset + serviceName: ${NAME} #replicas: 1 @@ -20,16 +20,23 @@ spec: # result in queued jobs hanging forever. ephemeral: ${TEST_EPHEMERAL} + enterprise: ${TEST_ENTERPRISE} + group: ${TEST_GROUP} + organization: ${TEST_ORG} repository: ${TEST_REPO} + # # Custom runner image # image: ${RUNNER_NAME}:${RUNNER_TAG} + # # dockerd within runner container # ## Replace `mumoshu/actions-runner-dind:dev` with your dind image #dockerdWithinRunnerContainer: true + dockerdWithinRunnerContainer: ${RUNNER_DOCKERD_WITHIN_RUNNER_CONTAINER} + # # Set the MTU used by dockerd-managed network interfaces (including docker-build-ubuntu) # @@ -47,7 +54,7 @@ spec: template: metadata: labels: - app: example-runnerset + app: ${NAME} spec: containers: - name: runner @@ -57,3 +64,19 @@ spec: value: "${RUNNER_FEATURE_FLAG_EPHEMERAL}" #- name: docker # #image: mumoshu/actions-runner-dind:dev +--- +apiVersion: actions.summerwind.dev/v1alpha1 +kind: HorizontalRunnerAutoscaler +metadata: + name: ${NAME} +spec: + scaleTargetRef: + kind: RunnerSet + name: ${NAME} + scaleUpTriggers: + - githubEvent: {} + amount: 1 + duration: "10m" + minReplicas: ${RUNNER_MIN_REPLICAS} + maxReplicas: 10 + scaleDownDelaySecondsAfterScaleOut: ${RUNNER_SCALE_DOWN_DELAY_SECONDS_AFTER_SCALE_OUT} diff --git a/test/e2e/e2e_test.go b/test/e2e/e2e_test.go index 728ba4ff..57e6aa71 100644 --- a/test/e2e/e2e_test.go +++ b/test/e2e/e2e_test.go @@ -277,7 +277,9 @@ func (e *env) installActionsRunnerController(t *testing.T) { "TEST_ID=" + e.testID, fmt.Sprintf("RUNNER_FEATURE_FLAG_EPHEMERAL=%v", e.featureFlagEphemeral), fmt.Sprintf("RUNNER_SCALE_DOWN_DELAY_SECONDS_AFTER_SCALE_OUT=%d", e.scaleDownDelaySecondsAfterScaleOut), + fmt.Sprintf("REPO_RUNNER_MIN_REPLICAS=%d", e.minReplicas), fmt.Sprintf("ORG_RUNNER_MIN_REPLICAS=%d", e.minReplicas), + fmt.Sprintf("ENTERPRISE_RUNNER_MIN_REPLICAS=%d", e.minReplicas), } if e.dockerdWithinRunnerContainer {