mirror of https://github.com/k3s-io/k3s
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.pull/6/head
parent
0b43fffa48
commit
b4ee4e2e80
|
@ -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()
|
||||
|
||||
|
|
|
@ -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{
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue