Skip to content

add test coverage for endPointSlices #3119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/e2e/ingress/multi_path_backend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var _ = Describe("test ingresses with multiple path and backends", func() {

if tf.Options.ControllerImage != "" {
By(fmt.Sprintf("ensure cluster installed with controller: %s", tf.Options.ControllerImage), func() {
err := tf.CTRLInstallationManager.UpgradeController(tf.Options.ControllerImage)
err := tf.CTRLInstallationManager.UpgradeController(tf.Options.ControllerImage, false)
Expect(err).NotTo(HaveOccurred())
time.Sleep(60 * time.Second)
})
Expand Down
53 changes: 52 additions & 1 deletion test/e2e/ingress/vanilla_ingress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var _ = Describe("vanilla ingress tests", func() {
ctx = context.Background()
if tf.Options.ControllerImage != "" {
By(fmt.Sprintf("ensure cluster installed with controller: %s", tf.Options.ControllerImage), func() {
err := tf.CTRLInstallationManager.UpgradeController(tf.Options.ControllerImage)
err := tf.CTRLInstallationManager.UpgradeController(tf.Options.ControllerImage, false)
Expect(err).NotTo(HaveOccurred())
time.Sleep(60 * time.Second)
})
Expand Down Expand Up @@ -346,6 +346,57 @@ var _ = Describe("vanilla ingress tests", func() {
})
})

Context("with ALB IP targets, named target port and endPointSlices enabled", func() {
BeforeEach(func() {
ctx = context.Background()
if tf.Options.ControllerImage != "" {
By(fmt.Sprintf("upgrade controller with endPointSlices enabled."), func() {
err := tf.CTRLInstallationManager.UpgradeController(tf.Options.ControllerImage, true)
Expect(err).NotTo(HaveOccurred())
time.Sleep(60 * time.Second)
})
}
})
It("with 'alb.ingress.kubernetes.io/target-type' annotation explicitly specified, and endPointSlices enabled, one ALB shall be created and functional", func() {
appBuilder := manifest.NewFixedResponseServiceBuilder().WithTargetPortName("e2e-targetport")
ingBuilder := manifest.NewIngressBuilder()
dp, svc := appBuilder.Build(sandboxNS.Name, "app")
ingBackend := networking.IngressBackend{
Service: &networking.IngressServiceBackend{
Name: svc.Name,
Port: networking.ServiceBackendPort{
Number: 80,
},
},
}
annotation := map[string]string{
"kubernetes.io/ingress.class": "alb",
"alb.ingress.kubernetes.io/scheme": "internet-facing",
"alb.ingress.kubernetes.io/target-type": "ip",
}
if tf.Options.IPFamily == "IPv6" {
annotation["alb.ingress.kubernetes.io/ip-address-type"] = "dualstack"
}
ing := ingBuilder.
AddHTTPRoute("", networking.HTTPIngressPath{Path: "/path", PathType: &exact, Backend: ingBackend}).
WithAnnotations(annotation).Build(sandboxNS.Name, "ing")
resStack := fixture.NewK8SResourceStack(tf, dp, svc, ing)
err := resStack.Setup(ctx)
Expect(err).NotTo(HaveOccurred())

defer resStack.TearDown(ctx)

lbARN, lbDNS := ExpectOneLBProvisionedForIngress(ctx, tf, ing)

// test traffic
ExpectLBDNSBeAvailable(ctx, tf, lbARN, lbDNS)
httpExp := httpexpect.New(tf.LoggerReporter, fmt.Sprintf("http://%v", lbDNS))
httpExp.GET("/path").Expect().
Status(http.StatusOK).
Body().Equal("Hello World!")
})
})

Context("with `alb.ingress.kubernetes.io/actions.${action-name}` variant settings", func() {
It("with annotation based actions, one ALB shall be created and functional", func() {
appBuilder := manifest.NewFixedResponseServiceBuilder()
Expand Down
7 changes: 5 additions & 2 deletions test/framework/controller/installation_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
// InstallationManager is responsible for manage controller installation in cluster.
type InstallationManager interface {
ResetController() error
UpgradeController(controllerImage string) error
UpgradeController(controllerImage string, enableEndPointSlices bool) error
}

// NewDefaultInstallationManager constructs new defaultInstallationManager.
Expand Down Expand Up @@ -53,7 +53,7 @@ func (m *defaultInstallationManager) ResetController() error {
return err
}

func (m *defaultInstallationManager) UpgradeController(controllerImage string) error {
func (m *defaultInstallationManager) UpgradeController(controllerImage string, enableEndPointSlices bool) error {
imageRepo, imageTag, err := splitImageRepoAndTag(controllerImage)
if err != nil {
return err
Expand All @@ -66,6 +66,9 @@ func (m *defaultInstallationManager) UpgradeController(controllerImage string) e
vals["podLabels"] = map[string]string{
"revision": string(uuid.NewUUID()),
}
if enableEndPointSlices {
vals["enableEndpointSlices"] = true
}
_, err = m.helmReleaseManager.InstallOrUpgradeRelease(m.helmChart,
m.namespace, AWSLoadBalancerControllerHelmRelease, vals,
helm.WithTimeout(AWSLoadBalancerControllerInstallationTimeout))
Expand Down