acceptance: Improve deploy.sh to recreate ARC (not runner) pods on new test id
So that one does not need to manually recreate ARC pods frequently.
This commit is contained in:
		
							parent
							
								
									4b557dc54c
								
							
						
					
					
						commit
						f3ceccd904
					
				|  | @ -37,7 +37,10 @@ fi | ||||||
| 
 | 
 | ||||||
| tool=${ACCEPTANCE_TEST_DEPLOYMENT_TOOL} | tool=${ACCEPTANCE_TEST_DEPLOYMENT_TOOL} | ||||||
| 
 | 
 | ||||||
|  | TEST_ID=${TEST_ID:-default} | ||||||
|  | 
 | ||||||
| if [ "${tool}" == "helm" ]; then | if [ "${tool}" == "helm" ]; then | ||||||
|  |   set -v | ||||||
|   helm upgrade --install actions-runner-controller \ |   helm upgrade --install actions-runner-controller \ | ||||||
|     charts/actions-runner-controller \ |     charts/actions-runner-controller \ | ||||||
|     -n actions-runner-system \ |     -n actions-runner-system \ | ||||||
|  | @ -46,7 +49,10 @@ if [ "${tool}" == "helm" ]; then | ||||||
|     --set authSecret.create=false \ |     --set authSecret.create=false \ | ||||||
|     --set image.repository=${NAME} \ |     --set image.repository=${NAME} \ | ||||||
|     --set image.tag=${VERSION} \ |     --set image.tag=${VERSION} \ | ||||||
|  |     --set podAnnotations.test-id=${TEST_ID} \ | ||||||
|  |     --set githubWebhookServer.podAnnotations.test-id=${TEST_ID} \ | ||||||
|     -f ${VALUES_FILE} |     -f ${VALUES_FILE} | ||||||
|  |   set +v | ||||||
|   # To prevent `CustomResourceDefinition.apiextensions.k8s.io "runners.actions.summerwind.dev" is invalid: metadata.annotations: Too long: must have at most 262144 bytes` |   # To prevent `CustomResourceDefinition.apiextensions.k8s.io "runners.actions.summerwind.dev" is invalid: metadata.annotations: Too long: must have at most 262144 bytes` | ||||||
|   # errors |   # errors | ||||||
|   kubectl create -f charts/actions-runner-controller/crds || kubectl replace -f charts/actions-runner-controller/crds |   kubectl create -f charts/actions-runner-controller/crds || kubectl replace -f charts/actions-runner-controller/crds | ||||||
|  |  | ||||||
|  | @ -167,6 +167,7 @@ type env struct { | ||||||
| 	useRunnerSet bool | 	useRunnerSet bool | ||||||
| 
 | 
 | ||||||
| 	testID                                                   string | 	testID                                                   string | ||||||
|  | 	testName                                                 string | ||||||
| 	repoToCommit                                             string | 	repoToCommit                                             string | ||||||
| 	runnerLabel, githubToken, testRepo, testOrg, testOrgRepo string | 	runnerLabel, githubToken, testRepo, testOrg, testOrgRepo string | ||||||
| 	githubTokenWebhook                                       string | 	githubTokenWebhook                                       string | ||||||
|  | @ -184,11 +185,12 @@ func initTestEnv(t *testing.T) *env { | ||||||
| 
 | 
 | ||||||
| 	id := e.ID() | 	id := e.ID() | ||||||
| 
 | 
 | ||||||
| 	testID := t.Name() + " " + id | 	testName := t.Name() + " " + id | ||||||
| 
 | 
 | ||||||
| 	t.Logf("Using test id %s", testID) | 	t.Logf("Initializing test with name %s", testName) | ||||||
| 
 | 
 | ||||||
| 	e.testID = testID | 	e.testID = id | ||||||
|  | 	e.testName = testName | ||||||
| 	e.runnerLabel = "test-" + id | 	e.runnerLabel = "test-" + id | ||||||
| 	e.githubToken = testing.Getenv(t, "GITHUB_TOKEN") | 	e.githubToken = testing.Getenv(t, "GITHUB_TOKEN") | ||||||
| 	e.githubTokenWebhook = testing.Getenv(t, "WEBHOOK_GITHUB_TOKEN") | 	e.githubTokenWebhook = testing.Getenv(t, "WEBHOOK_GITHUB_TOKEN") | ||||||
|  | @ -197,7 +199,7 @@ func initTestEnv(t *testing.T) *env { | ||||||
| 	e.testOrg = testing.Getenv(t, "TEST_ORG", "") | 	e.testOrg = testing.Getenv(t, "TEST_ORG", "") | ||||||
| 	e.testOrgRepo = testing.Getenv(t, "TEST_ORG_REPO", "") | 	e.testOrgRepo = testing.Getenv(t, "TEST_ORG_REPO", "") | ||||||
| 	e.testEnterprise = testing.Getenv(t, "TEST_ENTERPRISE") | 	e.testEnterprise = testing.Getenv(t, "TEST_ENTERPRISE") | ||||||
| 	e.testJobs = createTestJobs(id, testResultCMNamePrefix, 10) | 	e.testJobs = createTestJobs(id, testResultCMNamePrefix, 100) | ||||||
| 	ephemeral, _ := strconv.ParseBool(testing.Getenv(t, "TEST_FEATURE_FLAG_EPHEMERAL")) | 	ephemeral, _ := strconv.ParseBool(testing.Getenv(t, "TEST_FEATURE_FLAG_EPHEMERAL")) | ||||||
| 	e.featureFlagEphemeral = ephemeral | 	e.featureFlagEphemeral = ephemeral | ||||||
| 
 | 
 | ||||||
|  | @ -254,6 +256,7 @@ func (e *env) installActionsRunnerController(t *testing.T) { | ||||||
| 		"GITHUB_TOKEN=" + e.githubToken, | 		"GITHUB_TOKEN=" + e.githubToken, | ||||||
| 		"WEBHOOK_GITHUB_TOKEN=" + e.githubTokenWebhook, | 		"WEBHOOK_GITHUB_TOKEN=" + e.githubTokenWebhook, | ||||||
| 		"RUNNER_LABEL=" + e.runnerLabel, | 		"RUNNER_LABEL=" + e.runnerLabel, | ||||||
|  | 		"TEST_ID=" + e.testID, | ||||||
| 		fmt.Sprintf("RUNNER_FEATURE_FLAG_EPHEMERAL=%v", e.featureFlagEphemeral), | 		fmt.Sprintf("RUNNER_FEATURE_FLAG_EPHEMERAL=%v", e.featureFlagEphemeral), | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | @ -273,7 +276,7 @@ func (e *env) createControllerNamespaceAndServiceAccount(t *testing.T) { | ||||||
| func (e *env) installActionsWorkflow(t *testing.T) { | func (e *env) installActionsWorkflow(t *testing.T) { | ||||||
| 	t.Helper() | 	t.Helper() | ||||||
| 
 | 
 | ||||||
| 	installActionsWorkflow(t, e.testID, e.runnerLabel, testResultCMNamePrefix, e.repoToCommit, e.testJobs) | 	installActionsWorkflow(t, e.testName, e.runnerLabel, testResultCMNamePrefix, e.repoToCommit, e.testJobs) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (e *env) verifyActionsWorkflowRun(t *testing.T) { | func (e *env) verifyActionsWorkflowRun(t *testing.T) { | ||||||
|  | @ -302,13 +305,13 @@ func createTestJobs(id, testResultCMNamePrefix string, numJobs int) []job { | ||||||
| 
 | 
 | ||||||
| const Branch = "main" | const Branch = "main" | ||||||
| 
 | 
 | ||||||
| func installActionsWorkflow(t *testing.T, testID, runnerLabel, testResultCMNamePrefix, testRepo string, testJobs []job) { | func installActionsWorkflow(t *testing.T, testName, runnerLabel, testResultCMNamePrefix, testRepo string, testJobs []job) { | ||||||
| 	t.Helper() | 	t.Helper() | ||||||
| 
 | 
 | ||||||
| 	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) | 	ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) | ||||||
| 	defer cancel() | 	defer cancel() | ||||||
| 
 | 
 | ||||||
| 	wfName := "E2E " + testID | 	wfName := "E2E " + testName | ||||||
| 	wf := testing.Workflow{ | 	wf := testing.Workflow{ | ||||||
| 		Name: wfName, | 		Name: wfName, | ||||||
| 		On: testing.On{ | 		On: testing.On{ | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue