@@ -528,7 +528,7 @@ var _ = Describe("eventHandler", func() {
528528 poolUID1 := types .UID ("uid1" )
529529 poolUID2 := types .UID ("uid2" )
530530
531- fakeProcessor . ProcessReturns ( & graph.Graph {
531+ g := & graph.Graph {
532532 Gateways : map [types.NamespacedName ]* graph.Gateway {
533533 {}: {
534534 Source : & gatewayv1.Gateway {
@@ -576,7 +576,9 @@ var _ = Describe("eventHandler", func() {
576576 },
577577 },
578578 },
579- })
579+ }
580+
581+ fakeProcessor .ProcessReturns (g )
580582
581583 e := & events.UpsertEvent {Resource : & gatewayv1.HTTPRoute {}}
582584 batch := []any {e }
@@ -608,6 +610,37 @@ var _ = Describe("eventHandler", func() {
608610 Expect (svc2 .OwnerReferences ).To (HaveLen (1 ))
609611 Expect (svc2 .OwnerReferences [0 ].Name ).To (Equal (poolName2 ))
610612 Expect (svc2 .OwnerReferences [0 ].UID ).To (Equal (poolUID2 ))
613+
614+ // Now update pool1's selector and ensure the Service selector is updated
615+ updatedSelector := map [inference.LabelKey ]inference.LabelValue {"app" : "baz" }
616+ updatedPool := & inference.InferencePool {
617+ ObjectMeta : metav1.ObjectMeta {
618+ Name : poolName1 ,
619+ Namespace : namespace ,
620+ UID : poolUID1 ,
621+ },
622+ Spec : inference.InferencePoolSpec {
623+ Selector : inference.LabelSelector {
624+ MatchLabels : updatedSelector ,
625+ },
626+ TargetPorts : []inference.Port {
627+ {Number : 8081 },
628+ },
629+ },
630+ }
631+ // Simulate the updated pool in the graph
632+ g .ReferencedInferencePools [types.NamespacedName {Namespace : namespace , Name : poolName1 }].Source = updatedPool
633+ fakeProcessor .ProcessReturns (g )
634+
635+ e = & events.UpsertEvent {Resource : & inference.InferencePool {}}
636+ batch = []any {e }
637+ handler .HandleEventBatch (context .Background (), logr .Discard (), batch )
638+
639+ // Check that the Service selector was updated
640+ svc1 = & v1.Service {}
641+ err = fakeK8sClient .Get (context .Background (), types.NamespacedName {Name : svcName1 , Namespace : namespace }, svc1 )
642+ Expect (err ).ToNot (HaveOccurred ())
643+ Expect (svc1 .Spec .Selector ).To (HaveKeyWithValue ("app" , "baz" ))
611644 })
612645
613646 It ("should panic for an unknown event type" , func () {
0 commit comments