Skip to content

Commit 50fc9ea

Browse files
committed
Add basic aga controller e2e tests
1 parent ab38764 commit 50fc9ea

25 files changed

+2089
-91
lines changed

test/e2e/gateway/alb_instance_target_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ var _ = Describe("test k8s alb gateway using instance targets reconciled by the
7272
},
7373
}
7474
auxiliaryStack = newAuxiliaryResourceStack(ctx, tf, tgSpec, true)
75-
httpr := buildHTTPRoute([]string{}, []gwv1.HTTPRouteRule{}, &gwListeners[0].Name)
75+
httpr := BuildHTTPRoute([]string{}, []gwv1.HTTPRouteRule{}, &gwListeners[0].Name)
7676
By("deploying stack", func() {
7777
err := stack.DeployHTTP(ctx, auxiliaryStack, tf, gwListeners, []*gwv1.HTTPRoute{httpr}, lbcSpec, tgSpec, lrcSpec, nil, true)
7878
Expect(err).NotTo(HaveOccurred())
@@ -228,7 +228,7 @@ var _ = Describe("test k8s alb gateway using instance targets reconciled by the
228228
Protocol: gwv1.HTTPProtocolType,
229229
},
230230
}
231-
httpr := buildHTTPRoute([]string{}, httpRouteRuleWithMatchesAndTargetGroupWeights, nil)
231+
httpr := BuildHTTPRoute([]string{}, httpRouteRuleWithMatchesAndTargetGroupWeights, nil)
232232

233233
By("deploying stack", func() {
234234
err := stack.DeployHTTP(ctx, nil, tf, gwListeners, []*gwv1.HTTPRoute{httpr}, lbcSpec, tgSpec, lrcSpec, nil, true)
@@ -438,7 +438,7 @@ var _ = Describe("test k8s alb gateway using instance targets reconciled by the
438438
Protocol: gwv1.HTTPProtocolType,
439439
},
440440
}
441-
httpr := buildHTTPRoute([]string{}, httpRouteRuleWithMatchesAndFilters, nil)
441+
httpr := BuildHTTPRoute([]string{}, httpRouteRuleWithMatchesAndFilters, nil)
442442

443443
By("deploying stack", func() {
444444
err := stack.DeployHTTP(ctx, nil, tf, gwListeners, []*gwv1.HTTPRoute{httpr}, lbcSpec, tgSpec, lrcSpec, nil, true)
@@ -518,7 +518,7 @@ var _ = Describe("test k8s alb gateway using instance targets reconciled by the
518518
},
519519
}
520520

521-
httpr := buildHTTPRoute([]string{}, httpRouteRuleWithMultiMatchesInSingleRule, nil)
521+
httpr := BuildHTTPRoute([]string{}, httpRouteRuleWithMultiMatchesInSingleRule, nil)
522522

523523
By("deploying stack", func() {
524524
err := stack.DeployHTTP(ctx, nil, tf, gwListeners, []*gwv1.HTTPRoute{httpr}, lbcSpec, tgSpec, lrcSpec, nil, true)
@@ -716,7 +716,7 @@ var _ = Describe("test k8s alb gateway using instance targets reconciled by the
716716
Hostname: (*gwv1.Hostname)(awssdk.String(testHostname)),
717717
},
718718
}
719-
httpr := buildHTTPRoute([]string{testHostname}, []gwv1.HTTPRouteRule{}, nil)
719+
httpr := BuildHTTPRoute([]string{testHostname}, []gwv1.HTTPRouteRule{}, nil)
720720
By("deploying stack", func() {
721721
err := stack.DeployHTTP(ctx, nil, tf, gwListeners, []*gwv1.HTTPRoute{httpr}, lbcSpec, tgSpec, lrcSpec, nil, true)
722722
Expect(err).NotTo(HaveOccurred())
@@ -821,7 +821,7 @@ var _ = Describe("test k8s alb gateway using instance targets reconciled by the
821821
Hostname: (*gwv1.Hostname)(awssdk.String(testHostname)),
822822
},
823823
}
824-
httpr := buildHTTPRoute([]string{testHostname}, []gwv1.HTTPRouteRule{}, nil)
824+
httpr := BuildHTTPRoute([]string{testHostname}, []gwv1.HTTPRouteRule{}, nil)
825825
By("deploying stack", func() {
826826
err := stack.DeployHTTP(ctx, nil, tf, gwListeners, []*gwv1.HTTPRoute{httpr}, lbcSpec, tgSpec, lrcSpec, nil, true)
827827
Expect(err).NotTo(HaveOccurred())
@@ -966,7 +966,7 @@ var _ = Describe("test k8s alb gateway using instance targets reconciled by the
966966
},
967967
},
968968
}
969-
httpr := buildHTTPRoute([]string{testHostname}, httpRouteRules, &gwListeners[0].Name)
969+
httpr := BuildHTTPRoute([]string{testHostname}, httpRouteRules, &gwListeners[0].Name)
970970

971971
By("deploying stack", func() {
972972
err := stack.DeployHTTP(ctx, nil, tf, gwListeners, []*gwv1.HTTPRoute{httpr}, lbcSpec, tgSpec, lrcSpec, nil, false)
@@ -1173,7 +1173,7 @@ var _ = Describe("test k8s alb gateway using instance targets reconciled by the
11731173
},
11741174
},
11751175
}
1176-
httpr := buildHTTPRoute([]string{testHostname}, httpRouteRules, &gwListeners[0].Name)
1176+
httpr := BuildHTTPRoute([]string{testHostname}, httpRouteRules, &gwListeners[0].Name)
11771177

11781178
By("deploying stack", func() {
11791179
err := stack.DeployHTTP(ctx, nil, tf, gwListeners, []*gwv1.HTTPRoute{httpr}, lbcSpec, tgSpec, lrcSpec, oidcSecret, false)
@@ -1344,7 +1344,7 @@ var _ = Describe("test k8s alb gateway using instance targets reconciled by the
13441344
Hostname: (*gwv1.Hostname)(awssdk.String(testHostname)),
13451345
},
13461346
}
1347-
httpr := buildHTTPRoute([]string{testHostname}, []gwv1.HTTPRouteRule{}, nil)
1347+
httpr := BuildHTTPRoute([]string{testHostname}, []gwv1.HTTPRouteRule{}, nil)
13481348

13491349
By("deploying stack", func() {
13501350
err := stack.DeployHTTP(ctx, nil, tf, gwListeners, []*gwv1.HTTPRoute{httpr}, lbcSpec, tgSpec, lrcSpec, nil, true)

test/e2e/gateway/alb_ip_target_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ var _ = Describe("test k8s alb gateway using ip targets reconciled by the aws lo
7272
},
7373
}
7474
auxiliaryStack = newAuxiliaryResourceStack(ctx, tf, tgSpec, true)
75-
httpr := buildHTTPRoute([]string{}, []gwv1.HTTPRouteRule{}, &gwListeners[0].Name)
75+
httpr := BuildHTTPRoute([]string{}, []gwv1.HTTPRouteRule{}, &gwListeners[0].Name)
7676
By("deploying stack", func() {
7777
err := stack.DeployHTTP(ctx, auxiliaryStack, tf, gwListeners, []*gwv1.HTTPRoute{httpr}, lbcSpec, tgSpec, lrcSpec, nil, true)
7878
Expect(err).NotTo(HaveOccurred())
@@ -217,7 +217,7 @@ var _ = Describe("test k8s alb gateway using ip targets reconciled by the aws lo
217217
},
218218
}
219219

220-
httpr := buildHTTPRoute([]string{}, httpRouteRuleWithMatchesAndTargetGroupWeights, nil)
220+
httpr := BuildHTTPRoute([]string{}, httpRouteRuleWithMatchesAndTargetGroupWeights, nil)
221221
By("deploying stack", func() {
222222
err := stack.DeployHTTP(ctx, nil, tf, gwListeners, []*gwv1.HTTPRoute{httpr}, lbcSpec, tgSpec, lrcSpec, nil, true)
223223
Expect(err).NotTo(HaveOccurred())
@@ -424,7 +424,7 @@ var _ = Describe("test k8s alb gateway using ip targets reconciled by the aws lo
424424
Protocol: gwv1.HTTPProtocolType,
425425
},
426426
}
427-
httpr := buildHTTPRoute([]string{}, httpRouteRuleWithMatchesAndFilters, nil)
427+
httpr := BuildHTTPRoute([]string{}, httpRouteRuleWithMatchesAndFilters, nil)
428428

429429
By("deploying stack", func() {
430430
err := stack.DeployHTTP(ctx, nil, tf, gwListeners, []*gwv1.HTTPRoute{httpr}, lbcSpec, tgSpec, lrcSpec, nil, true)
@@ -503,7 +503,7 @@ var _ = Describe("test k8s alb gateway using ip targets reconciled by the aws lo
503503
},
504504
}
505505

506-
httpr := buildHTTPRoute([]string{}, httpRouteRuleWithMultiMatchesInSingleRule, nil)
506+
httpr := BuildHTTPRoute([]string{}, httpRouteRuleWithMultiMatchesInSingleRule, nil)
507507

508508
By("deploying stack", func() {
509509
err := stack.DeployHTTP(ctx, nil, tf, gwListeners, []*gwv1.HTTPRoute{httpr}, lbcSpec, tgSpec, lrcSpec, nil, true)
@@ -687,7 +687,7 @@ var _ = Describe("test k8s alb gateway using ip targets reconciled by the aws lo
687687
}
688688

689689
lrcSpec := elbv2gw.ListenerRuleConfigurationSpec{}
690-
httpr := buildHTTPRoute([]string{}, []gwv1.HTTPRouteRule{}, &gwListeners[0].Name)
690+
httpr := BuildHTTPRoute([]string{}, []gwv1.HTTPRouteRule{}, &gwListeners[0].Name)
691691
httpr.Spec.Rules[0].Filters = []gwv1.HTTPRouteFilter{
692692
{
693693
Type: gwv1.HTTPRouteFilterURLRewrite,
@@ -835,7 +835,7 @@ var _ = Describe("test k8s alb gateway using ip targets reconciled by the aws lo
835835
},
836836
}
837837

838-
httpr := buildHTTPRoute([]string{testHostname}, []gwv1.HTTPRouteRule{}, nil)
838+
httpr := BuildHTTPRoute([]string{testHostname}, []gwv1.HTTPRouteRule{}, nil)
839839

840840
By("deploying stack", func() {
841841
err := stack.DeployHTTP(ctx, nil, tf, gwListeners, []*gwv1.HTTPRoute{httpr}, lbcSpec, tgSpec, lrcSpec, nil, true)
@@ -947,7 +947,7 @@ var _ = Describe("test k8s alb gateway using ip targets reconciled by the aws lo
947947
},
948948
}
949949

950-
httpr := buildHTTPRoute([]string{testHostname}, []gwv1.HTTPRouteRule{}, nil)
950+
httpr := BuildHTTPRoute([]string{testHostname}, []gwv1.HTTPRouteRule{}, nil)
951951

952952
By("deploying stack", func() {
953953
err := stack.DeployHTTP(ctx, nil, tf, gwListeners, []*gwv1.HTTPRoute{httpr}, lbcSpec, tgSpec, lrcSpec, nil, true)
@@ -1099,7 +1099,7 @@ var _ = Describe("test k8s alb gateway using ip targets reconciled by the aws lo
10991099
},
11001100
},
11011101
}
1102-
httpr := buildHTTPRoute([]string{testHostname}, httpRouteRules, nil)
1102+
httpr := BuildHTTPRoute([]string{testHostname}, httpRouteRules, nil)
11031103

11041104
By("deploying stack", func() {
11051105
err := stack.DeployHTTP(ctx, nil, tf, gwListeners, []*gwv1.HTTPRoute{httpr}, lbcSpec, tgSpec, lrcSpec, nil, false)
@@ -1309,7 +1309,7 @@ var _ = Describe("test k8s alb gateway using ip targets reconciled by the aws lo
13091309
},
13101310
},
13111311
}
1312-
httpr := buildHTTPRoute([]string{testHostname}, httpRouteRules, nil)
1312+
httpr := BuildHTTPRoute([]string{testHostname}, httpRouteRules, nil)
13131313

13141314
By("deploying stack", func() {
13151315
err := stack.DeployHTTP(ctx, nil, tf, gwListeners, []*gwv1.HTTPRoute{httpr}, lbcSpec, tgSpec, lrcSpec, oidcSecret, false)
@@ -1478,7 +1478,7 @@ var _ = Describe("test k8s alb gateway using ip targets reconciled by the aws lo
14781478
},
14791479
}
14801480

1481-
httpr := buildHTTPRoute([]string{}, []gwv1.HTTPRouteRule{}, nil)
1481+
httpr := BuildHTTPRoute([]string{}, []gwv1.HTTPRouteRule{}, nil)
14821482

14831483
By("deploying stack", func() {
14841484
err := stack.DeployHTTP(ctx, nil, tf, gwListeners, []*gwv1.HTTPRoute{httpr}, lbcSpec, tgSpec, lrcSpec, nil, true)

test/e2e/gateway/alb_nlb_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@ package gateway
33
import (
44
"context"
55
"fmt"
6+
"strings"
7+
"time"
8+
69
. "github.com/onsi/ginkgo/v2"
710
. "github.com/onsi/gomega"
811
elbv2gw "sigs.k8s.io/aws-load-balancer-controller/apis/gateway/v1beta1"
912
"sigs.k8s.io/aws-load-balancer-controller/test/framework/http"
1013
"sigs.k8s.io/aws-load-balancer-controller/test/framework/verifier"
1114
gwv1 "sigs.k8s.io/gateway-api/apis/v1"
1215
gwbeta1 "sigs.k8s.io/gateway-api/apis/v1beta1"
13-
"strings"
14-
"time"
1516
)
1617

1718
var _ = Describe("test combined ALB and NLB gateways with HTTPRoute and TCPRoute", func() {
@@ -94,7 +95,7 @@ var _ = Describe("test combined ALB and NLB gateways with HTTPRoute and TCPRoute
9495
}
9596

9697
// HTTPRoute for ALB
97-
httpr := buildHTTPRoute([]string{}, []gwv1.HTTPRouteRule{}, nil)
98+
httpr := BuildHTTPRoute([]string{}, []gwv1.HTTPRouteRule{}, nil)
9899

99100
By("deploying ALB stack", func() {
100101
err := albStack.DeployHTTP(ctx, nil, tf, albGwListeners, []*gwv1.HTTPRoute{httpr}, albLbcSpec, tgSpec, lrcSpec, nil, true)

test/e2e/gateway/alb_resource_stack.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package gateway
33
import (
44
"context"
55
"fmt"
6+
67
appsv1 "k8s.io/api/apps/v1"
78
corev1 "k8s.io/api/core/v1"
89
rbac "k8s.io/api/rbac/v1"
@@ -64,9 +65,11 @@ func (s *albResourceStack) Deploy(ctx context.Context, f *framework.Framework) e
6465
})
6566
}
6667

67-
func (s *albResourceStack) Cleanup(ctx context.Context, f *framework.Framework) {
68-
s.commonStack.Cleanup(ctx, f)
69-
s.deleteOIDCSecretWithRBAC(ctx, f)
68+
func (s *albResourceStack) Cleanup(ctx context.Context, f *framework.Framework) error {
69+
if err := s.commonStack.Cleanup(ctx, f); err != nil {
70+
return err
71+
}
72+
return s.deleteOIDCSecretWithRBAC(ctx, f)
7073
}
7174

7275
func (s *albResourceStack) GetLoadBalancerIngressHostname() string {
@@ -77,6 +80,10 @@ func (s *albResourceStack) getListenersPortMap() map[string]string {
7780
return s.commonStack.getListenersPortMap()
7881
}
7982

83+
func (s *albResourceStack) GetNamespace() string {
84+
return s.commonStack.ns.Name
85+
}
86+
8087
func (s *albResourceStack) waitUntilDeploymentReady(ctx context.Context, f *framework.Framework) error {
8188
return waitUntilDeploymentReady(ctx, f, s.commonStack.dps)
8289
}

test/e2e/gateway/alb_test_helper.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,18 @@ func (s *ALBTestStack) deploy(ctx context.Context, f *framework.Framework, gwLis
7373
return s.albResourceStack.Deploy(ctx, f)
7474
}
7575

76-
func (s *ALBTestStack) Cleanup(ctx context.Context, f *framework.Framework) {
77-
s.albResourceStack.Cleanup(ctx, f)
76+
func (s *ALBTestStack) Cleanup(ctx context.Context, f *framework.Framework) error {
77+
return s.albResourceStack.Cleanup(ctx, f)
7878
}
7979

8080
func (s *ALBTestStack) GetLoadBalancerIngressHostName() string {
8181
return s.albResourceStack.GetLoadBalancerIngressHostname()
8282
}
8383

84+
func (s *ALBTestStack) GetNamespace() string {
85+
return s.albResourceStack.GetNamespace()
86+
}
87+
8488
func (s *ALBTestStack) GetWorkerNodes(ctx context.Context, f *framework.Framework) ([]corev1.Node, error) {
8589
allNodes := &corev1.NodeList{}
8690
err := f.K8sClient.List(ctx, allNodes)

test/e2e/gateway/common_resource_stack.go

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,16 @@ func (s *commonResourceStack) Deploy(ctx context.Context, f *framework.Framework
6666
v.Namespace = s.ns.Name
6767
}
6868

69-
for _, v := range s.tgcs {
70-
v.Namespace = s.ns.Name
69+
if s.tgcs != nil {
70+
for _, v := range s.tgcs {
71+
v.Namespace = s.ns.Name
72+
}
7173
}
7274

73-
for _, v := range s.lrcs {
74-
v.Namespace = s.ns.Name
75+
if s.lrcs != nil {
76+
for _, v := range s.lrcs {
77+
v.Namespace = s.ns.Name
78+
}
7579
}
7680

7781
s.gw.Namespace = s.ns.Name
@@ -120,9 +124,11 @@ func (s *commonResourceStack) Deploy(ctx context.Context, f *framework.Framework
120124
return nil
121125
}
122126

123-
func (s *commonResourceStack) Cleanup(ctx context.Context, f *framework.Framework) {
124-
_ = deleteNamespace(ctx, f, s.ns)
125-
_ = deleteGatewayClass(ctx, f, s.gwc)
127+
func (s *commonResourceStack) Cleanup(ctx context.Context, f *framework.Framework) error {
128+
if err := deleteNamespace(ctx, f, s.ns); err != nil {
129+
return err
130+
}
131+
return deleteGatewayClass(ctx, f, s.gwc)
126132
}
127133

128134
func (s *commonResourceStack) GetLoadBalancerIngressHostname() string {

test/e2e/gateway/nlb_resource_stack.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package gateway
22

33
import (
44
"context"
5+
56
appsv1 "k8s.io/api/apps/v1"
67
corev1 "k8s.io/api/core/v1"
78
elbv2gw "sigs.k8s.io/aws-load-balancer-controller/apis/gateway/v1beta1"
@@ -58,8 +59,8 @@ func (s *nlbResourceStack) Deploy(ctx context.Context, f *framework.Framework) e
5859
})
5960
}
6061

61-
func (s *nlbResourceStack) Cleanup(ctx context.Context, f *framework.Framework) {
62-
s.commonStack.Cleanup(ctx, f)
62+
func (s *nlbResourceStack) Cleanup(ctx context.Context, f *framework.Framework) error {
63+
return s.commonStack.Cleanup(ctx, f)
6364
}
6465

6566
func (s *nlbResourceStack) GetLoadBalancerIngressHostname() string {
@@ -74,6 +75,10 @@ func (s *nlbResourceStack) waitUntilDeploymentReady(ctx context.Context, f *fram
7475
return waitUntilDeploymentReady(ctx, f, s.commonStack.dps)
7576
}
7677

78+
func (s *nlbResourceStack) GetNamespace() string {
79+
return s.commonStack.ns.Name
80+
}
81+
7782
func (s *nlbResourceStack) createTCPRoutes(ctx context.Context, f *framework.Framework) error {
7883
for _, tcpr := range s.tcprs {
7984
f.Logger.Info("creating tcp route", "tcpr", k8s.NamespacedName(tcpr))

test/e2e/gateway/nlb_test_helper.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,14 +316,18 @@ func (s *NLBTestStack) CreateFENLBReferenceGrant(ctx context.Context, f *framewo
316316
return refGrant, nil
317317
}
318318

319-
func (s *NLBTestStack) Cleanup(ctx context.Context, f *framework.Framework) {
320-
s.nlbResourceStack.Cleanup(ctx, f)
319+
func (s *NLBTestStack) Cleanup(ctx context.Context, f *framework.Framework) error {
320+
return s.nlbResourceStack.Cleanup(ctx, f)
321321
}
322322

323323
func (s *NLBTestStack) GetLoadBalancerIngressHostName() string {
324324
return s.nlbResourceStack.GetLoadBalancerIngressHostname()
325325
}
326326

327+
func (s *NLBTestStack) GetNamespace() string {
328+
return s.nlbResourceStack.GetNamespace()
329+
}
330+
327331
func (s *NLBTestStack) GetWorkerNodes(ctx context.Context, f *framework.Framework) ([]corev1.Node, error) {
328332
allNodes := &corev1.NodeList{}
329333
err := f.K8sClient.List(ctx, allNodes)

test/e2e/gateway/shared_resource_definitions.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ func buildUDPRoute(sectionName string) *gwalpha2.UDPRoute {
437437
return udpr
438438
}
439439

440-
func buildHTTPRoute(hostnames []string, rules []gwv1.HTTPRouteRule, sectionName *gwv1.SectionName) *gwv1.HTTPRoute {
440+
func BuildHTTPRoute(hostnames []string, rules []gwv1.HTTPRouteRule, sectionName *gwv1.SectionName) *gwv1.HTTPRoute {
441441
routeName := fmt.Sprintf("%v-%v", defaultName, utils.RandomDNS1123Label(6))
442442
httpr := &gwv1.HTTPRoute{
443443
ObjectMeta: metav1.ObjectMeta{

0 commit comments

Comments
 (0)