mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 10:33:35 +00:00
rebase: update kubernetes to 1.28.0 in main
updating kubernetes to 1.28.0 in the main repo. Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
committed by
mergify[bot]
parent
b2fdc269c3
commit
ff3e84ad67
61
vendor/k8s.io/component-base/metrics/testutil/testutil.go
generated
vendored
61
vendor/k8s.io/component-base/metrics/testutil/testutil.go
generated
vendored
@ -19,11 +19,13 @@ package testutil
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"testing"
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus/testutil"
|
||||
|
||||
apimachineryversion "k8s.io/apimachinery/pkg/version"
|
||||
"k8s.io/component-base/metrics"
|
||||
"k8s.io/component-base/metrics/legacyregistry"
|
||||
)
|
||||
|
||||
// CollectAndCompare registers the provided Collector with a newly created
|
||||
@ -91,3 +93,62 @@ func NewFakeKubeRegistry(ver string) metrics.KubeRegistry {
|
||||
|
||||
return metrics.NewKubeRegistry()
|
||||
}
|
||||
|
||||
func AssertVectorCount(t *testing.T, name string, labelFilter map[string]string, wantCount int) {
|
||||
metrics, err := legacyregistry.DefaultGatherer.Gather()
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to gather metrics: %s", err)
|
||||
}
|
||||
|
||||
counterSum := 0
|
||||
for _, mf := range metrics {
|
||||
if mf.GetName() != name {
|
||||
continue // Ignore other metrics.
|
||||
}
|
||||
for _, metric := range mf.GetMetric() {
|
||||
if !LabelsMatch(metric, labelFilter) {
|
||||
continue
|
||||
}
|
||||
counterSum += int(metric.GetCounter().GetValue())
|
||||
}
|
||||
}
|
||||
if wantCount != counterSum {
|
||||
t.Errorf("Wanted count %d, got %d for metric %s with labels %#+v", wantCount, counterSum, name, labelFilter)
|
||||
for _, mf := range metrics {
|
||||
if mf.GetName() == name {
|
||||
for _, metric := range mf.GetMetric() {
|
||||
t.Logf("\tnear match: %s", metric.String())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func AssertHistogramTotalCount(t *testing.T, name string, labelFilter map[string]string, wantCount int) {
|
||||
metrics, err := legacyregistry.DefaultGatherer.Gather()
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to gather metrics: %s", err)
|
||||
}
|
||||
counterSum := 0
|
||||
for _, mf := range metrics {
|
||||
if mf.GetName() != name {
|
||||
continue // Ignore other metrics.
|
||||
}
|
||||
for _, metric := range mf.GetMetric() {
|
||||
if !LabelsMatch(metric, labelFilter) {
|
||||
continue
|
||||
}
|
||||
counterSum += int(metric.GetHistogram().GetSampleCount())
|
||||
}
|
||||
}
|
||||
if wantCount != counterSum {
|
||||
t.Errorf("Wanted count %d, got %d for metric %s with labels %#+v", wantCount, counterSum, name, labelFilter)
|
||||
for _, mf := range metrics {
|
||||
if mf.GetName() == name {
|
||||
for _, metric := range mf.GetMetric() {
|
||||
t.Logf("\tnear match: %s\n", metric.String())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user