add test for fake objectives

Change-Id: Ib0bfdf1299cd74490474f92c41d93090809f41c4
This commit is contained in:
Han Kang 2022-07-26 11:15:56 -07:00
parent cefa194998
commit c38746c353

View File

@ -696,7 +696,7 @@ var _ = metrics.NewCounter(
)
`},
{
testName: "error stable historgram with unknown prometheus bucket variable",
testName: "error stable histogram with unknown prometheus bucket variable",
err: fmt.Errorf("testdata/metric.go:9:13: Buckets should be set to list of floats, result from function call of prometheus.LinearBuckets or prometheus.ExponentialBuckets"),
src: `
package test
@ -711,7 +711,22 @@ var _ = metrics.NewHistogram(
)
`},
{
testName: "error stable historgram with unknown bucket variable",
testName: "error stable summary with unknown prometheus objective variable",
err: fmt.Errorf("testdata/metric.go:9:16: Objectives should be set to map of floats to floats"),
src: `
package test
import "k8s.io/component-base/metrics"
import "github.com/prometheus/client_golang/prometheus"
var _ = metrics.NewSummary(
&metrics.SummaryOpts{
Name: "summary",
StabilityLevel: metrics.STABLE,
Objectives: prometheus.FakeObjectives,
},
)
`},
{
testName: "error stable histogram with unknown bucket variable",
err: fmt.Errorf("testdata/metric.go:9:13: Buckets should be set to list of floats, result from function call of prometheus.LinearBuckets or prometheus.ExponentialBuckets"),
src: `
package test