diff --git a/pkg/ipam/floatingip/ipam_crd_test.go b/pkg/ipam/floatingip/ipam_crd_test.go index f27ce34f..f7464d61 100644 --- a/pkg/ipam/floatingip/ipam_crd_test.go +++ b/pkg/ipam/floatingip/ipam_crd_test.go @@ -17,6 +17,7 @@ package floatingip import ( + "context" "encoding/json" "fmt" "net" @@ -142,7 +143,7 @@ func TestAllocateSpecificIP(t *testing.T) { } func checkFIP(ipam *crdIpam, expect ...string) error { - fips, err := ipam.client.GalaxyV1alpha1().FloatingIPs().List(v1.ListOptions{}) + fips, err := ipam.client.GalaxyV1alpha1().FloatingIPs().List(context.Background(), v1.ListOptions{}) if err != nil { return err } diff --git a/pkg/ipam/floatingip/store_crd_test.go b/pkg/ipam/floatingip/store_crd_test.go index 48d24d83..f50d709e 100644 --- a/pkg/ipam/floatingip/store_crd_test.go +++ b/pkg/ipam/floatingip/store_crd_test.go @@ -17,6 +17,7 @@ package floatingip import ( + "context" "fmt" "net" "strings" @@ -44,7 +45,7 @@ func TestAddFloatingIPEventByUser(t *testing.T) { if err := assign(fipCrd, fip); err != nil { t.Fatal(err) } - if _, err := ipam.client.GalaxyV1alpha1().FloatingIPs().Create(fipCrd); err != nil { + if _, err := ipam.client.GalaxyV1alpha1().FloatingIPs().Create(context.Background(), fipCrd, v1.CreateOptions{}); err != nil { t.Fatal(err) } if err := waitFor(ipam, fip.IP, fip.Key, true, node1IPNet.String()); err != nil { @@ -107,7 +108,7 @@ func TestDeleteFloatingIPEvent(t *testing.T) { ip := net.ParseIP(fipCrd.Name) fipCrd.Labels[constant.ReserveFIPLabel] = "" fipCrd.Spec.Key = "pool__reserved-for-node_" - if _, err := ipam.client.GalaxyV1alpha1().FloatingIPs().Create(fipCrd); err != nil { + if _, err := ipam.client.GalaxyV1alpha1().FloatingIPs().Create(context.Background(), fipCrd, v1.CreateOptions{}); err != nil { t.Fatal(err) } if err := waitFor(ipam, ip, fipCrd.Spec.Key, true, node1IPNet.String()); err != nil { @@ -124,7 +125,7 @@ func TestDeleteFloatingIPEvent(t *testing.T) { // test if an event is created by user, deleteFloatingIPEvent should handle it fipCrd.Labels[constant.ReserveFIPLabel] = "" - if err := ipam.client.GalaxyV1alpha1().FloatingIPs().Delete(fipCrd.Name, &v1.DeleteOptions{}); err != nil { + if err := ipam.client.GalaxyV1alpha1().FloatingIPs().Delete(context.Background(), fipCrd.Name, v1.DeleteOptions{}); err != nil { t.Fatal(err) } if err := waitFor(ipam, ip, "", false, node1IPNet.String()); err != nil { diff --git a/pkg/ipam/schedulerplugin/bind_test.go b/pkg/ipam/schedulerplugin/bind_test.go index ea9cd795..39d4a5a3 100644 --- a/pkg/ipam/schedulerplugin/bind_test.go +++ b/pkg/ipam/schedulerplugin/bind_test.go @@ -17,6 +17,7 @@ package schedulerplugin import ( + "context" "encoding/json" "errors" "fmt" @@ -223,7 +224,7 @@ func TestReleaseIPOfFinishedPod(t *testing.T) { t.Fatalf("case %d: %v", i, err) } testCase.updatePodStatus(pod) - if _, err := fipPlugin.Client.CoreV1().Pods(pod.Namespace).UpdateStatus(pod); err != nil { + if _, err := fipPlugin.Client.CoreV1().Pods(pod.Namespace).UpdateStatus(context.Background(), pod, v1.UpdateOptions{}); err != nil { t.Fatalf("case %d: %v", i, err) } if err := wait.Poll(time.Microsecond*10, time.Second*30, func() (done bool, err error) { @@ -285,7 +286,7 @@ func TestFilterBindRequestIPRange(t *testing.T) { t.Fatal(err) } pod.Annotations = cniArgsAnnotation(request) - if _, err := fipPlugin.Client.CoreV1().Pods(pod.Namespace).Update(pod); err != nil { + if _, err := fipPlugin.Client.CoreV1().Pods(pod.Namespace).Update(context.Background(), pod, v1.UpdateOptions{}); err != nil { t.Fatal(err) } // wait for lister updates diff --git a/pkg/ipam/schedulerplugin/crdkey_test.go b/pkg/ipam/schedulerplugin/crdkey_test.go index d12cf200..33e6bd4e 100644 --- a/pkg/ipam/schedulerplugin/crdkey_test.go +++ b/pkg/ipam/schedulerplugin/crdkey_test.go @@ -37,7 +37,7 @@ func TestGetGroupVersionResource(t *testing.T) { if gvr == nil { t.Fatal() } - if gvr.Group != FooCrd.Spec.Group || gvr.Version != FooCrd.Spec.Version || + if gvr.Group != FooCrd.Spec.Group || gvr.Version != FooCrd.Spec.Versions[0].Name || gvr.Resource != FooCrd.Spec.Names.Plural { t.Fatal(gvr) }