Skip to content

Commit

Permalink
Fix Unit tests after bumping to K8s 1.23
Browse files Browse the repository at this point in the history
For a Fake k8s client we must now
explicitly register all resouces
we expect to list in the scheme.

Otherwise we'll run into
kubernetes/client-go#914

Signed-off-by: Andrew Stoycos <astoycos@redhat.com>
  • Loading branch information
Andrew Stoycos committed May 12, 2022
1 parent e28ed6c commit dc71dc8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions pkg/globalnet/controllers/controllers_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,14 @@ 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"
"k8s.io/client-go/dynamic"
"k8s.io/client-go/kubernetes/scheme"
"k8s.io/klog"

mcsv1a1 "sigs.k8s.io/mcs-api/pkg/apis/v1alpha1"
)

Expand Down Expand Up @@ -114,6 +116,10 @@ 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

Expand Down

0 comments on commit dc71dc8

Please sign in to comment.