Skip to content

Commit 1edccda

Browse files
authored
Merge pull request #2596 from oliviassss/ipv6-e2e
Add command line flag to run e2e test on ipv6 cluster
2 parents 02e9887 + 9868777 commit 1edccda

File tree

6 files changed

+193
-103
lines changed

6 files changed

+193
-103
lines changed

test/e2e/ingress/multi_path_backend.go

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func (s *multiPathBackendStack) Deploy(ctx context.Context, f *framework.Framewo
6666
if err := s.allocateNamespaces(ctx, f); err != nil {
6767
return err
6868
}
69-
s.resStackByNSID, s.ingByIngIDByNSID = s.buildResourceStacks(s.namespacedResourcesCFGs, s.nsByNSID)
69+
s.resStackByNSID, s.ingByIngIDByNSID = s.buildResourceStacks(s.namespacedResourcesCFGs, s.nsByNSID, f)
7070
if err := s.deployResourceStacks(ctx, f); err != nil {
7171
return err
7272
}
@@ -193,21 +193,21 @@ func (s *multiPathBackendStack) cleanupResourceStacks(ctx context.Context, f *fr
193193
return nil
194194
}
195195

196-
func (s *multiPathBackendStack) buildResourceStacks(namespacedResourcesCFGs map[string]NamespacedResourcesConfig, nsByNSID map[string]*corev1.Namespace) (map[string]*resourceStack, map[string]map[string]*networking.Ingress) {
196+
func (s *multiPathBackendStack) buildResourceStacks(namespacedResourcesCFGs map[string]NamespacedResourcesConfig, nsByNSID map[string]*corev1.Namespace, f *framework.Framework) (map[string]*resourceStack, map[string]map[string]*networking.Ingress) {
197197
resStackByNSID := make(map[string]*resourceStack, len(namespacedResourcesCFGs))
198198
ingByIngIDByNSID := make(map[string]map[string]*networking.Ingress, len(namespacedResourcesCFGs))
199199
for nsID, resCFG := range namespacedResourcesCFGs {
200200
ns := nsByNSID[nsID]
201-
resStack, ingByIngID := s.buildResourceStack(ns, resCFG)
201+
resStack, ingByIngID := s.buildResourceStack(ns, resCFG, f)
202202
resStackByNSID[nsID] = resStack
203203
ingByIngIDByNSID[nsID] = ingByIngID
204204
}
205205
return resStackByNSID, ingByIngIDByNSID
206206
}
207207

208-
func (s *multiPathBackendStack) buildResourceStack(ns *corev1.Namespace, resourcesCFG NamespacedResourcesConfig) (*resourceStack, map[string]*networking.Ingress) {
208+
func (s *multiPathBackendStack) buildResourceStack(ns *corev1.Namespace, resourcesCFG NamespacedResourcesConfig, f *framework.Framework) (*resourceStack, map[string]*networking.Ingress) {
209209
dpByBackendID, svcByBackendID := s.buildBackendResources(ns, resourcesCFG.BackendCFGs)
210-
ingByIngID := s.buildIngressResources(ns, resourcesCFG.IngCFGs, svcByBackendID)
210+
ingByIngID := s.buildIngressResources(ns, resourcesCFG.IngCFGs, svcByBackendID, f)
211211

212212
dps := make([]*appsv1.Deployment, 0, len(dpByBackendID))
213213
for _, dp := range dpByBackendID {
@@ -224,24 +224,28 @@ func (s *multiPathBackendStack) buildResourceStack(ns *corev1.Namespace, resourc
224224
return NewResourceStack(dps, svcs, ings), ingByIngID
225225
}
226226

227-
func (s *multiPathBackendStack) buildIngressResources(ns *corev1.Namespace, ingCFGs map[string]MultiPathIngressConfig, svcByBackendID map[string]*corev1.Service) map[string]*networking.Ingress {
227+
func (s *multiPathBackendStack) buildIngressResources(ns *corev1.Namespace, ingCFGs map[string]MultiPathIngressConfig, svcByBackendID map[string]*corev1.Service, f *framework.Framework) map[string]*networking.Ingress {
228228
ingByIngID := make(map[string]*networking.Ingress, len(ingCFGs))
229229
for ingID, ingCFG := range ingCFGs {
230-
ing := s.buildIngressResource(ns, ingID, ingCFG, svcByBackendID)
230+
ing := s.buildIngressResource(ns, ingID, ingCFG, svcByBackendID, f)
231231
ingByIngID[ingID] = ing
232232
}
233233
return ingByIngID
234234
}
235235

236-
func (s *multiPathBackendStack) buildIngressResource(ns *corev1.Namespace, ingID string, ingCFG MultiPathIngressConfig, svcByBackendID map[string]*corev1.Service) *networking.Ingress {
236+
func (s *multiPathBackendStack) buildIngressResource(ns *corev1.Namespace, ingID string, ingCFG MultiPathIngressConfig, svcByBackendID map[string]*corev1.Service, f *framework.Framework) *networking.Ingress {
237+
annotations := map[string]string{
238+
"kubernetes.io/ingress.class": "alb",
239+
"alb.ingress.kubernetes.io/scheme": "internet-facing",
240+
}
241+
if f.Options.IPFamily == "IPv6" {
242+
annotations["alb.ingress.kubernetes.io/ip-address-type"] = "dualstack"
243+
}
237244
ing := &networking.Ingress{
238245
ObjectMeta: metav1.ObjectMeta{
239-
Namespace: ns.Name,
240-
Name: ingID,
241-
Annotations: map[string]string{
242-
"kubernetes.io/ingress.class": "alb",
243-
"alb.ingress.kubernetes.io/scheme": "internet-facing",
244-
},
246+
Namespace: ns.Name,
247+
Name: ingID,
248+
Annotations: annotations,
245249
},
246250
Spec: networking.IngressSpec{
247251
Rules: []networking.IngressRule{

test/e2e/ingress/multi_path_backend_test.go

Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,19 @@ 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
42+
backendConfigA := BackendConfig{
43+
Replicas: 3,
44+
TargetType: elbv2model.TargetTypeInstance,
45+
HTTPBody: "backend-a",
46+
}
47+
if tf.Options.IPFamily == "IPv6" {
48+
backendConfigA = BackendConfig{
49+
Replicas: 3,
50+
TargetType: elbv2model.TargetTypeIP,
51+
HTTPBody: "backend-a",
52+
}
53+
}
4154
stack := NewMultiPathBackendStack(map[string]NamespacedResourcesConfig{
4255
"ns-1": {
4356
IngCFGs: map[string]MultiPathIngressConfig{
@@ -55,11 +68,7 @@ var _ = Describe("test ingresses with multiple path and backends", func() {
5568
},
5669
},
5770
BackendCFGs: map[string]BackendConfig{
58-
"backend-a": {
59-
Replicas: 3,
60-
TargetType: elbv2model.TargetTypeInstance,
61-
HTTPBody: "backend-a",
62-
},
71+
"backend-a": backendConfigA,
6372
"backend-b": {
6473
Replicas: 3,
6574
TargetType: elbv2model.TargetTypeIP,
@@ -99,6 +108,29 @@ var _ = Describe("test ingresses with multiple path and backends", func() {
99108
})
100109

101110
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
112+
backendConfigA := BackendConfig{
113+
Replicas: 3,
114+
TargetType: elbv2model.TargetTypeInstance,
115+
HTTPBody: "backend-a",
116+
}
117+
backendConfigD := BackendConfig{
118+
Replicas: 3,
119+
TargetType: elbv2model.TargetTypeInstance,
120+
HTTPBody: "backend-d",
121+
}
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+
}
102134
groupName := fmt.Sprintf("e2e-group.%v", utils.RandomDNS1123Label(8))
103135
stack := NewMultiPathBackendStack(map[string]NamespacedResourcesConfig{
104136
"ns-1": {
@@ -127,11 +159,7 @@ var _ = Describe("test ingresses with multiple path and backends", func() {
127159
},
128160
},
129161
BackendCFGs: map[string]BackendConfig{
130-
"backend-a": {
131-
Replicas: 3,
132-
TargetType: elbv2model.TargetTypeInstance,
133-
HTTPBody: "backend-a",
134-
},
162+
"backend-a": backendConfigA,
135163
"backend-b": {
136164
Replicas: 3,
137165
TargetType: elbv2model.TargetTypeIP,
@@ -161,11 +189,7 @@ var _ = Describe("test ingresses with multiple path and backends", func() {
161189
},
162190
},
163191
BackendCFGs: map[string]BackendConfig{
164-
"backend-d": {
165-
Replicas: 3,
166-
TargetType: elbv2model.TargetTypeInstance,
167-
HTTPBody: "backend-d",
168-
},
192+
"backend-d": backendConfigD,
169193
"backend-e": {
170194
Replicas: 3,
171195
TargetType: elbv2model.TargetTypeIP,

0 commit comments

Comments
 (0)