@@ -698,6 +698,40 @@ var _ = Describe("RouteRegistry", func() {
698698 Expect (found ).To (BeTrue (), "expected DeleteEndpointsPerPool to be called for the switched route" )
699699 })
700700
701+ It ("deletes the HB metric when the HB algorithm is removed and endpoint registers with empty algorithm" , func () {
702+ hbEndpoint := route .NewEndpoint (& route.EndpointOpts {
703+ Host : "192.168.1.1" ,
704+ Port : 8080 ,
705+ PrivateInstanceId : "id-1" ,
706+ LoadBalancingAlgorithm : config .LOAD_BALANCE_HB ,
707+ })
708+
709+ r .Register ("removed-hb.example.com" , hbEndpoint )
710+ Expect (reporter .CaptureEndpointsPerPoolCallCount ()).To (BeNumerically (">=" , 1 ))
711+
712+ // Endpoint re-registers with empty LB algorithm (HB setting removed from route)
713+ noAlgoEndpoint := route .NewEndpoint (& route.EndpointOpts {
714+ Host : "192.168.1.1" ,
715+ Port : 8080 ,
716+ PrivateInstanceId : "id-1" ,
717+ LoadBalancingAlgorithm : "" ,
718+ })
719+
720+ deleteBefore := reporter .DeleteEndpointsPerPoolCallCount ()
721+ r .Register ("removed-hb.example.com" , noAlgoEndpoint )
722+
723+ Expect (reporter .DeleteEndpointsPerPoolCallCount ()).To (BeNumerically (">" , deleteBefore ))
724+ found := false
725+ for i := deleteBefore ; i < reporter .DeleteEndpointsPerPoolCallCount (); i ++ {
726+ uri , algo := reporter .DeleteEndpointsPerPoolArgsForCall (i )
727+ if uri == "removed-hb.example.com" && algo == config .LOAD_BALANCE_HB {
728+ found = true
729+ break
730+ }
731+ }
732+ Expect (found ).To (BeTrue (), "expected DeleteEndpointsPerPool to be called when HB algorithm is removed" )
733+ })
734+
701735 It ("does not change the metric count when an existing HB endpoint is updated" , func () {
702736 hbEndpoint := route .NewEndpoint (& route.EndpointOpts {
703737 Host : "192.168.1.1" ,
0 commit comments