Skip to content

Commit 22b7f77

Browse files
authored
Merge pull request #2477 from danehans/issue_2402
Conformance: Adds Test to Exercise Gateway AttachedRoutes
2 parents 203d400 + 8b76391 commit 22b7f77

File tree

2 files changed

+92
-0
lines changed

2 files changed

+92
-0
lines changed

conformance/tests/gateway-with-attached-routes.go

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ var GatewayWithAttachedRoutes = suite.ConformanceTest{
3636
Description: "A Gateway in the gateway-conformance-infra namespace should be attached to routes.",
3737
Features: []suite.SupportedFeature{
3838
suite.SupportGateway,
39+
suite.SupportHTTPRoute,
3940
},
4041
Manifests: []string{"tests/gateway-with-attached-routes.yaml"},
4142
Test: func(t *testing.T, s *suite.ConformanceTestSuite) {
@@ -90,6 +91,52 @@ var GatewayWithAttachedRoutes = suite.ConformanceTest{
9091

9192
kubernetes.GatewayStatusMustHaveListeners(t, s.Client, s.TimeoutConfig, gwNN, listeners)
9293
})
94+
95+
t.Run("Gateway listener should have AttachedRoutes set even when Gateway has unresolved refs", func(t *testing.T) {
96+
gwNN := types.NamespacedName{Name: "unresolved-gateway-with-one-attached-unresolved-route", Namespace: "gateway-conformance-infra"}
97+
listeners := []v1.ListenerStatus{{
98+
Name: v1.SectionName("tls"),
99+
SupportedKinds: []v1.RouteGroupKind{{
100+
Group: (*v1.Group)(&v1.GroupVersion.Group),
101+
Kind: v1.Kind("HTTPRoute"),
102+
}},
103+
Conditions: []metav1.Condition{
104+
{
105+
Type: string(v1.ListenerConditionAccepted),
106+
Status: metav1.ConditionTrue,
107+
Reason: "", // any reason
108+
},
109+
{
110+
Type: string(v1.ListenerConditionProgrammed),
111+
Status: metav1.ConditionFalse,
112+
Reason: "", // any reason
113+
},
114+
{
115+
Type: string(v1.ListenerConditionResolvedRefs),
116+
Status: metav1.ConditionFalse,
117+
Reason: "", // any reason
118+
},
119+
},
120+
AttachedRoutes: 1,
121+
}}
122+
123+
kubernetes.GatewayStatusMustHaveListeners(t, s.Client, s.TimeoutConfig, gwNN, listeners)
124+
125+
hrouteNN := types.NamespacedName{Name: "http-route-4", Namespace: "gateway-conformance-infra"}
126+
notAccepted := metav1.Condition{
127+
Type: string(v1.RouteConditionAccepted),
128+
Status: metav1.ConditionTrue,
129+
Reason: "", // any reason
130+
}
131+
unresolved := metav1.Condition{
132+
Type: string(v1.RouteConditionResolvedRefs),
133+
Status: metav1.ConditionFalse,
134+
Reason: "", // any reason
135+
}
136+
137+
kubernetes.HTTPRouteMustHaveCondition(t, s.Client, s.TimeoutConfig, hrouteNN, gwNN, notAccepted)
138+
kubernetes.HTTPRouteMustHaveCondition(t, s.Client, s.TimeoutConfig, hrouteNN, gwNN, unresolved)
139+
})
93140
},
94141
}
95142

@@ -99,6 +146,7 @@ var GatewayWithAttachedRoutesWithPort8080 = suite.ConformanceTest{
99146
Features: []suite.SupportedFeature{
100147
suite.SupportGateway,
101148
suite.SupportGatewayPort8080,
149+
suite.SupportHTTPRoute,
102150
},
103151
Manifests: []string{"tests/gateway-with-attached-routes-with-port-8080.yaml"},
104152
Test: func(t *testing.T, s *suite.ConformanceTestSuite) {

conformance/tests/gateway-with-attached-routes.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,47 @@ spec:
8686
- backendRefs:
8787
- name: infra-backend-v1
8888
port: 8080
89+
---
90+
apiVersion: gateway.networking.k8s.io/v1beta1
91+
kind: Gateway
92+
metadata:
93+
name: unresolved-gateway-with-one-attached-unresolved-route
94+
namespace: gateway-conformance-infra
95+
spec:
96+
gatewayClassName: "{GATEWAY_CLASS_NAME}"
97+
listeners:
98+
- name: tls
99+
port: 443
100+
protocol: HTTPS
101+
allowedRoutes:
102+
kinds:
103+
- kind: HTTPRoute
104+
namespaces:
105+
from: Selector
106+
selector:
107+
matchLabels:
108+
# This label is added automatically as of K8s 1.22
109+
# to all namespaces
110+
kubernetes.io/metadata.name: gateway-conformance-infra
111+
tls:
112+
certificateRefs:
113+
- group: ""
114+
kind: Secret
115+
name: does-not-exist
116+
mode: Terminate
117+
---
118+
apiVersion: gateway.networking.k8s.io/v1beta1
119+
kind: HTTPRoute
120+
metadata:
121+
name: http-route-4
122+
namespace: gateway-conformance-infra
123+
spec:
124+
parentRefs:
125+
- kind: Gateway
126+
name: unresolved-gateway-with-one-attached-unresolved-route
127+
namespace: gateway-conformance-infra
128+
sectionName: tls
129+
rules:
130+
- backendRefs:
131+
- name: does-not-exist
132+
port: 8080

0 commit comments

Comments
 (0)