Skip to content

Commit add9986

Browse files
pacoxuk8s-publishing-bot
authored andcommitted
fix histogram vec compare using ignore fields
Kubernetes-commit: 171b19d9fe1519355e0641012ef8d0115f90ed58
1 parent 77c6a2c commit add9986

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

metrics/testutil/metrics_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"testing"
2424

2525
"github.com/google/go-cmp/cmp"
26+
"github.com/google/go-cmp/cmp/cmpopts"
2627
dto "github.com/prometheus/client_model/go"
2728
"k8s.io/component-base/metrics"
2829
"k8s.io/utils/pointer"
@@ -584,7 +585,7 @@ func TestGetHistogramVecFromGatherer(t *testing.T) {
584585
vec.WithLabelValues("value1-1", "value2-1").Observe(4.5)
585586
metricName := fmt.Sprintf("%s_%s_%s", HistogramOpts.Namespace, HistogramOpts.Subsystem, HistogramOpts.Name)
586587
histogramVec, _ := GetHistogramVecFromGatherer(gather, metricName, tt.lvMap)
587-
if diff := cmp.Diff(tt.wantVec, histogramVec); diff != "" {
588+
if diff := cmp.Diff(tt.wantVec, histogramVec, cmpopts.IgnoreFields(dto.Histogram{}, "state", "sizeCache", "unknownFields"), cmpopts.IgnoreFields(dto.Bucket{}, "state", "sizeCache", "unknownFields")); diff != "" {
588589
t.Errorf("Got unexpected HistogramVec (-want +got):\n%s", diff)
589590
}
590591
})

0 commit comments

Comments
 (0)