From c38746c353aad0cb631dc58d43aed865a18a59c0 Mon Sep 17 00:00:00 2001 From: Han Kang Date: Tue, 26 Jul 2022 11:15:56 -0700 Subject: [PATCH] add test for fake objectives Change-Id: Ib0bfdf1299cd74490474f92c41d93090809f41c4 --- test/instrumentation/main_test.go | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/test/instrumentation/main_test.go b/test/instrumentation/main_test.go index 0b8e10bd30e..bdb75b4b428 100644 --- a/test/instrumentation/main_test.go +++ b/test/instrumentation/main_test.go @@ -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