From b4ee4e2e803eaf9250263375ff14c2de5a086477 Mon Sep 17 00:00:00 2001 From: Solly Ross Date: Wed, 3 May 2017 18:11:22 -0400 Subject: [PATCH] Fix HPA unit tests with new fake client The new fake client properly represents the resource of `PodMetrics` as "pods" and the resource of `NodeMetrics` as "nodes". Previously, it used "podmetricses" and "nodemetrics", respectively. This fixes up `horizontal_test.go` and `replica_calc_test.go` to use the new names. --- pkg/controller/podautoscaler/horizontal_test.go | 3 +-- .../podautoscaler/metrics/rest_metrics_client_test.go | 2 +- pkg/controller/podautoscaler/replica_calculator_test.go | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/pkg/controller/podautoscaler/horizontal_test.go b/pkg/controller/podautoscaler/horizontal_test.go index e58e5fbd9e..e70fdaec22 100644 --- a/pkg/controller/podautoscaler/horizontal_test.go +++ b/pkg/controller/podautoscaler/horizontal_test.go @@ -360,8 +360,7 @@ func (tc *testCase) prepareTestClient(t *testing.T) (*fake.Clientset, *metricsfa fakeClient.AddWatchReactor("*", core.DefaultWatchReactor(fakeWatch, nil)) fakeMetricsClient := &metricsfake.Clientset{} - // NB: we have to sound like Gollum due to gengo's inability to handle already-plural resource names - fakeMetricsClient.AddReactor("list", "podmetricses", func(action core.Action) (handled bool, ret runtime.Object, err error) { + fakeMetricsClient.AddReactor("list", "pods", func(action core.Action) (handled bool, ret runtime.Object, err error) { tc.Lock() defer tc.Unlock() diff --git a/pkg/controller/podautoscaler/metrics/rest_metrics_client_test.go b/pkg/controller/podautoscaler/metrics/rest_metrics_client_test.go index 7ded3de6c3..0490135a5e 100644 --- a/pkg/controller/podautoscaler/metrics/rest_metrics_client_test.go +++ b/pkg/controller/podautoscaler/metrics/rest_metrics_client_test.go @@ -74,7 +74,7 @@ func (tc *restClientTestCase) prepareTestClient(t *testing.T) (*metricsfake.Clie fakeCMClient := &cmfake.FakeCustomMetricsClient{} if isResource { - fakeMetricsClient.AddReactor("list", "podmetricses", func(action core.Action) (handled bool, ret runtime.Object, err error) { + fakeMetricsClient.AddReactor("list", "pods", func(action core.Action) (handled bool, ret runtime.Object, err error) { metrics := &metricsapi.PodMetricsList{} for i, containers := range tc.reportedPodMetrics { metric := metricsapi.PodMetrics{ diff --git a/pkg/controller/podautoscaler/replica_calculator_test.go b/pkg/controller/podautoscaler/replica_calculator_test.go index c37b61494b..04418b5b07 100644 --- a/pkg/controller/podautoscaler/replica_calculator_test.go +++ b/pkg/controller/podautoscaler/replica_calculator_test.go @@ -135,7 +135,7 @@ func (tc *replicaCalcTestCase) prepareTestClient(t *testing.T) (*fake.Clientset, fakeMetricsClient := &metricsfake.Clientset{} // NB: we have to sound like Gollum due to gengo's inability to handle already-plural resource names - fakeMetricsClient.AddReactor("list", "podmetricses", func(action core.Action) (handled bool, ret runtime.Object, err error) { + fakeMetricsClient.AddReactor("list", "pods", func(action core.Action) (handled bool, ret runtime.Object, err error) { if tc.resource != nil { metrics := &metricsapi.PodMetricsList{} for i, resValue := range tc.resource.levels {