mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 15:25:57 +00:00
update integration test
This commit is contained in:
parent
b6c3dfdad5
commit
779b9cf90c
@ -68,6 +68,7 @@ var resetFieldsStatusData = map[schema.GroupVersionResource]string{
|
||||
gvr("admissionregistration.k8s.io", "v1", "validatingadmissionpolicies"): `{"status": {"conditions":[{"type":"Accepted","status":"True","lastTransitionTime":"2020-01-01T00:00:00Z","reason":"RuleApplied","message":"Rule was applied"}]}}`,
|
||||
gvr("networking.k8s.io", "v1alpha1", "servicecidrs"): `{"status": {"conditions":[{"type":"Accepted","status":"True","lastTransitionTime":"2020-01-01T00:00:00Z","reason":"RuleApplied","message":"Rule was applied"}]}}`,
|
||||
gvr("networking.k8s.io", "v1beta1", "servicecidrs"): `{"status": {"conditions":[{"type":"Accepted","status":"True","lastTransitionTime":"2020-01-01T00:00:00Z","reason":"RuleApplied","message":"Rule was applied"}]}}`,
|
||||
gvr("networking.k8s.io", "v1", "servicecidrs"): `{"status": {"conditions":[{"type":"Accepted","status":"True","lastTransitionTime":"2020-01-01T00:00:00Z","reason":"RuleApplied","message":"Rule was applied"}]}}`,
|
||||
}
|
||||
|
||||
// resetFieldsStatusDefault conflicts with statusDefault
|
||||
@ -138,6 +139,7 @@ var resetFieldsSpecData = map[schema.GroupVersionResource]string{
|
||||
gvr("networking.k8s.io", "v1", "ingresses"): `{"spec": {"defaultBackend": {"service": {"name": "service2"}}}}`,
|
||||
gvr("networking.k8s.io", "v1alpha1", "servicecidrs"): `{}`,
|
||||
gvr("networking.k8s.io", "v1beta1", "servicecidrs"): `{}`,
|
||||
gvr("networking.k8s.io", "v1", "servicecidrs"): `{}`,
|
||||
gvr("policy", "v1", "poddisruptionbudgets"): `{"spec": {"selector": {"matchLabels": {"anokkey2": "anokvalue"}}}}`,
|
||||
gvr("policy", "v1beta1", "poddisruptionbudgets"): `{"spec": {"selector": {"matchLabels": {"anokkey2": "anokvalue"}}}}`,
|
||||
gvr("storage.k8s.io", "v1alpha1", "volumeattachments"): `{"metadata": {"name": "va3"}, "spec": {"nodeName": "localhost2"}}`,
|
||||
|
@ -272,6 +272,14 @@ func GetEtcdStorageDataForNamespaceServedAt(namespace string, v string, removeAl
|
||||
ExpectedEtcdPath: "/registry/networkpolicies/" + namespace + "/np2",
|
||||
IntroducedVersion: "1.7",
|
||||
},
|
||||
gvr("networking.k8s.io", "v1", "ipaddresses"): {
|
||||
Stub: `{"metadata": {"name": "192.168.2.3"}, "spec": {"parentRef": {"resource": "services","name": "test", "namespace": "ns"}}}`,
|
||||
ExpectedEtcdPath: "/registry/ipaddresses/192.168.2.3",
|
||||
},
|
||||
gvr("networking.k8s.io", "v1", "servicecidrs"): {
|
||||
Stub: `{"metadata": {"name": "range-b2"}, "spec": {"cidrs": ["192.168.0.0/16","fd00:1::/120"]}}`,
|
||||
ExpectedEtcdPath: "/registry/servicecidrs/range-b2",
|
||||
},
|
||||
// --
|
||||
|
||||
// k8s.io/kubernetes/pkg/apis/networking/v1beta1
|
||||
|
@ -205,7 +205,7 @@ func TestServiceAllocIPAddressLargeCIDR(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
_, err = client.NetworkingV1beta1().IPAddresses().Get(tCtx, svc.Spec.ClusterIP, metav1.GetOptions{})
|
||||
_, err = client.NetworkingV1().IPAddresses().Get(tCtx, svc.Spec.ClusterIP, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@ -219,7 +219,7 @@ func TestServiceAllocIPAddressLargeCIDR(t *testing.T) {
|
||||
t.Errorf("unexpected error text: %v", err)
|
||||
}
|
||||
|
||||
_, err = client.NetworkingV1beta1().IPAddresses().Get(context.TODO(), lastSvc.Spec.ClusterIP, metav1.GetOptions{})
|
||||
_, err = client.NetworkingV1().IPAddresses().Get(context.TODO(), lastSvc.Spec.ClusterIP, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@ -286,7 +286,7 @@ func TestMigrateService(t *testing.T) {
|
||||
|
||||
err = wait.PollImmediate(1*time.Second, 10*time.Second, func() (bool, error) {
|
||||
// The repair loop must create the IP address associated
|
||||
_, err = kubeclient.NetworkingV1beta1().IPAddresses().Get(context.TODO(), svc.Spec.ClusterIP, metav1.GetOptions{})
|
||||
_, err = kubeclient.NetworkingV1().IPAddresses().Get(context.TODO(), svc.Spec.ClusterIP, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return false, nil
|
||||
}
|
||||
@ -339,7 +339,7 @@ func TestSkewedAllocatorsRollback(t *testing.T) {
|
||||
t.Error(err)
|
||||
continue
|
||||
}
|
||||
_, err = kubeclient1.NetworkingV1beta1().IPAddresses().Get(context.TODO(), service.Spec.ClusterIP, metav1.GetOptions{})
|
||||
_, err = kubeclient1.NetworkingV1().IPAddresses().Get(context.TODO(), service.Spec.ClusterIP, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@ -369,7 +369,7 @@ func TestSkewedAllocatorsRollback(t *testing.T) {
|
||||
|
||||
err = wait.PollImmediate(1*time.Second, 10*time.Second, func() (bool, error) {
|
||||
// The repair loop must create the IP address associated
|
||||
_, err = kubeclient1.NetworkingV1beta1().IPAddresses().Get(context.TODO(), service.Spec.ClusterIP, metav1.GetOptions{})
|
||||
_, err = kubeclient1.NetworkingV1().IPAddresses().Get(context.TODO(), service.Spec.ClusterIP, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return false, nil
|
||||
}
|
||||
@ -498,7 +498,7 @@ func TestSkewAllocatorsRollout(t *testing.T) {
|
||||
// It takes some time for the repairip loop to create the corresponding IPAddress objects
|
||||
// ClusterIPs are synchronized through the bitmap.
|
||||
err = wait.PollUntilContextTimeout(context.Background(), 1*time.Second, 10*time.Second, true, func(context.Context) (bool, error) {
|
||||
ips, err := kubeclientNew.NetworkingV1beta1().IPAddresses().List(context.Background(), metav1.ListOptions{})
|
||||
ips, err := kubeclientNew.NetworkingV1().IPAddresses().List(context.Background(), metav1.ListOptions{})
|
||||
if err != nil {
|
||||
return false, nil
|
||||
}
|
||||
@ -527,7 +527,7 @@ func TestSkewAllocatorsRollout(t *testing.T) {
|
||||
ip := fmt.Sprintf("10.0.0.%d", i)
|
||||
err = wait.PollUntilContextTimeout(context.Background(), 1*time.Second, 10*time.Second, true, func(context.Context) (bool, error) {
|
||||
// The repair loop must create the IP address associated
|
||||
_, err = kubeclientNew.NetworkingV1beta1().IPAddresses().Get(context.Background(), ip, metav1.GetOptions{})
|
||||
_, err = kubeclientNew.NetworkingV1().IPAddresses().Get(context.Background(), ip, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return false, nil
|
||||
}
|
||||
@ -577,7 +577,7 @@ func TestFlagsIPAllocator(t *testing.T) {
|
||||
t.Error(err)
|
||||
continue
|
||||
}
|
||||
_, err = kubeclient1.NetworkingV1beta1().IPAddresses().Get(context.TODO(), service.Spec.ClusterIP, metav1.GetOptions{})
|
||||
_, err = kubeclient1.NetworkingV1().IPAddresses().Get(context.TODO(), service.Spec.ClusterIP, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ import (
|
||||
"time"
|
||||
|
||||
v1 "k8s.io/api/core/v1"
|
||||
networkingv1beta1 "k8s.io/api/networking/v1beta1"
|
||||
networkingv1 "k8s.io/api/networking/v1"
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
@ -77,8 +77,8 @@ func TestMigrateServiceCIDR(t *testing.T) {
|
||||
// ServiceCIDR controller
|
||||
go servicecidrs.NewController(
|
||||
tCtx,
|
||||
informers1.Networking().V1beta1().ServiceCIDRs(),
|
||||
informers1.Networking().V1beta1().IPAddresses(),
|
||||
informers1.Networking().V1().ServiceCIDRs(),
|
||||
informers1.Networking().V1().IPAddresses(),
|
||||
client1,
|
||||
).Run(tCtx, 5)
|
||||
informers1.Start(tCtx.Done())
|
||||
@ -86,7 +86,7 @@ func TestMigrateServiceCIDR(t *testing.T) {
|
||||
|
||||
// the default serviceCIDR should have a finalizer and ready condition set to true
|
||||
if err := wait.PollUntilContextTimeout(context.Background(), 1*time.Second, time.Minute, false, func(ctx context.Context) (bool, error) {
|
||||
cidr, err := client1.NetworkingV1beta1().ServiceCIDRs().Get(context.TODO(), defaultservicecidr.DefaultServiceCIDRName, metav1.GetOptions{})
|
||||
cidr, err := client1.NetworkingV1().ServiceCIDRs().Get(context.TODO(), defaultservicecidr.DefaultServiceCIDRName, metav1.GetOptions{})
|
||||
if err != nil && !apierrors.IsNotFound(err) {
|
||||
return false, err
|
||||
}
|
||||
@ -120,13 +120,13 @@ func TestMigrateServiceCIDR(t *testing.T) {
|
||||
}
|
||||
}
|
||||
// Add a new service CIDR to be able to migrate the apiserver
|
||||
if _, err := client1.NetworkingV1beta1().ServiceCIDRs().Create(context.Background(), makeServiceCIDR("migration-cidr", cidr2, ""), metav1.CreateOptions{}); err != nil {
|
||||
if _, err := client1.NetworkingV1().ServiceCIDRs().Create(context.Background(), makeServiceCIDR("migration-cidr", cidr2, ""), metav1.CreateOptions{}); err != nil {
|
||||
t.Fatalf("got unexpected error: %v", err)
|
||||
}
|
||||
|
||||
// wait ServiceCIDR is ready
|
||||
if err := wait.PollUntilContextTimeout(context.Background(), 1*time.Second, time.Minute, false, func(ctx context.Context) (bool, error) {
|
||||
cidr, err := client1.NetworkingV1beta1().ServiceCIDRs().Get(context.TODO(), "migration-cidr", metav1.GetOptions{})
|
||||
cidr, err := client1.NetworkingV1().ServiceCIDRs().Get(context.TODO(), "migration-cidr", metav1.GetOptions{})
|
||||
if err != nil && !apierrors.IsNotFound(err) {
|
||||
return false, err
|
||||
}
|
||||
@ -136,18 +136,18 @@ func TestMigrateServiceCIDR(t *testing.T) {
|
||||
}
|
||||
|
||||
// delete the default ServiceCIDR so is no longer used for allocating IPs
|
||||
if err := client1.NetworkingV1beta1().ServiceCIDRs().Delete(context.Background(), defaultservicecidr.DefaultServiceCIDRName, metav1.DeleteOptions{}); err != nil {
|
||||
if err := client1.NetworkingV1().ServiceCIDRs().Delete(context.Background(), defaultservicecidr.DefaultServiceCIDRName, metav1.DeleteOptions{}); err != nil {
|
||||
t.Fatalf("got unexpected error: %v", err)
|
||||
}
|
||||
|
||||
// the default serviceCIDR should be pending deletion with Ready condition set to false
|
||||
if err := wait.PollUntilContextTimeout(context.Background(), 1*time.Second, time.Minute, false, func(ctx context.Context) (bool, error) {
|
||||
cidr, err := client1.NetworkingV1beta1().ServiceCIDRs().Get(context.TODO(), defaultservicecidr.DefaultServiceCIDRName, metav1.GetOptions{})
|
||||
cidr, err := client1.NetworkingV1().ServiceCIDRs().Get(context.TODO(), defaultservicecidr.DefaultServiceCIDRName, metav1.GetOptions{})
|
||||
if err != nil && !apierrors.IsNotFound(err) {
|
||||
return false, err
|
||||
}
|
||||
for _, condition := range cidr.Status.Conditions {
|
||||
if condition.Type == networkingv1beta1.ServiceCIDRConditionReady {
|
||||
if condition.Type == networkingv1.ServiceCIDRConditionReady {
|
||||
return condition.Status == metav1.ConditionFalse, nil
|
||||
}
|
||||
}
|
||||
@ -216,8 +216,8 @@ func TestMigrateServiceCIDR(t *testing.T) {
|
||||
informers2 := informers.NewSharedInformerFactory(client2, resyncPeriod)
|
||||
go servicecidrs.NewController(
|
||||
tCtx2,
|
||||
informers2.Networking().V1beta1().ServiceCIDRs(),
|
||||
informers2.Networking().V1beta1().IPAddresses(),
|
||||
informers2.Networking().V1().ServiceCIDRs(),
|
||||
informers2.Networking().V1().IPAddresses(),
|
||||
client2,
|
||||
).Run(tCtx2, 5)
|
||||
informers2.Start(tCtx2.Done())
|
||||
@ -231,7 +231,7 @@ func TestMigrateServiceCIDR(t *testing.T) {
|
||||
|
||||
// the default serviceCIDR should be the new one
|
||||
if err := wait.PollUntilContextTimeout(context.Background(), 1*time.Second, time.Minute, false, func(ctx context.Context) (bool, error) {
|
||||
cidr, err := client2.NetworkingV1beta1().ServiceCIDRs().Get(context.TODO(), defaultservicecidr.DefaultServiceCIDRName, metav1.GetOptions{})
|
||||
cidr, err := client2.NetworkingV1().ServiceCIDRs().Get(context.TODO(), defaultservicecidr.DefaultServiceCIDRName, metav1.GetOptions{})
|
||||
if err != nil && !apierrors.IsNotFound(err) {
|
||||
return false, err
|
||||
}
|
||||
@ -252,7 +252,7 @@ func TestMigrateServiceCIDR(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, condition := range cidr.Status.Conditions {
|
||||
if condition.Type == networkingv1beta1.ServiceCIDRConditionReady {
|
||||
if condition.Type == networkingv1.ServiceCIDRConditionReady {
|
||||
t.Logf("Expected Condition %s to be %s", condition.Status, metav1.ConditionTrue)
|
||||
return condition.Status == metav1.ConditionTrue, nil
|
||||
}
|
||||
@ -277,13 +277,13 @@ func TestMigrateServiceCIDR(t *testing.T) {
|
||||
}
|
||||
|
||||
// The temporary ServiceCIDR can be deleted now since the Default ServiceCIDR will cover it
|
||||
if err := client2.NetworkingV1beta1().ServiceCIDRs().Delete(context.Background(), "migration-cidr", metav1.DeleteOptions{}); err != nil {
|
||||
if err := client2.NetworkingV1().ServiceCIDRs().Delete(context.Background(), "migration-cidr", metav1.DeleteOptions{}); err != nil {
|
||||
t.Fatalf("got unexpected error: %v", err)
|
||||
}
|
||||
|
||||
// wait ServiceCIDR no longer exist
|
||||
if err := wait.PollUntilContextTimeout(context.Background(), 1*time.Second, time.Minute, false, func(ctx context.Context) (bool, error) {
|
||||
_, err := client2.NetworkingV1beta1().ServiceCIDRs().Get(context.TODO(), "migration-cidr", metav1.GetOptions{})
|
||||
_, err := client2.NetworkingV1().ServiceCIDRs().Get(context.TODO(), "migration-cidr", metav1.GetOptions{})
|
||||
if err != nil && !apierrors.IsNotFound(err) {
|
||||
return false, nil
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ import (
|
||||
"time"
|
||||
|
||||
v1 "k8s.io/api/core/v1"
|
||||
networkingv1beta1 "k8s.io/api/networking/v1beta1"
|
||||
networkingv1 "k8s.io/api/networking/v1"
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
@ -43,7 +43,7 @@ func TestServiceAllocNewServiceCIDR(t *testing.T) {
|
||||
s := kubeapiservertesting.StartTestServerOrDie(t,
|
||||
apiServerOptions,
|
||||
[]string{
|
||||
"--runtime-config=networking.k8s.io/v1beta1=true",
|
||||
"--runtime-config=networking.k8s.io/v1=true",
|
||||
"--service-cluster-ip-range=192.168.0.0/29",
|
||||
"--advertise-address=10.1.1.1",
|
||||
"--disable-admission-plugins=ServiceAccount",
|
||||
@ -63,8 +63,8 @@ func TestServiceAllocNewServiceCIDR(t *testing.T) {
|
||||
informerFactory := informers.NewSharedInformerFactory(client, resyncPeriod)
|
||||
go servicecidrs.NewController(
|
||||
ctx,
|
||||
informerFactory.Networking().V1beta1().ServiceCIDRs(),
|
||||
informerFactory.Networking().V1beta1().IPAddresses(),
|
||||
informerFactory.Networking().V1().ServiceCIDRs(),
|
||||
informerFactory.Networking().V1().IPAddresses(),
|
||||
client,
|
||||
).Run(ctx, 5)
|
||||
informerFactory.Start(ctx.Done())
|
||||
@ -97,12 +97,12 @@ func TestServiceAllocNewServiceCIDR(t *testing.T) {
|
||||
|
||||
// Add a new service CIDR to be able to create new IPs.
|
||||
cidr := makeServiceCIDR("test2", "10.168.0.0/24", "")
|
||||
if _, err := client.NetworkingV1beta1().ServiceCIDRs().Create(context.Background(), cidr, metav1.CreateOptions{}); err != nil {
|
||||
if _, err := client.NetworkingV1().ServiceCIDRs().Create(context.Background(), cidr, metav1.CreateOptions{}); err != nil {
|
||||
t.Fatalf("got unexpected error: %v", err)
|
||||
}
|
||||
// wait ServiceCIDR is ready
|
||||
if err := wait.PollUntilContextTimeout(context.Background(), 1*time.Second, time.Minute, false, func(ctx context.Context) (bool, error) {
|
||||
cidr, err := client.NetworkingV1beta1().ServiceCIDRs().Get(context.TODO(), cidr.Name, metav1.GetOptions{})
|
||||
cidr, err := client.NetworkingV1().ServiceCIDRs().Get(context.TODO(), cidr.Name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@ -141,7 +141,7 @@ func TestServiceCIDRDeletion(t *testing.T) {
|
||||
s := kubeapiservertesting.StartTestServerOrDie(t,
|
||||
apiServerOptions,
|
||||
[]string{
|
||||
"--runtime-config=networking.k8s.io/v1beta1=true",
|
||||
"--runtime-config=networking.k8s.io/v1=true",
|
||||
"--service-cluster-ip-range=" + cidr1,
|
||||
"--advertise-address=172.16.1.1",
|
||||
"--disable-admission-plugins=ServiceAccount",
|
||||
@ -165,8 +165,8 @@ func TestServiceCIDRDeletion(t *testing.T) {
|
||||
informerFactory := informers.NewSharedInformerFactory(client, resyncPeriod)
|
||||
go servicecidrs.NewController(
|
||||
ctx,
|
||||
informerFactory.Networking().V1beta1().ServiceCIDRs(),
|
||||
informerFactory.Networking().V1beta1().IPAddresses(),
|
||||
informerFactory.Networking().V1().ServiceCIDRs(),
|
||||
informerFactory.Networking().V1().IPAddresses(),
|
||||
client,
|
||||
).Run(ctx, 5)
|
||||
informerFactory.Start(ctx.Done())
|
||||
@ -180,13 +180,13 @@ func TestServiceCIDRDeletion(t *testing.T) {
|
||||
}
|
||||
}
|
||||
// create a new ServiceCIDRs that overlaps the default one
|
||||
_, err = client.NetworkingV1beta1().ServiceCIDRs().Create(ctx, makeServiceCIDR("cidr1", cidr1, ""), metav1.CreateOptions{})
|
||||
_, err = client.NetworkingV1().ServiceCIDRs().Create(ctx, makeServiceCIDR("cidr1", cidr1, ""), metav1.CreateOptions{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// Wait until is ready.
|
||||
if err := wait.PollUntilContextTimeout(context.Background(), 250*time.Millisecond, 30*time.Second, false, func(ctx context.Context) (bool, error) {
|
||||
cidr, err := client.NetworkingV1beta1().ServiceCIDRs().Get(ctx, "cidr1", metav1.GetOptions{})
|
||||
cidr, err := client.NetworkingV1().ServiceCIDRs().Get(ctx, "cidr1", metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return false, nil
|
||||
}
|
||||
@ -195,13 +195,13 @@ func TestServiceCIDRDeletion(t *testing.T) {
|
||||
t.Fatalf("cidr1 is not ready")
|
||||
}
|
||||
// we should be able to delete the ServiceCIDR despite it contains IP addresses as it overlaps with the default ServiceCIDR
|
||||
err = client.NetworkingV1beta1().ServiceCIDRs().Delete(ctx, "cidr1", metav1.DeleteOptions{})
|
||||
err = client.NetworkingV1().ServiceCIDRs().Delete(ctx, "cidr1", metav1.DeleteOptions{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if err := wait.PollUntilContextTimeout(context.Background(), 250*time.Millisecond, 30*time.Second, false, func(ctx context.Context) (bool, error) {
|
||||
_, err := client.NetworkingV1beta1().ServiceCIDRs().Get(ctx, "cidr1", metav1.GetOptions{})
|
||||
_, err := client.NetworkingV1().ServiceCIDRs().Get(ctx, "cidr1", metav1.GetOptions{})
|
||||
if err != nil && apierrors.IsNotFound(err) {
|
||||
return true, nil
|
||||
}
|
||||
@ -211,14 +211,14 @@ func TestServiceCIDRDeletion(t *testing.T) {
|
||||
}
|
||||
|
||||
// add a new ServiceCIDR with a new range
|
||||
_, err = client.NetworkingV1beta1().ServiceCIDRs().Create(ctx, makeServiceCIDR("cidr2", cidr2, ""), metav1.CreateOptions{})
|
||||
_, err = client.NetworkingV1().ServiceCIDRs().Create(ctx, makeServiceCIDR("cidr2", cidr2, ""), metav1.CreateOptions{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// wait the allocator process the new ServiceCIDR
|
||||
// Wait until is ready.
|
||||
if err := wait.PollUntilContextTimeout(context.Background(), 250*time.Millisecond, 30*time.Second, false, func(ctx context.Context) (bool, error) {
|
||||
cidr, err := client.NetworkingV1beta1().ServiceCIDRs().Get(ctx, "cidr2", metav1.GetOptions{})
|
||||
cidr, err := client.NetworkingV1().ServiceCIDRs().Get(ctx, "cidr2", metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return false, nil
|
||||
}
|
||||
@ -237,13 +237,13 @@ func TestServiceCIDRDeletion(t *testing.T) {
|
||||
}
|
||||
|
||||
// add a new ServiceCIDR that overlaps the existing one
|
||||
_, err = client.NetworkingV1beta1().ServiceCIDRs().Create(ctx, makeServiceCIDR("cidr3", cidr3, ""), metav1.CreateOptions{})
|
||||
_, err = client.NetworkingV1().ServiceCIDRs().Create(ctx, makeServiceCIDR("cidr3", cidr3, ""), metav1.CreateOptions{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// Wait until is ready.
|
||||
if err := wait.PollUntilContextTimeout(context.Background(), 250*time.Millisecond, 30*time.Second, false, func(ctx context.Context) (bool, error) {
|
||||
cidr, err := client.NetworkingV1beta1().ServiceCIDRs().Get(ctx, "cidr3", metav1.GetOptions{})
|
||||
cidr, err := client.NetworkingV1().ServiceCIDRs().Get(ctx, "cidr3", metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return false, nil
|
||||
}
|
||||
@ -252,13 +252,13 @@ func TestServiceCIDRDeletion(t *testing.T) {
|
||||
t.Fatalf("cidr3 is not ready")
|
||||
}
|
||||
// we should be able to delete the ServiceCIDR2 despite it contains IP addresses as it is contained on ServiceCIDR3
|
||||
err = client.NetworkingV1beta1().ServiceCIDRs().Delete(ctx, "cidr2", metav1.DeleteOptions{})
|
||||
err = client.NetworkingV1().ServiceCIDRs().Delete(ctx, "cidr2", metav1.DeleteOptions{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if err := wait.PollUntilContextTimeout(context.Background(), 250*time.Millisecond, 30*time.Second, false, func(ctx context.Context) (bool, error) {
|
||||
_, err := client.NetworkingV1beta1().ServiceCIDRs().Get(ctx, "cidr2", metav1.GetOptions{})
|
||||
_, err := client.NetworkingV1().ServiceCIDRs().Get(ctx, "cidr2", metav1.GetOptions{})
|
||||
if err != nil && apierrors.IsNotFound(err) {
|
||||
return true, nil
|
||||
}
|
||||
@ -268,18 +268,18 @@ func TestServiceCIDRDeletion(t *testing.T) {
|
||||
}
|
||||
|
||||
// serviceCIDR3 will not be able to be deleted until the IPAddress is removed
|
||||
err = client.NetworkingV1beta1().ServiceCIDRs().Delete(ctx, "cidr3", metav1.DeleteOptions{})
|
||||
err = client.NetworkingV1().ServiceCIDRs().Delete(ctx, "cidr3", metav1.DeleteOptions{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// Wait until is not ready.
|
||||
if err := wait.PollUntilContextTimeout(context.Background(), 250*time.Millisecond, 30*time.Second, false, func(ctx context.Context) (bool, error) {
|
||||
cidr, err := client.NetworkingV1beta1().ServiceCIDRs().Get(ctx, "cidr3", metav1.GetOptions{})
|
||||
cidr, err := client.NetworkingV1().ServiceCIDRs().Get(ctx, "cidr3", metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return false, nil
|
||||
}
|
||||
for _, condition := range cidr.Status.Conditions {
|
||||
if condition.Type == networkingv1beta1.ServiceCIDRConditionReady {
|
||||
if condition.Type == networkingv1.ServiceCIDRConditionReady {
|
||||
return condition.Status == metav1.ConditionStatus(metav1.ConditionFalse), nil
|
||||
}
|
||||
}
|
||||
@ -295,7 +295,7 @@ func TestServiceCIDRDeletion(t *testing.T) {
|
||||
|
||||
// cidr3 must not exist
|
||||
if err := wait.PollUntilContextTimeout(context.Background(), 250*time.Millisecond, 30*time.Second, false, func(ctx context.Context) (bool, error) {
|
||||
_, err := client.NetworkingV1beta1().ServiceCIDRs().Get(ctx, "cidr3", metav1.GetOptions{})
|
||||
_, err := client.NetworkingV1().ServiceCIDRs().Get(ctx, "cidr3", metav1.GetOptions{})
|
||||
if err != nil && apierrors.IsNotFound(err) {
|
||||
return true, nil
|
||||
}
|
||||
@ -305,12 +305,12 @@ func TestServiceCIDRDeletion(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func makeServiceCIDR(name, primary, secondary string) *networkingv1beta1.ServiceCIDR {
|
||||
serviceCIDR := &networkingv1beta1.ServiceCIDR{
|
||||
func makeServiceCIDR(name, primary, secondary string) *networkingv1.ServiceCIDR {
|
||||
serviceCIDR := &networkingv1.ServiceCIDR{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: name,
|
||||
},
|
||||
Spec: networkingv1beta1.ServiceCIDRSpec{},
|
||||
Spec: networkingv1.ServiceCIDRSpec{},
|
||||
}
|
||||
serviceCIDR.Spec.CIDRs = append(serviceCIDR.Spec.CIDRs, primary)
|
||||
if secondary != "" {
|
||||
@ -334,13 +334,13 @@ func makeService(name string) *v1.Service {
|
||||
}
|
||||
|
||||
// returns true of the ServiceCIDRConditionReady is true
|
||||
func isServiceCIDRReady(serviceCIDR *networkingv1beta1.ServiceCIDR) bool {
|
||||
func isServiceCIDRReady(serviceCIDR *networkingv1.ServiceCIDR) bool {
|
||||
if serviceCIDR == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
for _, condition := range serviceCIDR.Status.Conditions {
|
||||
if condition.Type == networkingv1beta1.ServiceCIDRConditionReady {
|
||||
if condition.Type == networkingv1.ServiceCIDRConditionReady {
|
||||
return condition.Status == metav1.ConditionStatus(metav1.ConditionTrue)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user