From eb02f2b8fdfea9be43436fd6a5f2f2192303db7a Mon Sep 17 00:00:00 2001 From: Andrew Stoycos Date: Wed, 11 May 2022 15:15:15 -0400 Subject: [PATCH] Fix Unit tests after bumping to K8s 1.23 For a Fake k8s client we must now explicitly register all resouces we expect to list in the scheme. Otherwise we'll run into https://github.com/kubernetes/client-go/issues/914 Signed-off-by: Andrew Stoycos --- .../datastoresyncer/datastoresyncer_suite_test.go | 1 + pkg/globalnet/controllers/controllers_suite_test.go | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/pkg/controllers/datastoresyncer/datastoresyncer_suite_test.go b/pkg/controllers/datastoresyncer/datastoresyncer_suite_test.go index 5cc45b38e..8d8646361 100644 --- a/pkg/controllers/datastoresyncer/datastoresyncer_suite_test.go +++ b/pkg/controllers/datastoresyncer/datastoresyncer_suite_test.go @@ -116,6 +116,7 @@ func newTestDriver() *testDriver { t.syncerScheme = runtime.NewScheme() Expect(submarinerv1.AddToScheme(t.syncerScheme)).To(Succeed()) + Expect(corev1.AddToScheme(t.syncerScheme)).To(Succeed()) t.localClient = fake.NewDynamicClient(t.syncerScheme) t.brokerClient = fake.NewDynamicClient(t.syncerScheme) diff --git a/pkg/globalnet/controllers/controllers_suite_test.go b/pkg/globalnet/controllers/controllers_suite_test.go index a6fed0734..6e26f3dcf 100644 --- a/pkg/globalnet/controllers/controllers_suite_test.go +++ b/pkg/globalnet/controllers/controllers_suite_test.go @@ -46,6 +46,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/apimachinery/pkg/util/uuid" "k8s.io/apimachinery/pkg/util/wait" @@ -114,6 +115,11 @@ func newTestDriverBase() *testDriverBase { Expect(submarinerv1.AddToScheme(t.scheme)).To(Succeed()) Expect(corev1.AddToScheme(t.scheme)).To(Succeed()) + // TODO: Remove this workaround for https://github.com/kubernetes/client-go/issues/949 once + // admiral has been updated + t.scheme.AddKnownTypeWithName(schema.GroupVersionKind{Group: "fake-dynamic-client-group", Version: "v1", Kind: "List"}, + &unstructured.UnstructuredList{}) + fakeClient := fakeDynClient.NewDynamicClient(t.scheme) t.dynClient = fakeClient