Skip to content

Commit 1c3cd3c

Browse files
committed
test(ingress): current tests pass
1 parent 8e92ce3 commit 1c3cd3c

File tree

1 file changed

+35
-2
lines changed

1 file changed

+35
-2
lines changed

pkg/ingress/model_build_frontend_nlb_test.go

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ func Test_buildFrontendNlbSubnetMappings(t *testing.T) {
216216
},
217217
},
218218
{
219-
name: "with subnets annoattion",
219+
name: "with subnets annotation",
220220
fields: fields{
221221
ingGroup: Group{
222222
ID: GroupID{
@@ -302,6 +302,34 @@ func Test_buildFrontendNlbSubnetMappings(t *testing.T) {
302302
wantMappings: nil,
303303
wantErr: "count of EIP allocations (2) and subnets (1) must match",
304304
},
305+
{
306+
name: "error when EIP allocations are specified but scheme is internal",
307+
fields: fields{
308+
ingGroup: Group{
309+
ID: GroupID{
310+
Namespace: "awesome-ns",
311+
Name: "my-ingress",
312+
},
313+
Members: []ClassifiedIngress{
314+
{
315+
Ing: &networking.Ingress{
316+
ObjectMeta: metav1.ObjectMeta{
317+
Namespace: "awesome-ns",
318+
Name: "ing-5",
319+
Annotations: map[string]string{
320+
"alb.ingress.kubernetes.io/frontend-nlb-subnets": "subnet-1,subnet-2",
321+
"alb.ingress.kubernetes.io/frontend-nlb-eip-allocations": "eip-1,eip-2",
322+
},
323+
},
324+
},
325+
},
326+
},
327+
},
328+
scheme: elbv2.LoadBalancerSchemeInternal, // EIPs not allowed for internal scheme
329+
},
330+
wantMappings: nil,
331+
wantErr: "EIP allocations can only be set for internet facing load balancers",
332+
},
305333
}
306334
for _, tt := range tests {
307335
t.Run(tt.name, func(t *testing.T) {
@@ -340,7 +368,12 @@ func Test_buildFrontendNlbSubnetMappings(t *testing.T) {
340368
annotationParser: annotationParser,
341369
subnetsResolver: subnetsResolver,
342370
}
343-
got, err := task.buildFrontendNlbSubnetMappings(context.Background(), tt.fields.scheme)
371+
alb := &elbv2model.LoadBalancer{
372+
Spec: elbv2model.LoadBalancerSpec{
373+
Scheme: tt.fields.scheme,
374+
},
375+
}
376+
got, err := task.buildFrontendNlbSubnetMappings(context.Background(), tt.fields.scheme, alb)
344377

345378
if err != nil {
346379
assert.EqualError(t, err, tt.wantErr)

0 commit comments

Comments
 (0)