Skip to content

WIP/test/e2e: export load balancer helpers#1381

Draft
mtulio wants to merge 11 commits into
kubernetes:masterfrom
mtulio:e2e-lb-export
Draft

WIP/test/e2e: export load balancer helpers#1381
mtulio wants to merge 11 commits into
kubernetes:masterfrom
mtulio:e2e-lb-export

Conversation

@mtulio
Copy link
Copy Markdown
Contributor

@mtulio mtulio commented Apr 14, 2026

What type of PR is this?

/kind cleanup
/kind design
/kind failing-test

What this PR does / why we need it:

This PR introduces exports for e2e library to be extended in test frameworks of layered controllers.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:


@k8s-ci-robot
Copy link
Copy Markdown
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Apr 14, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign kmala for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the needs-kind Indicates a PR lacks a `kind/foo` label and requires one. label Apr 14, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

This issue is currently awaiting triage.

If cloud-provider-aws contributors determine this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Apr 14, 2026
@mtulio
Copy link
Copy Markdown
Contributor Author

mtulio commented Apr 14, 2026

/test pull-cloud-provider-aws-test

@mtulio
Copy link
Copy Markdown
Contributor Author

mtulio commented Apr 14, 2026

/test ?

@mtulio
Copy link
Copy Markdown
Contributor Author

mtulio commented Apr 14, 2026

/test pull-cloud-provider-aws-e2e

@mtulio mtulio changed the title test/e2e: export load balancer helpers WIP/test/e2e: export load balancer helpers Apr 14, 2026
@mtulio mtulio marked this pull request as ready for review April 14, 2026 17:56
@mtulio
Copy link
Copy Markdown
Contributor Author

mtulio commented Apr 14, 2026

Covnerting to reguar PR just to trigger e2e

@k8s-ci-robot k8s-ci-robot requested review from dims and olemarkus April 14, 2026 17:56
@mtulio
Copy link
Copy Markdown
Contributor Author

mtulio commented Apr 14, 2026

/uncc dmis olemarkus

@k8s-ci-robot k8s-ci-robot removed the request for review from olemarkus April 14, 2026 17:56
@mtulio
Copy link
Copy Markdown
Contributor Author

mtulio commented Apr 14, 2026

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 14, 2026
@mtulio mtulio marked this pull request as draft April 14, 2026 21:25
@mtulio
Copy link
Copy Markdown
Contributor Author

mtulio commented Apr 14, 2026

/test pull-cloud-provider-aws-e2e

@mtulio
Copy link
Copy Markdown
Contributor Author

mtulio commented Apr 15, 2026

/test pull-cloud-provider-aws-e2e

@mtulio
Copy link
Copy Markdown
Contributor Author

mtulio commented Apr 15, 2026

Node discovery for hairpinning traffic was failing:

/test pull-cloud-provider-aws-e2e

Comment thread tests/e2e/helper_aws.go Outdated
Comment thread tests/e2e/helper_aws.go
Comment thread tests/e2e/helper_aws.go Outdated
Comment thread tests/e2e/helper_aws.go Outdated
Comment thread tests/e2e/helper_aws.go Outdated
Comment thread tests/e2e/helper_aws.go Outdated
Comment thread tests/e2e/helper_aws.go Outdated
Comment thread tests/e2e/helper_e2e.go Outdated
Comment thread tests/e2e/helper_e2e.go Outdated
Comment thread tests/e2e/helper_e2e.go Outdated
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 21, 2026
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 24, 2026
@mtulio
Copy link
Copy Markdown
Contributor Author

mtulio commented Apr 24, 2026

/test pull-cloud-provider-aws-e2e

@mtulio
Copy link
Copy Markdown
Contributor Author

mtulio commented Apr 27, 2026

Updated the worker node lookup function to get compatibility with existing logic:

/test pull-cloud-provider-aws-e2e

@mtulio
Copy link
Copy Markdown
Contributor Author

mtulio commented Apr 27, 2026

/test pull-cloud-provider-aws-e2e

@mtulio
Copy link
Copy Markdown
Contributor Author

mtulio commented Apr 27, 2026

local tests passing

$ ./e2e.test --ginkgo.v --ginkgo.focus="loadbalancer"
....
• [219.703 seconds]
------------------------------

Ran 5 of 8 Specs in 880.678 seconds
SUCCESS! -- 5 Passed | 0 Failed | 0 Pending | 3 Skipped

/test pull-cloud-provider-aws-e2e

@mtulio
Copy link
Copy Markdown
Contributor Author

mtulio commented Apr 28, 2026

/test ?

@mtulio
Copy link
Copy Markdown
Contributor Author

mtulio commented Apr 28, 2026

/test pull-cloud-provider-aws-e2e-kubetest2
/test pull-cloud-provider-aws-check
/test pull-cloud-provider-aws-test

