Skip to content

Commit 5754c2f

Browse files
committed
Conformance: Adds Test to Exercise Gateway AttachedRoutes
Signed-off-by: Daneyon Hansen <[email protected]>
1 parent 3765482 commit 5754c2f

File tree

2 files changed

+90
-0
lines changed

2 files changed

+90
-0
lines changed

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

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,52 @@ var GatewayWithAttachedRoutes = suite.ConformanceTest{
9090

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

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)