Skip to content

Commit c3ea3a0

Browse files
oliviassssTimothy-Dougherty
authored andcommitted
add test coverage for endPointSlices (kubernetes-sigs#3119)
1 parent 952238c commit c3ea3a0

File tree

3 files changed

+58
-4
lines changed

3 files changed

+58
-4
lines changed

test/e2e/ingress/multi_path_backend_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ var _ = Describe("test ingresses with multiple path and backends", func() {
2424

2525
if tf.Options.ControllerImage != "" {
2626
By(fmt.Sprintf("ensure cluster installed with controller: %s", tf.Options.ControllerImage), func() {
27-
err := tf.CTRLInstallationManager.UpgradeController(tf.Options.ControllerImage)
27+
err := tf.CTRLInstallationManager.UpgradeController(tf.Options.ControllerImage, false)
2828
Expect(err).NotTo(HaveOccurred())
2929
time.Sleep(60 * time.Second)
3030
})

test/e2e/ingress/vanilla_ingress_test.go

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ var _ = Describe("vanilla ingress tests", func() {
3535
ctx = context.Background()
3636
if tf.Options.ControllerImage != "" {
3737
By(fmt.Sprintf("ensure cluster installed with controller: %s", tf.Options.ControllerImage), func() {
38-
err := tf.CTRLInstallationManager.UpgradeController(tf.Options.ControllerImage)
38+
err := tf.CTRLInstallationManager.UpgradeController(tf.Options.ControllerImage, false)
3939
Expect(err).NotTo(HaveOccurred())
4040
time.Sleep(60 * time.Second)
4141
})
@@ -346,6 +346,57 @@ var _ = Describe("vanilla ingress tests", func() {
346346
})
347347
})
348348

349+
Context("with ALB IP targets, named target port and endPointSlices enabled", func() {
350+
BeforeEach(func() {
351+
ctx = context.Background()
352+
if tf.Options.ControllerImage != "" {
353+
By(fmt.Sprintf("upgrade controller with endPointSlices enabled."), func() {
354+
err := tf.CTRLInstallationManager.UpgradeController(tf.Options.ControllerImage, true)
355+
Expect(err).NotTo(HaveOccurred())
356+
time.Sleep(60 * time.Second)
357+
})
358+
}
359+
})
360+
It("with 'alb.ingress.kubernetes.io/target-type' annotation explicitly specified, and endPointSlices enabled, one ALB shall be created and functional", func() {
361+
appBuilder := manifest.NewFixedResponseServiceBuilder().WithTargetPortName("e2e-targetport")
362+
ingBuilder := manifest.NewIngressBuilder()
363+
dp, svc := appBuilder.Build(sandboxNS.Name, "app")
364+
ingBackend := networking.IngressBackend{
365+
Service: &networking.IngressServiceBackend{
366+
Name: svc.Name,
367+
Port: networking.ServiceBackendPort{
368+
Number: 80,
369+
},
370+
},
371+
}
372+
annotation := map[string]string{
373+
"kubernetes.io/ingress.class": "alb",
374+
"alb.ingress.kubernetes.io/scheme": "internet-facing",
375+
"alb.ingress.kubernetes.io/target-type": "ip",
376+
}
377+
if tf.Options.IPFamily == "IPv6" {
378+
annotation["alb.ingress.kubernetes.io/ip-address-type"] = "dualstack"
379+
}
380+
ing := ingBuilder.
381+
AddHTTPRoute("", networking.HTTPIngressPath{Path: "/path", PathType: &exact, Backend: ingBackend}).
382+
WithAnnotations(annotation).Build(sandboxNS.Name, "ing")
383+
resStack := fixture.NewK8SResourceStack(tf, dp, svc, ing)
384+
err := resStack.Setup(ctx)
385+
Expect(err).NotTo(HaveOccurred())
386+
387+
defer resStack.TearDown(ctx)
388+
389+
lbARN, lbDNS := ExpectOneLBProvisionedForIngress(ctx, tf, ing)
390+
391+
// test traffic
392+
ExpectLBDNSBeAvailable(ctx, tf, lbARN, lbDNS)
393+
httpExp := httpexpect.New(tf.LoggerReporter, fmt.Sprintf("http://%v", lbDNS))
394+
httpExp.GET("/path").Expect().
395+
Status(http.StatusOK).
396+
Body().Equal("Hello World!")
397+
})
398+
})
399+
349400
Context("with `alb.ingress.kubernetes.io/actions.${action-name}` variant settings", func() {
350401
It("with annotation based actions, one ALB shall be created and functional", func() {
351402
appBuilder := manifest.NewFixedResponseServiceBuilder()

test/framework/controller/installation_manager.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
// InstallationManager is responsible for manage controller installation in cluster.
1313
type InstallationManager interface {
1414
ResetController() error
15-
UpgradeController(controllerImage string) error
15+
UpgradeController(controllerImage string, enableEndPointSlices bool) error
1616
}
1717

1818
// NewDefaultInstallationManager constructs new defaultInstallationManager.
@@ -53,7 +53,7 @@ func (m *defaultInstallationManager) ResetController() error {
5353
return err
5454
}
5555

56-
func (m *defaultInstallationManager) UpgradeController(controllerImage string) error {
56+
func (m *defaultInstallationManager) UpgradeController(controllerImage string, enableEndPointSlices bool) error {
5757
imageRepo, imageTag, err := splitImageRepoAndTag(controllerImage)
5858
if err != nil {
5959
return err
@@ -66,6 +66,9 @@ func (m *defaultInstallationManager) UpgradeController(controllerImage string) e
6666
vals["podLabels"] = map[string]string{
6767
"revision": string(uuid.NewUUID()),
6868
}
69+
if enableEndPointSlices {
70+
vals["enableEndpointSlices"] = true
71+
}
6972
_, err = m.helmReleaseManager.InstallOrUpgradeRelease(m.helmChart,
7073
m.namespace, AWSLoadBalancerControllerHelmRelease, vals,
7174
helm.WithTimeout(AWSLoadBalancerControllerInstallationTimeout))

0 commit comments

Comments
 (0)