Skip to content

Commit 91ca3b8

Browse files
authored
Merge pull request #4511 from wweiwei-li/ipv6
Fix IPv6 tests
2 parents 7e3cb8a + a4cc58d commit 91ca3b8

File tree

4 files changed

+85
-57
lines changed

4 files changed

+85
-57
lines changed

test/e2e/globalaccelerator/gateway_endpoint_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
agav1beta1 "sigs.k8s.io/aws-load-balancer-controller/apis/aga/v1beta1"
1111
elbv2gw "sigs.k8s.io/aws-load-balancer-controller/apis/gateway/v1beta1"
1212
"sigs.k8s.io/aws-load-balancer-controller/test/e2e/gateway"
13+
"sigs.k8s.io/aws-load-balancer-controller/test/framework"
1314
"sigs.k8s.io/aws-load-balancer-controller/test/framework/utils"
1415
gwv1 "sigs.k8s.io/gateway-api/apis/v1"
1516
)
@@ -130,6 +131,9 @@ var _ = Describe("GlobalAccelerator with Gateway endpoint", func() {
130131
)
131132

132133
BeforeEach(func() {
134+
if tf.Options.IPFamily == framework.IPv6 {
135+
Skip("Skipping test for IPv6")
136+
}
133137
gwStack = &gateway.NLBTestStack{}
134138
scheme := elbv2gw.LoadBalancerSchemeInternetFacing
135139
err := gwStack.Deploy(ctx, tf, nil, elbv2gw.LoadBalancerConfigurationSpec{Scheme: &scheme}, elbv2gw.TargetGroupConfigurationSpec{}, false)

test/e2e/globalaccelerator/multi_endpoint_test.go

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,21 @@ import (
1212
networkingv1 "k8s.io/api/networking/v1"
1313
agav1beta1 "sigs.k8s.io/aws-load-balancer-controller/apis/aga/v1beta1"
1414
"sigs.k8s.io/aws-load-balancer-controller/test/e2e/ingress"
15-
"sigs.k8s.io/aws-load-balancer-controller/test/e2e/service"
1615
"sigs.k8s.io/aws-load-balancer-controller/test/framework/utils"
1716
)
1817

1918
var _ = Describe("GlobalAccelerator with multiple endpoint types", func() {
2019
var (
21-
ctx context.Context
22-
agaStack *ResourceStack
23-
svcStack *service.ResourceStack
24-
ingStack *ingress.ResourceStack
25-
namespace string
26-
svcName string
27-
ingName string
28-
aga *agav1beta1.GlobalAccelerator
29-
baseName string
20+
ctx context.Context
21+
agaStack *ResourceStack
22+
ingStack *ingress.ResourceStack
23+
namespace string
24+
svcName string
25+
ingName string
26+
aga *agav1beta1.GlobalAccelerator
27+
baseName string
28+
svcDeployment *appsv1.Deployment
29+
nlbSvc *corev1.Service
3030
)
3131

3232
BeforeEach(func() {
@@ -52,12 +52,13 @@ var _ = Describe("GlobalAccelerator with multiple endpoint types", func() {
5252
Expect(err).NotTo(HaveOccurred())
5353

5454
// Deploy Service endpoint resources in the same namespace
55-
svcDeployment := createDeployment(baseName+"-svc", namespace, labels)
55+
svcDeployment = createDeployment(baseName+"-svc", namespace, labels)
5656
nlbAnnotations := createServiceAnnotations("nlb-ip", "internet-facing", tf.Options.IPFamily)
57-
nlbSvc := createLoadBalancerService(svcName, labels, nlbAnnotations)
57+
nlbSvc = createLoadBalancerService(svcName, labels, nlbAnnotations)
5858
nlbSvc.Namespace = namespace
59-
svcStack = service.NewResourceStack(svcDeployment, nlbSvc, nil, namespace, true)
60-
err = svcStack.Deploy(ctx, tf)
59+
err = tf.K8sClient.Create(ctx, svcDeployment)
60+
Expect(err).NotTo(HaveOccurred())
61+
err = tf.K8sClient.Create(ctx, nlbSvc)
6162
Expect(err).NotTo(HaveOccurred())
6263
})
6364

@@ -66,17 +67,25 @@ var _ = Describe("GlobalAccelerator with multiple endpoint types", func() {
6667
err := agaStack.Cleanup(ctx, tf)
6768
Expect(err).NotTo(HaveOccurred())
6869
}
70+
if nlbSvc != nil {
71+
err := tf.K8sClient.Delete(ctx, nlbSvc)
72+
if err != nil {
73+
tf.Logger.Info("failed to delete service", "error", err)
74+
}
75+
}
76+
if svcDeployment != nil {
77+
err := tf.K8sClient.Delete(ctx, svcDeployment)
78+
if err != nil {
79+
tf.Logger.Info("failed to delete deployment", "error", err)
80+
}
81+
}
6982
if ingStack != nil {
7083
err := ingStack.Cleanup(ctx, tf)
7184
Expect(err).NotTo(HaveOccurred())
7285
}
73-
if svcStack != nil {
74-
err := svcStack.Cleanup(ctx, tf)
75-
Expect(err).NotTo(HaveOccurred())
76-
}
7786
})
7887

79-
Context("Multiple endpoint types with port overrides", func() {
88+
Context("Multiple endpoint", func() {
8089
It("Should create GlobalAccelerator with Service and Ingress endpoints", func() {
8190
acceleratorName := "aga-multi-" + utils.RandomDNS1123Label(6)
8291
protocol := agav1beta1.GlobalAcceleratorProtocolTCP
@@ -87,14 +96,15 @@ var _ = Describe("GlobalAccelerator with multiple endpoint types", func() {
8796
"svcName", svcName,
8897
"ingName", ingName)
8998

99+
svcEndpoint := createServiceEndpoint(svcName, 128)
90100
aga = createAGA(gaName, namespace, acceleratorName, agav1beta1.IPAddressTypeIPV4, &[]agav1beta1.GlobalAcceleratorListener{{
91101
Protocol: &protocol,
92102
PortRanges: &[]agav1beta1.PortRange{{FromPort: 80, ToPort: 80}},
93103
ClientAffinity: agav1beta1.ClientAffinityNone,
94104
EndpointGroups: &[]agav1beta1.GlobalAcceleratorEndpointGroup{{
95105
TrafficDialPercentage: awssdk.Int32(100),
96106
Endpoints: &[]agav1beta1.GlobalAcceleratorEndpoint{
97-
{Type: agav1beta1.GlobalAcceleratorEndpointTypeService, Name: awssdk.String(svcName)},
107+
svcEndpoint,
98108
{Type: agav1beta1.GlobalAcceleratorEndpointTypeIngress, Name: awssdk.String(ingName)},
99109
},
100110
}},
@@ -118,7 +128,7 @@ var _ = Describe("GlobalAccelerator with multiple endpoint types", func() {
118128
ClientAffinity: string(types.ClientAffinityNone),
119129
EndpointGroups: []EndpointGroupExpectation{{
120130
TrafficDialPercentage: 100,
121-
NumEndpoints: 1,
131+
NumEndpoints: 2,
122132
}},
123133
}},
124134
})

test/e2e/globalaccelerator/service_endpoint_test.go

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
agav1beta1 "sigs.k8s.io/aws-load-balancer-controller/apis/aga/v1beta1"
1313
"sigs.k8s.io/aws-load-balancer-controller/pkg/k8s"
1414
"sigs.k8s.io/aws-load-balancer-controller/test/e2e/service"
15+
"sigs.k8s.io/aws-load-balancer-controller/test/framework"
1516
"sigs.k8s.io/aws-load-balancer-controller/test/framework/utils"
1617
)
1718

@@ -79,11 +80,7 @@ var _ = Describe("GlobalAccelerator with Service endpoint", func() {
7980
{
8081
TrafficDialPercentage: awssdk.Int32(100),
8182
Endpoints: &[]agav1beta1.GlobalAcceleratorEndpoint{
82-
{
83-
Type: agav1beta1.GlobalAcceleratorEndpointTypeService,
84-
Name: awssdk.String(svcName),
85-
Weight: awssdk.Int32(128),
86-
},
83+
createServiceEndpoint(svcName, 128),
8784
},
8885
},
8986
},
@@ -202,6 +199,9 @@ var _ = Describe("GlobalAccelerator with Service endpoint", func() {
202199
})
203200

204201
It("Should update GlobalAccelerator endpoint when load balancer scheme changes", func() {
202+
if tf.Options.IPFamily == framework.IPv6 {
203+
Skip("Skipping test for IPv6")
204+
}
205205
acceleratorName := "aga-svc-ins" + utils.RandomDNS1123Label(6)
206206
gaName := "aga-" + utils.RandomDNS1123Label(8)
207207
protocol := agav1beta1.GlobalAcceleratorProtocolTCP
@@ -358,10 +358,7 @@ var _ = Describe("GlobalAccelerator with Service endpoint", func() {
358358
ClientAffinity: agav1beta1.ClientAffinityNone,
359359
EndpointGroups: &[]agav1beta1.GlobalAcceleratorEndpointGroup{{
360360
TrafficDialPercentage: awssdk.Int32(100),
361-
Endpoints: &[]agav1beta1.GlobalAcceleratorEndpoint{{
362-
Type: agav1beta1.GlobalAcceleratorEndpointTypeEndpointID,
363-
EndpointID: awssdk.String(lbARN),
364-
}},
361+
Endpoints: &[]agav1beta1.GlobalAcceleratorEndpoint{createEndpointIDEndpoint(lbARN)},
365362
}},
366363
}})
367364

@@ -446,11 +443,7 @@ var _ = Describe("GlobalAccelerator with Service endpoint", func() {
446443
ClientAffinity: agav1beta1.ClientAffinityNone,
447444
EndpointGroups: &[]agav1beta1.GlobalAcceleratorEndpointGroup{{
448445
TrafficDialPercentage: awssdk.Int32(100),
449-
Endpoints: &[]agav1beta1.GlobalAcceleratorEndpoint{{
450-
Type: agav1beta1.GlobalAcceleratorEndpointTypeService,
451-
Name: awssdk.String(instanceSvcName),
452-
Weight: awssdk.Int32(128),
453-
}},
446+
Endpoints: &[]agav1beta1.GlobalAcceleratorEndpoint{createServiceEndpoint(instanceSvcName, 128)},
454447
}},
455448
},
456449
{
@@ -459,11 +452,7 @@ var _ = Describe("GlobalAccelerator with Service endpoint", func() {
459452
ClientAffinity: agav1beta1.ClientAffinityNone,
460453
EndpointGroups: &[]agav1beta1.GlobalAcceleratorEndpointGroup{{
461454
TrafficDialPercentage: awssdk.Int32(100),
462-
Endpoints: &[]agav1beta1.GlobalAcceleratorEndpoint{{
463-
Type: agav1beta1.GlobalAcceleratorEndpointTypeService,
464-
Name: awssdk.String(instanceSvcName),
465-
Weight: awssdk.Int32(128),
466-
}},
455+
Endpoints: &[]agav1beta1.GlobalAcceleratorEndpoint{createServiceEndpoint(instanceSvcName, 128)},
467456
}},
468457
},
469458
})
@@ -520,11 +509,7 @@ var _ = Describe("GlobalAccelerator with Service endpoint", func() {
520509
ClientAffinity: agav1beta1.ClientAffinityNone,
521510
EndpointGroups: &[]agav1beta1.GlobalAcceleratorEndpointGroup{{
522511
TrafficDialPercentage: awssdk.Int32(100),
523-
Endpoints: &[]agav1beta1.GlobalAcceleratorEndpoint{{
524-
Type: agav1beta1.GlobalAcceleratorEndpointTypeService,
525-
Name: awssdk.String(instanceSvcName),
526-
Weight: awssdk.Int32(128),
527-
}},
512+
Endpoints: &[]agav1beta1.GlobalAcceleratorEndpoint{createServiceEndpoint(instanceSvcName, 128)},
528513
}},
529514
}})
530515

test/e2e/globalaccelerator/test_helpers_test.go

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,18 @@ func createAGAWithIngressEndpoint(name, namespace, acceleratorName, endpointName
5353
// Pass nil for listeners to use auto-discovery (omits Protocol, PortRanges, ClientAffinity, TrafficDialPercentage)
5454
func createAGAWithServiceEndpoint(name, namespace, acceleratorName, endpointName string, ipAddressType agav1beta1.IPAddressType, listeners *[]agav1beta1.GlobalAcceleratorListener) *agav1beta1.GlobalAccelerator {
5555
if listeners == nil {
56+
ep := agav1beta1.GlobalAcceleratorEndpoint{
57+
Type: agav1beta1.GlobalAcceleratorEndpointTypeService,
58+
Name: awssdk.String(endpointName),
59+
}
60+
if tf.Options.IPFamily == framework.IPv6 {
61+
ep.ClientIPPreservationEnabled = awssdk.Bool(false)
62+
}
5663
listeners = &[]agav1beta1.GlobalAcceleratorListener{
5764
{
5865
EndpointGroups: &[]agav1beta1.GlobalAcceleratorEndpointGroup{
5966
{
60-
Endpoints: &[]agav1beta1.GlobalAcceleratorEndpoint{
61-
{
62-
Type: agav1beta1.GlobalAcceleratorEndpointTypeService,
63-
Name: awssdk.String(endpointName),
64-
},
65-
},
67+
Endpoints: &[]agav1beta1.GlobalAcceleratorEndpoint{ep},
6668
},
6769
},
6870
},
@@ -97,16 +99,18 @@ func createAGAWithGatewayEndpoint(name, namespace, acceleratorName, endpointName
9799
// Pass nil for listeners to use auto-discovery (omits Protocol, PortRanges, ClientAffinity, TrafficDialPercentage)
98100
func createAGAWithEndpointID(name, namespace, acceleratorName, endpointID string, ipAddressType agav1beta1.IPAddressType, listeners *[]agav1beta1.GlobalAcceleratorListener) *agav1beta1.GlobalAccelerator {
99101
if listeners == nil {
102+
ep := agav1beta1.GlobalAcceleratorEndpoint{
103+
Type: agav1beta1.GlobalAcceleratorEndpointTypeEndpointID,
104+
EndpointID: awssdk.String(endpointID),
105+
}
106+
if tf.Options.IPFamily == framework.IPv6 {
107+
ep.ClientIPPreservationEnabled = awssdk.Bool(false)
108+
}
100109
listeners = &[]agav1beta1.GlobalAcceleratorListener{
101110
{
102111
EndpointGroups: &[]agav1beta1.GlobalAcceleratorEndpointGroup{
103112
{
104-
Endpoints: &[]agav1beta1.GlobalAcceleratorEndpoint{
105-
{
106-
Type: agav1beta1.GlobalAcceleratorEndpointTypeEndpointID,
107-
EndpointID: awssdk.String(endpointID),
108-
},
109-
},
113+
Endpoints: &[]agav1beta1.GlobalAcceleratorEndpoint{ep},
110114
},
111115
},
112116
},
@@ -252,3 +256,28 @@ func createServiceAnnotations(lbType, scheme string, ipFamily string) map[string
252256
}
253257
return annotations
254258
}
259+
260+
// createServiceEndpoint creates a Service endpoint with appropriate clientIPPreservationEnabled setting
261+
func createServiceEndpoint(svcName string, weight int32) agav1beta1.GlobalAcceleratorEndpoint {
262+
ep := agav1beta1.GlobalAcceleratorEndpoint{
263+
Type: agav1beta1.GlobalAcceleratorEndpointTypeService,
264+
Name: awssdk.String(svcName),
265+
Weight: awssdk.Int32(weight),
266+
}
267+
if tf.Options.IPFamily == framework.IPv6 {
268+
ep.ClientIPPreservationEnabled = awssdk.Bool(false)
269+
}
270+
return ep
271+
}
272+
273+
// createEndpointIDEndpoint creates an EndpointID endpoint with appropriate clientIPPreservationEnabled setting
274+
func createEndpointIDEndpoint(endpointID string) agav1beta1.GlobalAcceleratorEndpoint {
275+
ep := agav1beta1.GlobalAcceleratorEndpoint{
276+
Type: agav1beta1.GlobalAcceleratorEndpointTypeEndpointID,
277+
EndpointID: awssdk.String(endpointID),
278+
}
279+
if tf.Options.IPFamily == framework.IPv6 {
280+
ep.ClientIPPreservationEnabled = awssdk.Bool(false)
281+
}
282+
return ep
283+
}

0 commit comments

Comments
 (0)