@@ -11,6 +11,7 @@ import (
11
11
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
12
12
"k8s.io/apimachinery/pkg/types"
13
13
gwv1 "sigs.k8s.io/gateway-api/apis/v1"
14
+ gwv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2"
14
15
15
16
"github.com/solo-io/gloo/projects/gateway2/reports"
16
17
)
@@ -115,7 +116,7 @@ var _ = DescribeTable("Basic GatewayTranslator Tests",
115
116
Name : "example-gateway" ,
116
117
}}),
117
118
Entry (
118
- "route with missing backend reports correctly" ,
119
+ "httproute with missing backend reports correctly" ,
119
120
translatorTestCase {
120
121
inputFile : "http-routing-missing-backend" ,
121
122
outputFile : "http-routing-missing-backend.yaml" ,
@@ -139,7 +140,7 @@ var _ = DescribeTable("Basic GatewayTranslator Tests",
139
140
},
140
141
}),
141
142
Entry (
142
- "route with invalid backend reports correctly" ,
143
+ "httproute with invalid backend reports correctly" ,
143
144
translatorTestCase {
144
145
inputFile : "http-routing-invalid-backend" ,
145
146
outputFile : "http-routing-invalid-backend.yaml" ,
@@ -181,6 +182,71 @@ var _ = DescribeTable("Basic GatewayTranslator Tests",
181
182
Namespace : "default" ,
182
183
Name : "example-gateway" ,
183
184
},
185
+ assertReports : func (gwNN types.NamespacedName , reportsMap reports.ReportMap ) {
186
+ route := & gwv1a2.TCPRoute {
187
+ ObjectMeta : metav1.ObjectMeta {
188
+ Name : "example-tcp-route" ,
189
+ Namespace : "default" ,
190
+ },
191
+ }
192
+ routeStatus := reportsMap .BuildRouteStatus (context .TODO (), route , "" )
193
+ Expect (routeStatus ).NotTo (BeNil ())
194
+ Expect (routeStatus .Parents ).To (HaveLen (1 ))
195
+ resolvedRefs := meta .FindStatusCondition (routeStatus .Parents [0 ].Conditions , string (gwv1 .RouteConditionResolvedRefs ))
196
+ Expect (resolvedRefs ).NotTo (BeNil ())
197
+ Expect (resolvedRefs .Status ).To (Equal (metav1 .ConditionTrue ))
198
+ Expect (resolvedRefs .Reason ).To (Equal (string (gwv1 .RouteReasonResolvedRefs )))
199
+ },
200
+ }),
201
+ Entry (
202
+ "tcproute with missing backend reports correctly" ,
203
+ translatorTestCase {
204
+ inputFile : "tcp-routing/missing-backend.yaml" ,
205
+ outputFile : "tcp-routing/missing-backend.yaml" ,
206
+ gwNN : types.NamespacedName {
207
+ Namespace : "default" ,
208
+ Name : "example-gateway" ,
209
+ },
210
+ assertReports : func (gwNN types.NamespacedName , reportsMap reports.ReportMap ) {
211
+ route := & gwv1a2.TCPRoute {
212
+ ObjectMeta : metav1.ObjectMeta {
213
+ Name : "example-tcp-route" ,
214
+ Namespace : "default" ,
215
+ },
216
+ }
217
+ routeStatus := reportsMap .BuildRouteStatus (context .TODO (), route , "" )
218
+ Expect (routeStatus ).NotTo (BeNil ())
219
+ Expect (routeStatus .Parents ).To (HaveLen (1 ))
220
+ resolvedRefs := meta .FindStatusCondition (routeStatus .Parents [0 ].Conditions , string (gwv1 .RouteConditionResolvedRefs ))
221
+ Expect (resolvedRefs ).NotTo (BeNil ())
222
+ Expect (resolvedRefs .Status ).To (Equal (metav1 .ConditionFalse ))
223
+ Expect (resolvedRefs .Message ).To (Equal ("services \" example-tcp-svc\" not found" ))
224
+ },
225
+ }),
226
+ Entry (
227
+ "tcproute with invalid backend reports correctly" ,
228
+ translatorTestCase {
229
+ inputFile : "tcp-routing/invalid-backend.yaml" ,
230
+ outputFile : "tcp-routing/invalid-backend.yaml" ,
231
+ gwNN : types.NamespacedName {
232
+ Namespace : "default" ,
233
+ Name : "example-gateway" ,
234
+ },
235
+ assertReports : func (gwNN types.NamespacedName , reportsMap reports.ReportMap ) {
236
+ route := & gwv1a2.TCPRoute {
237
+ ObjectMeta : metav1.ObjectMeta {
238
+ Name : "example-tcp-route" ,
239
+ Namespace : "default" ,
240
+ },
241
+ }
242
+ routeStatus := reportsMap .BuildRouteStatus (context .TODO (), route , "" )
243
+ Expect (routeStatus ).NotTo (BeNil ())
244
+ Expect (routeStatus .Parents ).To (HaveLen (1 ))
245
+ resolvedRefs := meta .FindStatusCondition (routeStatus .Parents [0 ].Conditions , string (gwv1 .RouteConditionResolvedRefs ))
246
+ Expect (resolvedRefs ).NotTo (BeNil ())
247
+ Expect (resolvedRefs .Status ).To (Equal (metav1 .ConditionFalse ))
248
+ Expect (resolvedRefs .Message ).To (Equal ("unknown backend kind" ))
249
+ },
184
250
}),
185
251
Entry (
186
252
"tcp gateway with multiple backend services" ,
0 commit comments