Skip to content

Commit 9651683

Browse files
committed
[feat gw-api]update relative e2e tests
1 parent 658d7ed commit 9651683

File tree

7 files changed

+103
-31
lines changed

7 files changed

+103
-31
lines changed

controllers/gateway/route_reconciler_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,12 +503,12 @@ func Test_setConditionsWithRouteStatusInfo(t *testing.T) {
503503
acceptedCondition := findCondition(conditions, string(gwv1.RouteConditionAccepted))
504504
assert.NotNil(t, acceptedCondition)
505505
assert.Equal(t, metav1.ConditionTrue, acceptedCondition.Status)
506-
assert.Equal(t, gwv1.RouteReasonAccepted, acceptedCondition.Reason)
506+
assert.Equal(t, string(gwv1.RouteReasonAccepted), acceptedCondition.Reason)
507507

508508
resolvedRefCondition := findCondition(conditions, string(gwv1.RouteConditionResolvedRefs))
509509
assert.NotNil(t, resolvedRefCondition)
510510
assert.Equal(t, metav1.ConditionTrue, resolvedRefCondition.Status)
511-
assert.Equal(t, gwv1.RouteReasonResolvedRefs, resolvedRefCondition.Reason)
511+
assert.Equal(t, string(gwv1.RouteReasonResolvedRefs), resolvedRefCondition.Reason)
512512
},
513513
},
514514
{

test/e2e/gateway/alb_instance_target_test.go

Lines changed: 62 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,12 @@ var _ = Describe("test k8s alb gateway using instance targets reconciled by the
5757
Scheme: &interf,
5858
ListenerConfigurations: listenerConfigurationForHeaderModification,
5959
}
60-
tgSpec := elbv2gw.TargetGroupConfigurationSpec{}
60+
instanceTargetType := elbv2gw.TargetTypeInstance
61+
tgSpec := elbv2gw.TargetGroupConfigurationSpec{
62+
DefaultConfiguration: elbv2gw.TargetGroupProps{
63+
TargetType: &instanceTargetType,
64+
},
65+
}
6166
lrcSpec := elbv2gw.ListenerRuleConfigurationSpec{}
6267
gwListeners := []gwv1.Listener{
6368
{
@@ -135,9 +140,9 @@ var _ = Describe("test k8s alb gateway using instance targets reconciled by the
135140
err := tf.HTTPVerifier.VerifyURL(url, http.ResponseCodeMatches(200))
136141
Expect(err).NotTo(HaveOccurred())
137142
})
138-
By("cross-ns listener should return 503 as no ref grant is available", func() {
143+
By("cross-ns listener should return 500 as no ref grant is available", func() {
139144
url := fmt.Sprintf("http://%v:5000/any-path", dnsName)
140-
err := tf.HTTPVerifier.VerifyURL(url, http.ResponseCodeMatches(503))
145+
err := tf.HTTPVerifier.VerifyURL(url, http.ResponseCodeMatches(500))
141146
Expect(err).NotTo(HaveOccurred())
142147
})
143148
By("confirming the route status", func() {
@@ -191,9 +196,9 @@ var _ = Describe("test k8s alb gateway using instance targets reconciled by the
191196
// Give some time to have the reference grant to be deleted
192197
time.Sleep(2 * time.Minute)
193198
})
194-
By("cross-ns listener should return 503 as no ref grant is available", func() {
199+
By("cross-ns listener should return 500 as no ref grant is available", func() {
195200
url := fmt.Sprintf("http://%v:5000/any-path", dnsName)
196-
err := tf.HTTPVerifier.VerifyURL(url, http.ResponseCodeMatches(503))
201+
err := tf.HTTPVerifier.VerifyURL(url, http.ResponseCodeMatches(500))
197202
Expect(err).NotTo(HaveOccurred())
198203
})
199204
By("confirming the route status", func() {
@@ -209,7 +214,12 @@ var _ = Describe("test k8s alb gateway using instance targets reconciled by the
209214
lbcSpec := elbv2gw.LoadBalancerConfigurationSpec{
210215
Scheme: &interf,
211216
}
212-
tgSpec := elbv2gw.TargetGroupConfigurationSpec{}
217+
instanceTargetType := elbv2gw.TargetTypeInstance
218+
tgSpec := elbv2gw.TargetGroupConfigurationSpec{
219+
DefaultConfiguration: elbv2gw.TargetGroupProps{
220+
TargetType: &instanceTargetType,
221+
},
222+
}
213223
lrcSpec := elbv2gw.ListenerRuleConfigurationSpec{}
214224
gwListeners := []gwv1.Listener{
215225
{
@@ -414,7 +424,12 @@ var _ = Describe("test k8s alb gateway using instance targets reconciled by the
414424
lbcSpec := elbv2gw.LoadBalancerConfigurationSpec{
415425
Scheme: &interf,
416426
}
417-
tgSpec := elbv2gw.TargetGroupConfigurationSpec{}
427+
instanceTargetType := elbv2gw.TargetTypeInstance
428+
tgSpec := elbv2gw.TargetGroupConfigurationSpec{
429+
DefaultConfiguration: elbv2gw.TargetGroupProps{
430+
TargetType: &instanceTargetType,
431+
},
432+
}
418433
lrcSpec := elbv2gw.ListenerRuleConfigurationSpec{}
419434
gwListeners := []gwv1.Listener{
420435
{
@@ -477,7 +492,12 @@ var _ = Describe("test k8s alb gateway using instance targets reconciled by the
477492
lbcSpec := elbv2gw.LoadBalancerConfigurationSpec{
478493
Scheme: &interf,
479494
}
480-
tgSpec := elbv2gw.TargetGroupConfigurationSpec{}
495+
instanceTargetType := elbv2gw.TargetTypeInstance
496+
tgSpec := elbv2gw.TargetGroupConfigurationSpec{
497+
DefaultConfiguration: elbv2gw.TargetGroupProps{
498+
TargetType: &instanceTargetType,
499+
},
500+
}
481501

482502
matchIndex := []int{0, 2}
483503
sourceIp := "10.0.0.0/8"
@@ -681,7 +701,12 @@ var _ = Describe("test k8s alb gateway using instance targets reconciled by the
681701
DefaultCertificate: &cert,
682702
}
683703
lbcSpec.ListenerConfigurations = &[]elbv2gw.ListenerConfiguration{lsConfig}
684-
tgSpec := elbv2gw.TargetGroupConfigurationSpec{}
704+
instanceTargetType := elbv2gw.TargetTypeInstance
705+
tgSpec := elbv2gw.TargetGroupConfigurationSpec{
706+
DefaultConfiguration: elbv2gw.TargetGroupProps{
707+
TargetType: &instanceTargetType,
708+
},
709+
}
685710
lrcSpec := elbv2gw.ListenerRuleConfigurationSpec{}
686711
gwListeners := []gwv1.Listener{
687712
{
@@ -781,7 +806,12 @@ var _ = Describe("test k8s alb gateway using instance targets reconciled by the
781806
},
782807
}
783808
lbcSpec.ListenerConfigurations = &[]elbv2gw.ListenerConfiguration{lsConfig}
784-
tgSpec := elbv2gw.TargetGroupConfigurationSpec{}
809+
instanceTargetType := elbv2gw.TargetTypeInstance
810+
tgSpec := elbv2gw.TargetGroupConfigurationSpec{
811+
DefaultConfiguration: elbv2gw.TargetGroupProps{
812+
TargetType: &instanceTargetType,
813+
},
814+
}
785815
lrcSpec := elbv2gw.ListenerRuleConfigurationSpec{}
786816
gwListeners := []gwv1.Listener{
787817
{
@@ -885,7 +915,12 @@ var _ = Describe("test k8s alb gateway using instance targets reconciled by the
885915
DefaultCertificate: &cert,
886916
}
887917
lbcSpec.ListenerConfigurations = &[]elbv2gw.ListenerConfiguration{lsConfig}
888-
tgSpec := elbv2gw.TargetGroupConfigurationSpec{}
918+
instanceTargetType := elbv2gw.TargetTypeInstance
919+
tgSpec := elbv2gw.TargetGroupConfigurationSpec{
920+
DefaultConfiguration: elbv2gw.TargetGroupProps{
921+
TargetType: &instanceTargetType,
922+
},
923+
}
889924
gwListeners := []gwv1.Listener{
890925
{
891926
Name: "https443",
@@ -1071,7 +1106,12 @@ var _ = Describe("test k8s alb gateway using instance targets reconciled by the
10711106
DefaultCertificate: &cert,
10721107
}
10731108
lbcSpec.ListenerConfigurations = &[]elbv2gw.ListenerConfiguration{lsConfig}
1074-
tgSpec := elbv2gw.TargetGroupConfigurationSpec{}
1109+
instanceTargetType := elbv2gw.TargetTypeInstance
1110+
tgSpec := elbv2gw.TargetGroupConfigurationSpec{
1111+
DefaultConfiguration: elbv2gw.TargetGroupProps{
1112+
TargetType: &instanceTargetType,
1113+
},
1114+
}
10751115
gwListeners := []gwv1.Listener{
10761116
{
10771117
Name: "https443",
@@ -1284,7 +1324,12 @@ var _ = Describe("test k8s alb gateway using instance targets reconciled by the
12841324
httpsLsConfig,
12851325
}
12861326

1287-
tgSpec := elbv2gw.TargetGroupConfigurationSpec{}
1327+
instanceTargetType := elbv2gw.TargetTypeInstance
1328+
tgSpec := elbv2gw.TargetGroupConfigurationSpec{
1329+
DefaultConfiguration: elbv2gw.TargetGroupProps{
1330+
TargetType: &instanceTargetType,
1331+
},
1332+
}
12881333
lrcSpec := elbv2gw.ListenerRuleConfigurationSpec{}
12891334
gwListeners := []gwv1.Listener{
12901335
{
@@ -1413,8 +1458,11 @@ var _ = Describe("test k8s alb gateway using instance targets reconciled by the
14131458
DefaultCertificate: &cert,
14141459
}
14151460
lbcSpec.ListenerConfigurations = &[]elbv2gw.ListenerConfiguration{lsConfig}
1461+
instanceTargetType := elbv2gw.TargetTypeInstance
14161462
tgSpec := elbv2gw.TargetGroupConfigurationSpec{
1417-
DefaultConfiguration: elbv2gw.TargetGroupProps{},
1463+
DefaultConfiguration: elbv2gw.TargetGroupProps{
1464+
TargetType: &instanceTargetType,
1465+
},
14181466
}
14191467
lrcSpec := elbv2gw.ListenerRuleConfigurationSpec{}
14201468
gwListeners := []gwv1.Listener{

test/e2e/gateway/alb_ip_target_test.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ import (
44
"context"
55
"crypto/tls"
66
"fmt"
7+
"strings"
8+
"time"
9+
710
awssdk "github.com/aws/aws-sdk-go-v2/aws"
811
elbv2types "github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2/types"
912
"github.com/gavv/httpexpect/v2"
@@ -21,8 +24,6 @@ import (
2124
"sigs.k8s.io/aws-load-balancer-controller/test/framework/utils"
2225
"sigs.k8s.io/aws-load-balancer-controller/test/framework/verifier"
2326
gwv1 "sigs.k8s.io/gateway-api/apis/v1"
24-
"strings"
25-
"time"
2627
)
2728

2829
var _ = Describe("test k8s alb gateway using ip targets reconciled by the aws load balancer controller", func() {
@@ -130,9 +131,9 @@ var _ = Describe("test k8s alb gateway using ip targets reconciled by the aws lo
130131
err := tf.HTTPVerifier.VerifyURL(url, http.ResponseCodeMatches(200))
131132
Expect(err).NotTo(HaveOccurred())
132133
})
133-
By("cross-ns listener should return 503 as no ref grant is available", func() {
134+
By("cross-ns listener should return 500 as no ref grant is available", func() {
134135
url := fmt.Sprintf("http://%v:5000/any-path", dnsName)
135-
err := tf.HTTPVerifier.VerifyURL(url, http.ResponseCodeMatches(503))
136+
err := tf.HTTPVerifier.VerifyURL(url, http.ResponseCodeMatches(500))
136137
Expect(err).NotTo(HaveOccurred())
137138
})
138139
By("confirming the route status", func() {
@@ -184,9 +185,9 @@ var _ = Describe("test k8s alb gateway using ip targets reconciled by the aws lo
184185
// Give some time to have the reference grant to be deleted
185186
time.Sleep(2 * time.Minute)
186187
})
187-
By("cross-ns listener should return 503 as no ref grant is available", func() {
188+
By("cross-ns listener should return 500 as no ref grant is available", func() {
188189
url := fmt.Sprintf("http://%v:5000/any-path", dnsName)
189-
err := tf.HTTPVerifier.VerifyURL(url, http.ResponseCodeMatches(503))
190+
err := tf.HTTPVerifier.VerifyURL(url, http.ResponseCodeMatches(500))
190191
Expect(err).NotTo(HaveOccurred())
191192
})
192193
By("confirming the route status", func() {

test/e2e/gateway/alb_test_helper.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"crypto/tls"
66
"fmt"
7+
78
"google.golang.org/grpc"
89
"google.golang.org/grpc/credentials"
910
appsv1 "k8s.io/api/apps/v1"
@@ -131,8 +132,8 @@ func validateHTTPRouteStatusNotPermitted(tf *framework.Framework, stack ALBTestS
131132
parentKind: "Gateway",
132133
resolvedRefReason: "RefNotPermitted",
133134
resolvedRefsStatus: "False",
134-
acceptedReason: "RefNotPermitted",
135-
acceptedStatus: "False",
135+
acceptedReason: "Accepted",
136+
acceptedStatus: "True",
136137
},
137138
},
138139
},

test/e2e/gateway/nlb_instance_target_test.go

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,17 @@ package gateway
33
import (
44
"context"
55
"fmt"
6+
"strconv"
7+
"strings"
8+
"time"
9+
610
awssdk "github.com/aws/aws-sdk-go-v2/aws"
711
. "github.com/onsi/ginkgo/v2"
812
. "github.com/onsi/gomega"
913
elbv2gw "sigs.k8s.io/aws-load-balancer-controller/apis/gateway/v1beta1"
1014
"sigs.k8s.io/aws-load-balancer-controller/test/framework/http"
1115
"sigs.k8s.io/aws-load-balancer-controller/test/framework/utils"
1216
"sigs.k8s.io/aws-load-balancer-controller/test/framework/verifier"
13-
"strconv"
14-
"strings"
15-
"time"
1617
)
1718

1819
var _ = Describe("test nlb gateway using instance targets reconciled by the aws load balancer controller", func() {
@@ -56,7 +57,12 @@ var _ = Describe("test nlb gateway using instance targets reconciled by the aws
5657
hasTLS = true
5758
}
5859

59-
tgSpec := elbv2gw.TargetGroupConfigurationSpec{}
60+
instanceTargetType := elbv2gw.TargetTypeInstance
61+
tgSpec := elbv2gw.TargetGroupConfigurationSpec{
62+
DefaultConfiguration: elbv2gw.TargetGroupProps{
63+
TargetType: &instanceTargetType,
64+
},
65+
}
6066

6167
auxiliaryStack = newAuxiliaryResourceStack(ctx, tf, tgSpec, false)
6268

@@ -318,7 +324,12 @@ var _ = Describe("test nlb gateway using instance targets reconciled by the aws
318324
hasTLS = true
319325
}
320326

321-
tgSpec := elbv2gw.TargetGroupConfigurationSpec{}
327+
instanceTargetType := elbv2gw.TargetTypeInstance
328+
tgSpec := elbv2gw.TargetGroupConfigurationSpec{
329+
DefaultConfiguration: elbv2gw.TargetGroupProps{
330+
TargetType: &instanceTargetType,
331+
},
332+
}
322333

323334
auxiliaryStack = newAuxiliaryResourceStack(ctx, tf, tgSpec, false)
324335

test/e2e/gateway/nlb_test_helper.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package gateway
33
import (
44
"context"
55
"fmt"
6+
67
awssdk "github.com/aws/aws-sdk-go-v2/aws"
78
appsv1 "k8s.io/api/apps/v1"
89
corev1 "k8s.io/api/core/v1"
@@ -49,10 +50,19 @@ func (s *NLBTestStack) Deploy(ctx context.Context, f *framework.Framework, auxil
4950
if lbConfSpec.ListenerConfigurations != nil {
5051
for _, lsr := range *lbConfSpec.ListenerConfigurations {
5152
if lsr.ProtocolPort == "TLS:443" {
53+
tlsMode := gwv1.TLSModeTerminate
5254
listeners = append(listeners, gwv1.Listener{
5355
Name: "port443",
5456
Port: 443,
5557
Protocol: gwv1.TLSProtocolType,
58+
TLS: &gwv1.GatewayTLSConfig{
59+
Mode: &tlsMode,
60+
CertificateRefs: []gwv1.SecretObjectReference{
61+
{
62+
Name: "tls-cert",
63+
},
64+
},
65+
},
5666
})
5767
break
5868
}
@@ -253,8 +263,8 @@ func validateL4RouteStatusNotPermitted(tf *framework.Framework, stack NLBTestSta
253263
parentKind: "Gateway",
254264
resolvedRefReason: "RefNotPermitted",
255265
resolvedRefsStatus: "False",
256-
acceptedReason: "RefNotPermitted",
257-
acceptedStatus: "False",
266+
acceptedReason: "Accepted",
267+
acceptedStatus: "True",
258268
},
259269
},
260270
},

test/e2e/gateway/route_validator.go

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

33
import (
44
"fmt"
5+
56
"github.com/onsi/ginkgo/v2"
67
. "github.com/onsi/gomega"
78
"k8s.io/apimachinery/pkg/types"

0 commit comments

Comments
 (0)