Skip to content

Commit 569da5e

Browse files
Fix flakey test by disabling EC2 metadata lookup in test case (#1005)
## Summary - Disable EC2 IMDS lookups inside `TestCreateWorkerDeploymentVersion_Errors`. - Keep the fake AWS Lambda validation failure deterministic and local. ## Root Cause The test intentionally passes fake AWS Lambda and assume-role inputs. Server-side worker-deployment validation uses `go.temporal.io/auto-scaled-workers`, which imports the AWS SDK and validates the `aws-lambda` compute provider. That path builds default AWS config and calls STS/Lambda validation. Before STS can assume the fake role, the AWS SDK needs base credentials. In a local or CI environment with no AWS env creds/profile/container creds, the AWS SDK falls back to EC2 Instance Metadata Service. Outside EC2, that means waiting on IMDS/network retries even though the test only wants an expected validation failure. ## Scope of the Fix This is broader AWS SDK behavior: `AWS_EC2_METADATA_DISABLED=true` is useful for any test/process that invokes AWS SDK default credential resolution without real credentials and should not hit EC2 IMDS. In this CLI test suite, the enabled surface is narrow: - `TestCreateWorkerDeploymentVersion_Errors` is the only enabled test that passes a complete fake AWS Lambda compute config to the server. - The later missing-field subcases in that same test fail in CLI-side validation before server-side AWS validation. - `TestCreateWorkerDeploymentVersion_LambdaComputeConfig` would also hit the AWS path, but it is skipped because it needs real AWS fixtures. So the fix is intentionally test-local rather than package-wide, to avoid changing behavior for future tests that might intentionally exercise AWS credential resolution. ## Validation - `go test -mod=readonly ./internal/temporalcli -run 'TestSharedServerSuite/TestCreateWorkerDeploymentVersion_Errors' -count=1 -v` Co-authored-by: Alex Stanfield <13949480+chaptersix@users.noreply.github.com>
1 parent 1a064e5 commit 569da5e

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

internal/temporalcli/commands.worker.deployment_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,6 +1199,10 @@ func (s *SharedServerSuite) TestCreateWorkerDeploymentVersion_EmptyComputeConfig
11991199
}
12001200

12011201
func (s *SharedServerSuite) TestCreateWorkerDeploymentVersion_Errors() {
1202+
// Keep the fake AWS validation case local; otherwise the SDK tries EC2 IMDS
1203+
// during credential resolution and waits on network retries.
1204+
s.T().Setenv("AWS_EC2_METADATA_DISABLED", "true")
1205+
12021206
deploymentName := uuid.NewString()
12031207
taskQueue := uuid.NewString()
12041208

0 commit comments

Comments
 (0)