Merge pull request #121913 from liggitt/testing-dep
Drop testing dependency from shipped binaries
This commit is contained in:
		| @@ -22,7 +22,6 @@ import ( | |||||||
| 	"net/url" | 	"net/url" | ||||||
| 	"reflect" | 	"reflect" | ||||||
| 	"sync" | 	"sync" | ||||||
| 	"testing" |  | ||||||
| 	"time" | 	"time" | ||||||
|  |  | ||||||
| 	v1 "k8s.io/api/core/v1" | 	v1 "k8s.io/api/core/v1" | ||||||
| @@ -33,6 +32,10 @@ import ( | |||||||
| 	"k8s.io/kubernetes/pkg/volume" | 	"k8s.io/kubernetes/pkg/volume" | ||||||
| ) | ) | ||||||
|  |  | ||||||
|  | type TB interface { | ||||||
|  | 	Errorf(format string, args ...any) | ||||||
|  | } | ||||||
|  |  | ||||||
| type FakePod struct { | type FakePod struct { | ||||||
| 	Pod       *kubecontainer.Pod | 	Pod       *kubecontainer.Pod | ||||||
| 	NetnsPath string | 	NetnsPath string | ||||||
| @@ -65,7 +68,7 @@ type FakeRuntime struct { | |||||||
| 	// from container runtime. | 	// from container runtime. | ||||||
| 	BlockImagePulls      bool | 	BlockImagePulls      bool | ||||||
| 	imagePullTokenBucket chan bool | 	imagePullTokenBucket chan bool | ||||||
| 	T                    *testing.T | 	T                    TB | ||||||
| } | } | ||||||
|  |  | ||||||
| const FakeHost = "localhost:12345" | const FakeHost = "localhost:12345" | ||||||
|   | |||||||
| @@ -19,7 +19,6 @@ package testutil | |||||||
| import ( | import ( | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"io" | 	"io" | ||||||
| 	"testing" |  | ||||||
|  |  | ||||||
| 	"github.com/prometheus/client_golang/prometheus/testutil" | 	"github.com/prometheus/client_golang/prometheus/testutil" | ||||||
|  |  | ||||||
| @@ -28,6 +27,12 @@ import ( | |||||||
| 	"k8s.io/component-base/metrics/legacyregistry" | 	"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 | // CollectAndCompare registers the provided Collector with a newly created | ||||||
| // pedantic Registry. It then does the same as GatherAndCompare, gathering the | // pedantic Registry. It then does the same as GatherAndCompare, gathering the | ||||||
| // metrics from the pedantic Registry. | // metrics from the pedantic Registry. | ||||||
| @@ -94,7 +99,7 @@ func NewFakeKubeRegistry(ver string) metrics.KubeRegistry { | |||||||
| 	return metrics.NewKubeRegistry() | 	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() | 	metrics, err := legacyregistry.DefaultGatherer.Gather() | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("Failed to gather metrics: %s", err) | 		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() | 	metrics, err := legacyregistry.DefaultGatherer.Gather() | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("Failed to gather metrics: %s", err) | 		t.Fatalf("Failed to gather metrics: %s", err) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Kubernetes Prow Robot
					Kubernetes Prow Robot