milvus/pkg/util/testutils/prometheus_metric.go
congqixia af315539d4
fix: Remove time tick delay metrics when nodes go offline (#30833)
See also #30832

This PR removes time tick delay metrics when rootcoord GetMetrics
response does not have previously existed querynode/datanode

Also add unit tests for this case

---------

Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
Signed-off-by: Congqi.Xia <congqi.xia@zilliz.com>
2024-02-28 10:10:56 +08:00

23 lines
726 B
Go

package testutils
import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/testutil"
"github.com/stretchr/testify/suite"
)
// PromMetricsSuite is a util suite wrapper providing prometheus metrics assertion functions.
type PromMetricsSuite struct {
suite.Suite
}
func (suite *PromMetricsSuite) MetricsEqual(c prometheus.Collector, expect float64, msgAndArgs ...any) bool {
value := testutil.ToFloat64(c)
return suite.Suite.Equal(expect, value, msgAndArgs...)
}
func (suite *PromMetricsSuite) CollectCntEqual(c prometheus.Collector, expect int, msgAndArgs ...any) bool {
cnt := testutil.CollectAndCount(c)
return suite.Suite.EqualValues(expect, cnt, msgAndArgs...)
}