From fdf07ba774549fc7bed6dfa94911a1c7ecc75098 Mon Sep 17 00:00:00 2001 From: Max Russell Date: Wed, 20 Nov 2024 14:56:42 -0800 Subject: [PATCH 1/2] fix: make some k8s tests pass --- master/internal/rm/kubernetesrm/jobs_test.go | 8 +++----- .../kubernetesrm/kubernetes_resource_manager_intg_test.go | 1 + 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/master/internal/rm/kubernetesrm/jobs_test.go b/master/internal/rm/kubernetesrm/jobs_test.go index 15d304e1a9d..453ffde8125 100644 --- a/master/internal/rm/kubernetesrm/jobs_test.go +++ b/master/internal/rm/kubernetesrm/jobs_test.go @@ -123,8 +123,7 @@ func TestListPodsInAllNamespaces(t *testing.T) { }, } - var expectedPods []k8sV1.Pod - copy(expectedPods, append(detPods, outsidePod)) + var expectedPods []k8sV1.Pod = append(detPods, outsidePod) expectedPodList := k8sV1.PodList{Items: expectedPods} emptyNS.On("List", mock.Anything, mock.Anything).Once(). Return(&k8sV1.PodList{Items: expectedPods}, nil) @@ -133,7 +132,7 @@ func TestListPodsInAllNamespaces(t *testing.T) { opts := metaV1.ListOptions{} actualPodList, err := js.listPodsInAllNamespaces(ctx, opts) require.NoError(t, err) - require.NotNil(t, actualPodList) + require.NotEmpty(t, actualPodList) require.ElementsMatch(t, expectedPodList.Items, actualPodList) forbiddenErr := k8error.NewForbidden(schema.GroupResource{}, "forbidden", @@ -204,8 +203,7 @@ func TestHealthStatus(t *testing.T) { }, } - var expectedPods []k8sV1.Pod - copy(expectedPods, append(detPods, outsidePod)) + var expectedPods []k8sV1.Pod = append(detPods, outsidePod) emptyNS.On("List", mock.Anything, mock.Anything).Once(). Return(&k8sV1.PodList{Items: expectedPods}, nil) diff --git a/master/internal/rm/kubernetesrm/kubernetes_resource_manager_intg_test.go b/master/internal/rm/kubernetesrm/kubernetes_resource_manager_intg_test.go index 55824f29a13..ab36f0b5e3e 100644 --- a/master/internal/rm/kubernetesrm/kubernetes_resource_manager_intg_test.go +++ b/master/internal/rm/kubernetesrm/kubernetes_resource_manager_intg_test.go @@ -778,6 +778,7 @@ func TestHealthCheck(t *testing.T) { jobsService: &jobsService{ podInterfaces: map[string]typedV1.PodInterface{ "namespace": mockPodInterface, + "": mockPodInterface, }, syslog: logrus.WithField("namespace", "test"), }, From bdaa43631f3be48b0111a9e9897b4e2f569a4811 Mon Sep 17 00:00:00 2001 From: Bradley Laney Date: Thu, 21 Nov 2024 10:49:04 -0500 Subject: [PATCH 2/2] quell linters --- master/internal/rm/kubernetesrm/jobs_test.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/master/internal/rm/kubernetesrm/jobs_test.go b/master/internal/rm/kubernetesrm/jobs_test.go index 453ffde8125..983b53470c7 100644 --- a/master/internal/rm/kubernetesrm/jobs_test.go +++ b/master/internal/rm/kubernetesrm/jobs_test.go @@ -123,7 +123,8 @@ func TestListPodsInAllNamespaces(t *testing.T) { }, } - var expectedPods []k8sV1.Pod = append(detPods, outsidePod) + //nolint:gocritic + expectedPods := append(detPods, outsidePod) expectedPodList := k8sV1.PodList{Items: expectedPods} emptyNS.On("List", mock.Anything, mock.Anything).Once(). Return(&k8sV1.PodList{Items: expectedPods}, nil) @@ -203,7 +204,8 @@ func TestHealthStatus(t *testing.T) { }, } - var expectedPods []k8sV1.Pod = append(detPods, outsidePod) + //nolint:gocritic + expectedPods := append(detPods, outsidePod) emptyNS.On("List", mock.Anything, mock.Anything).Once(). Return(&k8sV1.PodList{Items: expectedPods}, nil)