@@ -28,7 +28,6 @@ import (
2828 "github.com/stretchr/testify/assert"
2929 "github.com/stretchr/testify/require"
3030 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
31- "k8s.io/utils/ptr"
3231
3332 flaggerv1 "github.com/fluxcd/flagger/pkg/apis/flagger/v1beta1"
3433 v1 "github.com/fluxcd/flagger/pkg/apis/gatewayapi/v1"
@@ -643,106 +642,3 @@ func TestGatewayAPIRouter_makeFilters_CORS(t *testing.T) {
643642 // Assert MaxAge (24h = 86400 seconds)
644643 assert .Equal (t , int32 (86400 ), corsFilter .CORS .MaxAge )
645644}
646-
647- func TestGatewayAPIRouter_GetRoutes (t * testing.T ) {
648- canary := newTestGatewayAPICanary ()
649- mocks := newFixture (canary )
650- router := & GatewayAPIRouter {
651- gatewayAPIClient : mocks .meshClient ,
652- kubeClient : mocks .kubeClient ,
653- logger : mocks .logger ,
654- }
655-
656- httpRoute := & v1.HTTPRoute {
657- ObjectMeta : metav1.ObjectMeta {
658- Name : "podinfo" ,
659- Generation : 1 ,
660- },
661- Spec : v1.HTTPRouteSpec {
662- Rules : []v1.HTTPRouteRule {
663- {
664- BackendRefs : []v1.HTTPBackendRef {
665- {
666- BackendRef : v1.BackendRef {
667- BackendObjectReference : v1.BackendObjectReference {
668- Name : "podinfo-canary" ,
669- },
670- Weight : ptr .To (int32 (10 )),
671- },
672- },
673- {
674- BackendRef : v1.BackendRef {
675- BackendObjectReference : v1.BackendObjectReference {
676- Name : "podinfo-primary" ,
677- },
678- Weight : ptr .To (int32 (90 )),
679- },
680- },
681- },
682- },
683- },
684- CommonRouteSpec : v1.CommonRouteSpec {
685- ParentRefs : []v1.ParentReference {
686- {
687- Name : "podinfo" ,
688- },
689- },
690- },
691- },
692- }
693- httpRoute , err := router .gatewayAPIClient .GatewayapiV1 ().HTTPRoutes ("default" ).Create (context .TODO (), httpRoute , metav1.CreateOptions {})
694- require .NoError (t , err )
695-
696- t .Run ("httproute generation" , func (t * testing.T ) {
697- httpRoute .ObjectMeta .Generation = 5
698- httpRoute .Status .Parents = []v1.RouteParentStatus {
699- {
700- ParentRef : v1.ParentReference {
701- Name : "podinfo" ,
702- SectionName : ptr .To (v1 .SectionName ("https" )),
703- },
704- Conditions : []metav1.Condition {
705- {
706- Type : string (v1 .RouteConditionAccepted ),
707- Status : metav1 .ConditionTrue ,
708- ObservedGeneration : 1 ,
709- },
710- },
711- },
712- {
713- ParentRef : v1.ParentReference {
714- Name : "podinfo" ,
715- },
716- Conditions : []metav1.Condition {
717- {
718- Type : string (v1 .RouteConditionAccepted ),
719- Status : metav1 .ConditionFalse ,
720- ObservedGeneration : 4 ,
721- },
722- },
723- },
724- }
725- httpRoute , err := router .gatewayAPIClient .GatewayapiV1 ().HTTPRoutes ("default" ).Update (context .TODO (), httpRoute , metav1.UpdateOptions {})
726- require .NoError (t , err )
727-
728- _ , _ , _ , err = router .GetRoutes (canary )
729- require .Error (t , err )
730-
731- httpRoute .Status .Parents [1 ].Conditions [0 ].ObservedGeneration = 5
732- _ , err = router .gatewayAPIClient .GatewayapiV1 ().HTTPRoutes ("default" ).Update (context .TODO (), httpRoute , metav1.UpdateOptions {})
733- require .NoError (t , err )
734-
735- _ , _ , _ , err = router .GetRoutes (canary )
736- require .Error (t , err )
737-
738- httpRoute .Status .Parents [1 ].Conditions [0 ].Status = metav1 .ConditionTrue
739- _ , err = router .gatewayAPIClient .GatewayapiV1 ().HTTPRoutes ("default" ).Update (context .TODO (), httpRoute , metav1.UpdateOptions {})
740- require .NoError (t , err )
741-
742- primaryWeight , canaryWeight , mirrored , err := router .GetRoutes (canary )
743- require .NoError (t , err )
744- assert .Equal (t , 90 , primaryWeight )
745- assert .Equal (t , 10 , canaryWeight )
746- assert .False (t , mirrored )
747- })
748- }
0 commit comments