@@ -14,7 +14,6 @@ import (
14
14
v1 "sigs.k8s.io/gateway-api/apis/v1"
15
15
16
16
ngfAPI "github.com/nginx/nginx-gateway-fabric/v2/apis/v1alpha1"
17
- "github.com/nginx/nginx-gateway-fabric/v2/internal/controller/state/conditions"
18
17
"github.com/nginx/nginx-gateway-fabric/v2/tests/framework"
19
18
)
20
19
@@ -28,7 +27,8 @@ var _ = Describe("SnippetsFilter", Ordered, Label("functional", "snippets-filter
28
27
29
28
namespace = "snippets-filter"
30
29
31
- nginxPodName string
30
+ nginxPodName string
31
+ gatewayNsName = types.NamespacedName {Name : "gateway" , Namespace : namespace }
32
32
)
33
33
34
34
BeforeAll (func () {
@@ -234,9 +234,8 @@ var _ = Describe("SnippetsFilter", Ordered, Label("functional", "snippets-filter
234
234
235
235
Expect (resourceManager .ApplyFromFiles (files , namespace )).To (Succeed ())
236
236
237
- nsname := types.NamespacedName {Name : "tea" , Namespace : namespace }
238
- Eventually (checkHTTPRouteToHaveGatewayNotProgrammedCond ).
239
- WithArguments (nsname ).
237
+ Eventually (checkGatewayToHaveGatewayNotProgrammedCond ).
238
+ WithArguments (gatewayNsName ).
240
239
WithTimeout (timeoutConfig .GetStatusTimeout ).
241
240
WithPolling (500 * time .Millisecond ).
242
241
Should (Succeed ())
@@ -249,9 +248,8 @@ var _ = Describe("SnippetsFilter", Ordered, Label("functional", "snippets-filter
249
248
250
249
Expect (resourceManager .ApplyFromFiles (files , namespace )).To (Succeed ())
251
250
252
- nsname := types.NamespacedName {Name : "soda" , Namespace : namespace }
253
- Eventually (checkHTTPRouteToHaveGatewayNotProgrammedCond ).
254
- WithArguments (nsname ).
251
+ Eventually (checkGatewayToHaveGatewayNotProgrammedCond ).
252
+ WithArguments (gatewayNsName ).
255
253
WithTimeout (timeoutConfig .GetStatusTimeout ).
256
254
WithPolling (500 * time .Millisecond ).
257
255
Should (Succeed ())
@@ -261,40 +259,38 @@ var _ = Describe("SnippetsFilter", Ordered, Label("functional", "snippets-filter
261
259
})
262
260
})
263
261
264
- func checkHTTPRouteToHaveGatewayNotProgrammedCond ( httpRouteNsName types.NamespacedName ) error {
262
+ func checkGatewayToHaveGatewayNotProgrammedCond ( gatewayNsName types.NamespacedName ) error {
265
263
ctx , cancel := context .WithTimeout (context .Background (), timeoutConfig .GetTimeout )
266
264
defer cancel ()
267
265
268
266
GinkgoWriter .Printf (
269
- "Checking for HTTPRoute %q to have the condition Accepted/True/GatewayNotProgrammed \n " ,
270
- httpRouteNsName ,
267
+ "Checking for Gateway %q to have the condition Programmed/False/Invalid \n " ,
268
+ gatewayNsName ,
271
269
)
272
270
273
- var hr v1.HTTPRoute
271
+ var gw v1.Gateway
274
272
var err error
275
273
276
- if err = resourceManager .Get (ctx , httpRouteNsName , & hr ); err != nil {
274
+ if err = resourceManager .Get (ctx , gatewayNsName , & gw ); err != nil {
277
275
return err
278
276
}
279
277
280
- if len (hr .Status .Parents ) != 1 {
281
- tooManyParentStatusesErr := fmt .Errorf ("httproute has %d parent statuses, expected 1" , len (hr .Status .Parents ))
282
- GinkgoWriter .Printf ("ERROR: %v\n " , tooManyParentStatusesErr )
283
-
284
- return tooManyParentStatusesErr
285
- }
286
-
287
- parent := hr .Status .Parents [0 ]
288
- if parent .Conditions == nil {
289
- nilConditionErr := fmt .Errorf ("expected parent conditions to not be nil" )
278
+ gwStatus := gw .Status
279
+ if gwStatus .Conditions == nil {
280
+ nilConditionErr := fmt .Errorf ("expected gateway conditions to not be nil" )
290
281
GinkgoWriter .Printf ("ERROR: %v\n " , nilConditionErr )
291
282
292
283
return nilConditionErr
293
284
}
294
285
295
- cond := parent .Conditions [1 ]
296
- if cond .Type != string (v1 .GatewayConditionAccepted ) {
297
- wrongTypeErr := fmt .Errorf ("expected condition type to be Accepted, got %s" , cond .Type )
286
+ for i := range gwStatus .Conditions {
287
+ GinkgoWriter .Printf ("Gateway condition %d: Type=%s, Status=%s, Reason=%s\n " ,
288
+ i , gwStatus .Conditions [i ].Type , gwStatus .Conditions [i ].Status , gwStatus .Conditions [i ].Reason )
289
+ }
290
+
291
+ cond := gwStatus .Conditions [1 ]
292
+ if cond .Type != string (v1 .GatewayConditionProgrammed ) {
293
+ wrongTypeErr := fmt .Errorf ("expected condition type to be Programmed, got %s" , cond .Type )
298
294
GinkgoWriter .Printf ("ERROR: %v\n " , wrongTypeErr )
299
295
300
296
return wrongTypeErr
@@ -307,8 +303,8 @@ func checkHTTPRouteToHaveGatewayNotProgrammedCond(httpRouteNsName types.Namespac
307
303
return wrongStatusErr
308
304
}
309
305
310
- if cond .Reason != string (conditions . RouteReasonGatewayNotProgrammed ) {
311
- wrongReasonErr := fmt .Errorf ("expected condition reason to be GatewayNotProgrammed , got %s" , cond .Reason )
306
+ if cond .Reason != string (v1 . GatewayReasonInvalid ) {
307
+ wrongReasonErr := fmt .Errorf ("expected condition reason to be GatewayReasonInvalid , got %s" , cond .Reason )
312
308
GinkgoWriter .Printf ("ERROR: %v\n " , wrongReasonErr )
313
309
314
310
return wrongReasonErr
0 commit comments