Migrate Helm e2e tests to terratest v2 modules - #1356
Merged
Conversation
terratest v1 ships as a single module, and modules/k8s imported modules/aws for one EC2 call, which pulled the entire AWS SDK into our dependency graph: 36 aws-sdk-go-v2 entries in go.mod for code we never call. terratest v2 splits the repo into per-package modules and drops that edge, so depending on k8s no longer drags in the AWS SDK. Switch the Helm e2e test to the v2 modules (k8s, helm, httphelper and core/random) at v2.0.0-beta.2. This is a pre-release, which is acceptable here because terratest is a test-only dependency that never reaches a shipped binary. The v2 API required a few call-site updates: the non-Context function variants are gone, http-helper takes an options struct, and UniqueId was renamed to UniqueID. In the Cleanup deleting the OIDC Secret we pass context.Background(), since t.Context() is canceled just before Cleanup functions run. Also fix a pre-existing bug: the first two arguments to NewKubectlOptions were swapped, so -kubeconfig and -context were wired to the wrong fields. It went unnoticed because both flags default to the empty string. go.sum drops from 470 to 375 lines. Supersedes antrea-io#1290. Signed-off-by: Antonin Bas <antonin.bas@broadcom.com>
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1290, which bumped terratest to v1. This goes further and moves us to the v2 modules instead.
Why
terratest v1 ships as a single Go module, and
modules/k8simportedmodules/awsfor a single EC2 call (resolving EKS node public IPs inGetServiceEndpoint).modules/awsis one flat package covering every AWS service, so importingmodules/k8spulled the whole AWS SDK into our graph:That was 36
aws-sdk-go-v2entries ingo.modfor code we never call.Upstream fixed this: gruntwork-io/terratest#1877 broke the
k8s->awsedge (node addresses now preferExternalIP, so there is no EC2 call and noec2:DescribeInstancespermission needed), and #1881 added CI gating so the edge cannot come back. v2 also splits terratest into 16 per-package modules, so we only pull what we use.Result
aws-sdk-go-v2entries ingo.modgo.sumlinesChanges
k8s/v2,helm/v2,http-helper->httphelper/v2(the package identifier loses its underscore), andrandom->core/v2/random.Contextfunction variants, so thehelmandk8scalls become their…Contextequivalents with an explicitctx.httphelpercollapsed the URL and TLS parameters into anHttpGetOptionsstruct.random.UniqueId->random.UniqueID.k8s.NewKubectlOptionswere swapped. The signature isNewKubectlOptions(contextName, configPath, namespace), but we passed(kubeconfigPath, kubeconfigContext, ...), so-kubeconfigand-contextwere wired to the wrong fields. This is not migration fallout — the signature is identical in v1 and v2. It went unnoticed because both flags default to the empty string.In the
t.Cleanupthat deletes the OIDC Secret I passcontext.Background()rather thant.Context(), becauset.Context()is canceled just beforeCleanupfunctions run and the delete would fail. The plaindeferblocks inside the subtest still run before the test function returns, sot.Context()is valid there.Note on the beta
v2.0.0-beta.2is a pre-release. I think that is acceptable here: terratest is a test-only dependency that never reaches a shipped binary, and the alternative is carrying the AWS SDK until v2 is final. Worth flagging explicitly for review, though — and Renovate will not track these the way it tracked v1.Testing
go build ./...,go vet ./...,go test -c ./test/e2e_helm/and golangci-lint all pass locally. The e2e suite itself needs a live cluster, so I have not run it — relying on CI for that.