Commit b4ee4e2e authored by Solly Ross's avatar Solly Ross

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.
parent 0b43fffa
...@@ -360,8 +360,7 @@ func (tc *testCase) prepareTestClient(t *testing.T) (*fake.Clientset, *metricsfa ...@@ -360,8 +360,7 @@ func (tc *testCase) prepareTestClient(t *testing.T) (*fake.Clientset, *metricsfa
fakeClient.AddWatchReactor("*", core.DefaultWatchReactor(fakeWatch, nil)) fakeClient.AddWatchReactor("*", core.DefaultWatchReactor(fakeWatch, nil))
fakeMetricsClient := &metricsfake.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", "pods", func(action core.Action) (handled bool, ret runtime.Object, err error) {
fakeMetricsClient.AddReactor("list", "podmetricses", func(action core.Action) (handled bool, ret runtime.Object, err error) {
tc.Lock() tc.Lock()
defer tc.Unlock() defer tc.Unlock()
......
...@@ -74,7 +74,7 @@ func (tc *restClientTestCase) prepareTestClient(t *testing.T) (*metricsfake.Clie ...@@ -74,7 +74,7 @@ func (tc *restClientTestCase) prepareTestClient(t *testing.T) (*metricsfake.Clie
fakeCMClient := &cmfake.FakeCustomMetricsClient{} fakeCMClient := &cmfake.FakeCustomMetricsClient{}
if isResource { 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{} metrics := &metricsapi.PodMetricsList{}
for i, containers := range tc.reportedPodMetrics { for i, containers := range tc.reportedPodMetrics {
metric := metricsapi.PodMetrics{ metric := metricsapi.PodMetrics{
......
...@@ -135,7 +135,7 @@ func (tc *replicaCalcTestCase) prepareTestClient(t *testing.T) (*fake.Clientset, ...@@ -135,7 +135,7 @@ func (tc *replicaCalcTestCase) prepareTestClient(t *testing.T) (*fake.Clientset,
fakeMetricsClient := &metricsfake.Clientset{} fakeMetricsClient := &metricsfake.Clientset{}
// NB: we have to sound like Gollum due to gengo's inability to handle already-plural resource names // 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 { if tc.resource != nil {
metrics := &metricsapi.PodMetricsList{} metrics := &metricsapi.PodMetricsList{}
for i, resValue := range tc.resource.levels { for i, resValue := range tc.resource.levels {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment