Merge pull request #121913 from liggitt/testing-dep

Drop testing dependency from shipped binaries
This commit is contained in:
Kubernetes Prow Robot 2023-12-13 23:55:56 +01:00 committed by GitHub
commit 30bb24b1c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 5 deletions

View File

@ -22,7 +22,6 @@ import (
"net/url"
"reflect"
"sync"
"testing"
"time"
v1 "k8s.io/api/core/v1"
@ -33,6 +32,10 @@ import (
"k8s.io/kubernetes/pkg/volume"
)
type TB interface {
Errorf(format string, args ...any)
}
type FakePod struct {
Pod *kubecontainer.Pod
NetnsPath string
@ -65,7 +68,7 @@ type FakeRuntime struct {
// from container runtime.
BlockImagePulls bool
imagePullTokenBucket chan bool
T *testing.T
T TB
}
const FakeHost = "localhost:12345"

View File

@ -19,7 +19,6 @@ package testutil
import (
"fmt"
"io"
"testing"
"github.com/prometheus/client_golang/prometheus/testutil"
@ -28,6 +27,12 @@ import (
"k8s.io/component-base/metrics/legacyregistry"
)
type TB interface {
Logf(format string, args ...any)
Errorf(format string, args ...any)
Fatalf(format string, args ...any)
}
// CollectAndCompare registers the provided Collector with a newly created
// pedantic Registry. It then does the same as GatherAndCompare, gathering the
// metrics from the pedantic Registry.
@ -94,7 +99,7 @@ func NewFakeKubeRegistry(ver string) metrics.KubeRegistry {
return metrics.NewKubeRegistry()
}
func AssertVectorCount(t *testing.T, name string, labelFilter map[string]string, wantCount int) {
func AssertVectorCount(t TB, name string, labelFilter map[string]string, wantCount int) {
metrics, err := legacyregistry.DefaultGatherer.Gather()
if err != nil {
t.Fatalf("Failed to gather metrics: %s", err)
@ -124,7 +129,7 @@ func AssertVectorCount(t *testing.T, name string, labelFilter map[string]string,
}
}
func AssertHistogramTotalCount(t *testing.T, name string, labelFilter map[string]string, wantCount int) {
func AssertHistogramTotalCount(t TB, name string, labelFilter map[string]string, wantCount int) {
metrics, err := legacyregistry.DefaultGatherer.Gather()
if err != nil {
t.Fatalf("Failed to gather metrics: %s", err)