Skip to content

Commit 6ecfc62

Browse files
authored
enable ingress instance e2e test for ipv6 (#3416)
* enable ingress instance e2e test for ipv6 * add coverage for ingress instance e2e test
1 parent 72602d3 commit 6ecfc62

File tree

3 files changed

+85
-30
lines changed

3 files changed

+85
-30
lines changed

scripts/run-e2e-test.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,12 +200,9 @@ function run_ginkgo_test() {
200200
TEST_RESULT=success
201201
local focus=$1
202202
echo "Starting the ginkgo tests from generated ginkgo test binaries with focus: $focus"
203-
if [ "$IP_FAMILY" == "IPv4" ]; then
203+
if [ "$IP_FAMILY" == "IPv4" ] || [ "$IP_FAMILY" == "IPv6" ]; then
204204
(CGO_ENABLED=0 GOOS=$OS_OVERRIDE ginkgo --no-color $EXTRA_GINKGO_FLAGS --focus="$focus" -v --timeout 2h --fail-on-pending $GINKGO_TEST_BUILD/ingress.test -- --kubeconfig=$KUBE_CONFIG_PATH --cluster-name=$CLUSTER_NAME --aws-region=$REGION --aws-vpc-id=$VPC_ID --test-image-registry=$TEST_IMAGE_REGISTRY --ip-family=$IP_FAMILY || TEST_RESULT=fail)
205205
(CGO_ENABLED=0 GOOS=$OS_OVERRIDE ginkgo --no-color $EXTRA_GINKGO_FLAGS --focus="$focus" -v --timeout 2h --fail-on-pending $GINKGO_TEST_BUILD/service.test -- --kubeconfig=$KUBE_CONFIG_PATH --cluster-name=$CLUSTER_NAME --aws-region=$REGION --aws-vpc-id=$VPC_ID --test-image-registry=$TEST_IMAGE_REGISTRY --ip-family=$IP_FAMILY || TEST_RESULT=fail)
206-
elif [ "$IP_FAMILY" == "IPv6" ]; then
207-
(CGO_ENABLED=0 GOOS=$OS_OVERRIDE ginkgo --no-color $EXTRA_GINKGO_FLAGS --focus="$focus" --skip="instance" -v --timeout 2h --fail-on-pending $GINKGO_TEST_BUILD/ingress.test -- --kubeconfig=$KUBE_CONFIG_PATH --cluster-name=$CLUSTER_NAME --aws-region=$REGION --aws-vpc-id=$VPC_ID --test-image-registry=$TEST_IMAGE_REGISTRY --ip-family=$IP_FAMILY || TEST_RESULT=fail)
208-
(CGO_ENABLED=0 GOOS=$OS_OVERRIDE ginkgo --no-color $EXTRA_GINKGO_FLAGS --focus="$focus" --skip="instance" -v --timeout 2h --fail-on-pending $GINKGO_TEST_BUILD/service.test -- --kubeconfig=$KUBE_CONFIG_PATH --cluster-name=$CLUSTER_NAME --aws-region=$REGION --aws-vpc-id=$VPC_ID --test-image-registry=$TEST_IMAGE_REGISTRY --ip-family=$IP_FAMILY || TEST_RESULT=fail)
209206
else
210207
echo "Invalid IP_FAMILY input, choose from IPv4 or IPv6 only"
211208
fi

test/e2e/ingress/multi_path_backend_test.go

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,11 @@ var _ = Describe("test ingresses with multiple path and backends", func() {
3838

3939
Context("with podReadinessGate enabled", func() {
4040
It("standalone Ingress should behaves correctly", func() {
41-
// TODO: Once instance mode is supported in IPv6, the backendConfigA can be removed and reverted
4241
backendConfigA := BackendConfig{
4342
Replicas: 3,
4443
TargetType: elbv2model.TargetTypeInstance,
4544
HTTPBody: "backend-a",
4645
}
47-
if tf.Options.IPFamily == "IPv6" {
48-
backendConfigA = BackendConfig{
49-
Replicas: 3,
50-
TargetType: elbv2model.TargetTypeIP,
51-
HTTPBody: "backend-a",
52-
}
53-
}
5446
stack := NewMultiPathBackendStack(map[string]NamespacedResourcesConfig{
5547
"ns-1": {
5648
IngCFGs: map[string]MultiPathIngressConfig{
@@ -106,9 +98,7 @@ var _ = Describe("test ingresses with multiple path and backends", func() {
10698
err = stack.Cleanup(ctx, tf)
10799
Expect(err).NotTo(HaveOccurred())
108100
})
109-
110101
It("IngressGroup across namespaces should behaves correctly", func() {
111-
// TODO: Once instance mode is supported in IPv6, the backendConfigA and backendConfigD can be removed and reverted
112102
backendConfigA := BackendConfig{
113103
Replicas: 3,
114104
TargetType: elbv2model.TargetTypeInstance,
@@ -119,18 +109,6 @@ var _ = Describe("test ingresses with multiple path and backends", func() {
119109
TargetType: elbv2model.TargetTypeInstance,
120110
HTTPBody: "backend-d",
121111
}
122-
if tf.Options.IPFamily == "IPv6" {
123-
backendConfigA = BackendConfig{
124-
Replicas: 3,
125-
TargetType: elbv2model.TargetTypeIP,
126-
HTTPBody: "backend-a",
127-
}
128-
backendConfigD = BackendConfig{
129-
Replicas: 3,
130-
TargetType: elbv2model.TargetTypeIP,
131-
HTTPBody: "backend-d",
132-
}
133-
}
134112
groupName := fmt.Sprintf("e2e-group.%v", utils.RandomDNS1123Label(8))
135113
stack := NewMultiPathBackendStack(map[string]NamespacedResourcesConfig{
136114
"ns-1": {

test/e2e/ingress/vanilla_ingress_test.go

Lines changed: 84 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,52 @@ var _ = Describe("vanilla ingress tests", func() {
7070
})
7171

7272
Context("with basic settings", func() {
73-
It("[ingress-class] with IngressClass configured with 'ingress.k8s.aws/alb' controller, one ALB shall be created and functional", func() {
73+
It("[ingress-class] in IP mode, with IngressClass configured with 'ingress.k8s.aws/alb' controller, one ALB shall be created and functional", func() {
74+
appBuilder := manifest.NewFixedResponseServiceBuilder()
75+
ingBuilder := manifest.NewIngressBuilder()
76+
dp, svc := appBuilder.Build(sandboxNS.Name, "app", tf.Options.TestImageRegistry)
77+
ingBackend := networking.IngressBackend{
78+
Service: &networking.IngressServiceBackend{
79+
Name: svc.Name,
80+
Port: networking.ServiceBackendPort{
81+
Number: 80,
82+
},
83+
},
84+
}
85+
ingClass := &networking.IngressClass{
86+
ObjectMeta: metav1.ObjectMeta{
87+
Name: sandboxNS.Name,
88+
},
89+
Spec: networking.IngressClassSpec{
90+
Controller: "ingress.k8s.aws/alb",
91+
},
92+
}
93+
annotation := map[string]string{
94+
"alb.ingress.kubernetes.io/scheme": "internet-facing",
95+
"alb.ingress.kubernetes.io/target-type": "ip",
96+
}
97+
if tf.Options.IPFamily == "IPv6" {
98+
annotation["alb.ingress.kubernetes.io/ip-address-type"] = "dualstack"
99+
}
100+
ing := ingBuilder.
101+
AddHTTPRoute("", networking.HTTPIngressPath{Path: "/path", PathType: &exact, Backend: ingBackend}).
102+
WithIngressClassName(ingClass.Name).
103+
WithAnnotations(annotation).Build(sandboxNS.Name, "ing")
104+
resStack := fixture.NewK8SResourceStack(tf, dp, svc, ingClass, ing)
105+
err := resStack.Setup(ctx)
106+
Expect(err).NotTo(HaveOccurred())
107+
108+
defer resStack.TearDown(ctx)
109+
110+
lbARN, lbDNS := ExpectOneLBProvisionedForIngress(ctx, tf, ing)
111+
// test traffic
112+
ExpectLBDNSBeAvailable(ctx, tf, lbARN, lbDNS)
113+
httpExp := httpexpect.New(tf.LoggerReporter, fmt.Sprintf("http://%v", lbDNS))
114+
httpExp.GET("/path").Expect().
115+
Status(http.StatusOK).
116+
Body().Equal("Hello World!")
117+
})
118+
It("[ingress-class] in Instance mode, with IngressClass configured with 'ingress.k8s.aws/alb' controller, one ALB shall be created and functional", func() {
74119
appBuilder := manifest.NewFixedResponseServiceBuilder()
75120
ingBuilder := manifest.NewIngressBuilder()
76121
dp, svc := appBuilder.Build(sandboxNS.Name, "app", tf.Options.TestImageRegistry)
@@ -95,7 +140,6 @@ var _ = Describe("vanilla ingress tests", func() {
95140
}
96141
if tf.Options.IPFamily == "IPv6" {
97142
annotation["alb.ingress.kubernetes.io/ip-address-type"] = "dualstack"
98-
annotation["alb.ingress.kubernetes.io/target-type"] = "ip"
99143
}
100144
ing := ingBuilder.
101145
AddHTTPRoute("", networking.HTTPIngressPath{Path: "/path", PathType: &exact, Backend: ingBackend}).
@@ -116,7 +160,44 @@ var _ = Describe("vanilla ingress tests", func() {
116160
Body().Equal("Hello World!")
117161
})
118162

119-
It("with 'kubernetes.io/ingress.class' annotation set to 'alb', one ALB shall be created and functional", func() {
163+
It("ingress in IP mode, with 'kubernetes.io/ingress.class' annotation set to 'alb', one ALB shall be created and functional", func() {
164+
appBuilder := manifest.NewFixedResponseServiceBuilder()
165+
ingBuilder := manifest.NewIngressBuilder()
166+
dp, svc := appBuilder.Build(sandboxNS.Name, "app", tf.Options.TestImageRegistry)
167+
ingBackend := networking.IngressBackend{
168+
Service: &networking.IngressServiceBackend{
169+
Name: svc.Name,
170+
Port: networking.ServiceBackendPort{
171+
Number: 80,
172+
},
173+
},
174+
}
175+
annotation := map[string]string{
176+
"kubernetes.io/ingress.class": "alb",
177+
"alb.ingress.kubernetes.io/scheme": "internet-facing",
178+
"alb.ingress.kubernetes.io/target-type": "ip",
179+
}
180+
if tf.Options.IPFamily == "IPv6" {
181+
annotation["alb.ingress.kubernetes.io/ip-address-type"] = "dualstack"
182+
}
183+
ing := ingBuilder.
184+
AddHTTPRoute("", networking.HTTPIngressPath{Path: "/path", PathType: &exact, Backend: ingBackend}).
185+
WithAnnotations(annotation).Build(sandboxNS.Name, "ing")
186+
resStack := fixture.NewK8SResourceStack(tf, dp, svc, ing)
187+
err := resStack.Setup(ctx)
188+
Expect(err).NotTo(HaveOccurred())
189+
190+
defer resStack.TearDown(ctx)
191+
192+
lbARN, lbDNS := ExpectOneLBProvisionedForIngress(ctx, tf, ing)
193+
// test traffic
194+
ExpectLBDNSBeAvailable(ctx, tf, lbARN, lbDNS)
195+
httpExp := httpexpect.New(tf.LoggerReporter, fmt.Sprintf("http://%v", lbDNS))
196+
httpExp.GET("/path").Expect().
197+
Status(http.StatusOK).
198+
Body().Equal("Hello World!")
199+
})
200+
It("ingress in Instance mode, with 'kubernetes.io/ingress.class' annotation set to 'alb', one ALB shall be created and functional", func() {
120201
appBuilder := manifest.NewFixedResponseServiceBuilder()
121202
ingBuilder := manifest.NewIngressBuilder()
122203
dp, svc := appBuilder.Build(sandboxNS.Name, "app", tf.Options.TestImageRegistry)
@@ -134,7 +215,6 @@ var _ = Describe("vanilla ingress tests", func() {
134215
}
135216
if tf.Options.IPFamily == "IPv6" {
136217
annotation["alb.ingress.kubernetes.io/ip-address-type"] = "dualstack"
137-
annotation["alb.ingress.kubernetes.io/target-type"] = "ip"
138218
}
139219
ing := ingBuilder.
140220
AddHTTPRoute("", networking.HTTPIngressPath{Path: "/path", PathType: &exact, Backend: ingBackend}).

0 commit comments

Comments
 (0)