@@ -594,21 +594,21 @@ func waitForIndividualRouteMetrics(t *testing.T, metrics *metricstest.MockMetric
594594 }
595595}
596596
597- func TestRouteMetricsSetToZeroWhenFixed (t * testing.T ) {
597+ func TestRouteMetricsStaySetWhenRouteIsFixed (t * testing.T ) {
598598 t .Run ("MockMetrics" , func (t * testing.T ) {
599599 synctest .Test (t , func (t * testing.T ) {
600- testRouteMetricsSetToZeroWhenFixedWithMock (t )
600+ testRouteMetricsStaySetWhenRouteIsFixedWithMock (t )
601601 })
602602 })
603603
604604 t .Run ("Prometheus" , func (t * testing.T ) {
605605 synctest .Test (t , func (t * testing.T ) {
606- testRouteMetricsSetToZeroWhenFixedWithPrometheus (t )
606+ testRouteMetricsStaySetWhenRouteIsFixedWithPrometheus (t )
607607 })
608608 })
609609}
610610
611- func testRouteMetricsSetToZeroWhenFixedWithMock (t * testing.T ) {
611+ func testRouteMetricsStaySetWhenRouteIsFixedWithMock (t * testing.T ) {
612612 metrics := & metricstest.MockMetrics {}
613613
614614 // Start with an invalid route
@@ -649,16 +649,16 @@ func testRouteMetricsSetToZeroWhenFixedWithMock(t *testing.T) {
649649 // Wait for the update to be processed
650650 time .Sleep (50 * time .Millisecond )
651651
652- // Verify the metric is now set to 0 (not deleted)
652+ // Verify the metric remains set (not deleted or zeroed out )
653653 metrics .WithGauges (func (gauges map [string ]float64 ) {
654654 expectedKey := "route.invalid.invalidBackend1..failed_backend_split"
655- if gauges [expectedKey ] != 0 {
656- t .Errorf ("Expected invalid route metric to be set to 0 when route becomes valid, got %f" , gauges [expectedKey ])
655+ if gauges [expectedKey ] != 1 {
656+ t .Errorf ("Expected invalid route metric to stay set when route becomes valid, got %f" , gauges [expectedKey ])
657657 }
658658 })
659659}
660660
661- func testRouteMetricsSetToZeroWhenFixedWithPrometheus (t * testing.T ) {
661+ func testRouteMetricsStaySetWhenRouteIsFixedWithPrometheus (t * testing.T ) {
662662 pm := metrics .NewPrometheus (metrics.Options {})
663663 path := "/metrics"
664664
@@ -708,16 +708,16 @@ func testRouteMetricsSetToZeroWhenFixedWithPrometheus(t *testing.T) {
708708 // Wait for the update to be processed
709709 time .Sleep (50 * time .Millisecond )
710710
711- // Check that the metric is now set to 0
711+ // Check that the metric stays set (not deleted or zeroed out)
712712 req = httptest .NewRequest ("GET" , path , nil )
713713 w = httptest .NewRecorder ()
714714 mux .ServeHTTP (w , req )
715715 body , _ = io .ReadAll (w .Result ().Body )
716716 output = string (body )
717717
718- expectedZeroLine : = `skipper_route_invalid{reason="failed_backend_split",route_id="invalidBackend1"} 0 `
719- if ! strings .Contains (output , expectedZeroLine ) {
720- t .Errorf ("Expected to find invalid route metric set to 0 when route becomes valid" )
718+ expectedLine = `skipper_route_invalid{reason="failed_backend_split",route_id="invalidBackend1"} 1 `
719+ if ! strings .Contains (output , expectedLine ) {
720+ t .Errorf ("Expected invalid route metric to remain set when route becomes valid" )
721721 t .Logf ("Output: %s" , output )
722722 }
723723}
0 commit comments