Comment thread tests/e2e/helper_e2e.go
Comment on lines +141 to +144
func (e *E2ETestHelper) cleanup(ctx context.Context) {
framework.Logf("Cleaning up e2e resources")
// TODO cleanup resources created by the test helper
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this or does it need to be implemented?

Comment thread tests/e2e/loadbalancer.go
}
lbDNS := cfg.svc.Status.LoadBalancer.Ingress[0].Hostname
framework.ExpectNoError(getLBTargetCount(cfg.ctx, lbDNS, cfg.nodeCount), "AWS LB target count validation failed")
// TODO expected lbDNS not empty
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: remove comment or add validation of lbDNS

Comment thread tests/e2e/loadbalancer.go
// Use AWS SDK paginator to search through all load balancers
foundLB, err := getAWSLoadBalancerFromDNSName(e2e.ctx, elbClient, hostAddr)
framework.ExpectNoError(err, "failed to find load balancer with DNS name %s", hostAddr)
foundLB, err := e2e.GetAWSHelper().GetLoadBalancerFromDNSNameWithRetry(ctx, hostAddr)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GetLoadBalancerFromDNSNameWithRetry is marked as deprecated (see comment to the function), if so we should not use it in new code.

Comment thread tests/e2e/helper_e2e.go
Capabilities: &v1.Capabilities{
Drop: []v1.Capability{"ALL"},
},
ReadOnlyRootFilesystem: aws.Bool(true),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I don't particularly like using the AWS SDK helpers (aws.Bool in this case) outside AWS-related blocks of code, it adds unnecessary coupling.

Comment thread tests/e2e/helper_e2e.go
@@ -0,0 +1,883 @@
/*
Copyright 2025 The Kubernetes Authors.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be 2026

Comment thread tests/e2e/helper_aws.go
func (h *E2ETestHelperAWS) GetLBTargets(ctx context.Context, lbDNSName string, listenerPort, targetPort int32) ([]string, error) {
foundLB, err := h.GetLoadBalancerFromDNSNameDefaultTimeout(ctx, lbDNSName)
if err != nil {
return nil, fmt.Errorf("failed to get load balancer from DNS name: %v", err)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit (was already present before): it is good practice to error wrap with %w instead of %v, consider fixing.

Comment thread tests/e2e/helper_aws.go
LoadBalancerArn: aws.String(lbARN),
})
if err != nil {
return nil, fmt.Errorf("failed to describe listeners: %v", err)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit (was already present before): it is good practice to error wrap with %w instead of %v, consider fixing.

Comment thread tests/e2e/helper_aws.go
// MaxAttempts: 5,
// MaxBackoff: 10 * time.Second,
// })
func NewAWSHelperWithOptions(ctx context.Context, opts E2ETestHelperAWSOptions) (*E2ETestHelperAWS, error) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, just an alternative approach to E2ETestHelperAWSOptions:

It is quite common in go to use the "Functional Options" pattern to pass optional configurations, and it might work well here as well. For example instead of having a NewAWSHelperWithOptions and a E2ETestHelperAWS struct, we could have:

type E2ETestHelperAWSOpt func(*E2ETestHelperAWS)

func NewAWSHelper(ctx context.Context, opts ...E2ETestHelperAWSOpt) (*E2ETestHelperAWS, error) {
	h := &E2ETestHelperAWS {}
    for _, optFn := range opts {
       optFn(h)
    }

   // rest of code down here
}

func WithMaxAttempts(attempts int) func(*E2ETestHelperAWS) {
  return func(h *E2ETestHelperAWS) {
    h.MaxAttempts = attempts
  }
}


func WithMaxBackoff(maxBackoff time.Duration) func(*E2ETestHelperAWS) {
  return func(h *E2ETestHelperAWS) {
    h.MaxBackoff = maxBackoff
  }
}

With this pattern you have only 1 constructor and the user can pass only the configurations he wants to edit.
For example to get the default one would do:

h, err := NewAWSHelper(ctx)

And instead to customize only one of the settings would do:

h, err := NewAWSHelper(ctx, WithMaxAttempts(5))

I think this approach is less code and more flexible.

Comment thread tests/e2e/helper_aws.go
Comment on lines +220 to +221
framework.Logf("error getting LB targets (will retry): %v", err)
lastErr = err
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could consider isolating and treating differently retryable vs non-retryable errors here too.

Comment thread tests/e2e/helper_aws.go
opts.ApplyDefaults()

cfg, err := config.LoadDefaultConfig(ctx)
framework.ExpectNoError(err, "unable to load AWS config")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Should we do test assertions inside the helpers (here and in other parts of the PR)? Not a strong opinion, just generally I'd do assertions inside the test function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. needs-kind Indicates a PR lacks a `kind/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants