mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-14 14:23:37 +00:00
fix histogram vec compare using ignore fields
This commit is contained in:
parent
9b6af80a63
commit
171b19d9fe
@ -23,6 +23,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/google/go-cmp/cmp"
|
"github.com/google/go-cmp/cmp"
|
||||||
|
"github.com/google/go-cmp/cmp/cmpopts"
|
||||||
dto "github.com/prometheus/client_model/go"
|
dto "github.com/prometheus/client_model/go"
|
||||||
"k8s.io/component-base/metrics"
|
"k8s.io/component-base/metrics"
|
||||||
"k8s.io/utils/pointer"
|
"k8s.io/utils/pointer"
|
||||||
@ -584,7 +585,7 @@ func TestGetHistogramVecFromGatherer(t *testing.T) {
|
|||||||
vec.WithLabelValues("value1-1", "value2-1").Observe(4.5)
|
vec.WithLabelValues("value1-1", "value2-1").Observe(4.5)
|
||||||
metricName := fmt.Sprintf("%s_%s_%s", HistogramOpts.Namespace, HistogramOpts.Subsystem, HistogramOpts.Name)
|
metricName := fmt.Sprintf("%s_%s_%s", HistogramOpts.Namespace, HistogramOpts.Subsystem, HistogramOpts.Name)
|
||||||
histogramVec, _ := GetHistogramVecFromGatherer(gather, metricName, tt.lvMap)
|
histogramVec, _ := GetHistogramVecFromGatherer(gather, metricName, tt.lvMap)
|
||||||
if diff := cmp.Diff(tt.wantVec, histogramVec); diff != "" {
|
if diff := cmp.Diff(tt.wantVec, histogramVec, cmpopts.IgnoreFields(dto.Histogram{}, "state", "sizeCache", "unknownFields"), cmpopts.IgnoreFields(dto.Bucket{}, "state", "sizeCache", "unknownFields")); diff != "" {
|
||||||
t.Errorf("Got unexpected HistogramVec (-want +got):\n%s", diff)
|
t.Errorf("Got unexpected HistogramVec (-want +got):\n%s", diff)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user