mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-04 18:00:08 +00:00
Merge pull request #126244 from googs1025/informer
chore(servicecidr): use WaitForCacheSync after sharedInformerFactory Start in integration test
This commit is contained in:
commit
f2f7708375
@ -82,6 +82,7 @@ func TestMigrateServiceCIDR(t *testing.T) {
|
|||||||
client1,
|
client1,
|
||||||
).Run(tCtx, 5)
|
).Run(tCtx, 5)
|
||||||
informers1.Start(tCtx.Done())
|
informers1.Start(tCtx.Done())
|
||||||
|
informers1.WaitForCacheSync(tCtx.Done())
|
||||||
|
|
||||||
// the default serviceCIDR should have a finalizer and ready condition set to true
|
// 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) {
|
if err := wait.PollUntilContextTimeout(context.Background(), 1*time.Second, time.Minute, false, func(ctx context.Context) (bool, error) {
|
||||||
@ -220,6 +221,7 @@ func TestMigrateServiceCIDR(t *testing.T) {
|
|||||||
client2,
|
client2,
|
||||||
).Run(tCtx2, 5)
|
).Run(tCtx2, 5)
|
||||||
informers2.Start(tCtx2.Done())
|
informers2.Start(tCtx2.Done())
|
||||||
|
informers2.WaitForCacheSync(tCtx.Done())
|
||||||
|
|
||||||
// delete the kubernetes.default service so the old DefaultServiceCIDR can be deleted
|
// delete the kubernetes.default service so the old DefaultServiceCIDR can be deleted
|
||||||
// and the new apiserver can take over
|
// and the new apiserver can take over
|
||||||
|
@ -68,6 +68,7 @@ func TestServiceAllocNewServiceCIDR(t *testing.T) {
|
|||||||
client,
|
client,
|
||||||
).Run(ctx, 5)
|
).Run(ctx, 5)
|
||||||
informerFactory.Start(ctx.Done())
|
informerFactory.Start(ctx.Done())
|
||||||
|
informerFactory.WaitForCacheSync(ctx.Done())
|
||||||
|
|
||||||
// /29 = 6 services, kubernetes.default takes the first address
|
// /29 = 6 services, kubernetes.default takes the first address
|
||||||
// make 5 more services to take up all IPs
|
// make 5 more services to take up all IPs
|
||||||
@ -169,6 +170,7 @@ func TestServiceCIDRDeletion(t *testing.T) {
|
|||||||
client,
|
client,
|
||||||
).Run(ctx, 5)
|
).Run(ctx, 5)
|
||||||
informerFactory.Start(ctx.Done())
|
informerFactory.Start(ctx.Done())
|
||||||
|
informerFactory.WaitForCacheSync(ctx.Done())
|
||||||
|
|
||||||
// /29 = 6 services, kubernetes.default takes the first address
|
// /29 = 6 services, kubernetes.default takes the first address
|
||||||
// make 5 more services to take up all IPs
|
// make 5 more services to take up all IPs
|
||||||
@ -180,7 +182,7 @@ func TestServiceCIDRDeletion(t *testing.T) {
|
|||||||
// create a new ServiceCIDRs that overlaps the default one
|
// create a new ServiceCIDRs that overlaps the default one
|
||||||
_, err = client.NetworkingV1beta1().ServiceCIDRs().Create(ctx, makeServiceCIDR("cidr1", cidr1, ""), metav1.CreateOptions{})
|
_, err = client.NetworkingV1beta1().ServiceCIDRs().Create(ctx, makeServiceCIDR("cidr1", cidr1, ""), metav1.CreateOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal((err))
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
// Wait until is ready.
|
// Wait until is ready.
|
||||||
if err := wait.PollUntilContextTimeout(context.Background(), 250*time.Millisecond, 30*time.Second, false, func(ctx context.Context) (bool, error) {
|
if err := wait.PollUntilContextTimeout(context.Background(), 250*time.Millisecond, 30*time.Second, false, func(ctx context.Context) (bool, error) {
|
||||||
@ -195,7 +197,7 @@ func TestServiceCIDRDeletion(t *testing.T) {
|
|||||||
// we should be able to delete the ServiceCIDR despite it contains IP addresses as it overlaps with the default ServiceCIDR
|
// 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.NetworkingV1beta1().ServiceCIDRs().Delete(ctx, "cidr1", metav1.DeleteOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal((err))
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := wait.PollUntilContextTimeout(context.Background(), 250*time.Millisecond, 30*time.Second, false, func(ctx context.Context) (bool, error) {
|
if err := wait.PollUntilContextTimeout(context.Background(), 250*time.Millisecond, 30*time.Second, false, func(ctx context.Context) (bool, error) {
|
||||||
@ -211,7 +213,7 @@ func TestServiceCIDRDeletion(t *testing.T) {
|
|||||||
// add a new ServiceCIDR with a new range
|
// add a new ServiceCIDR with a new range
|
||||||
_, err = client.NetworkingV1beta1().ServiceCIDRs().Create(ctx, makeServiceCIDR("cidr2", cidr2, ""), metav1.CreateOptions{})
|
_, err = client.NetworkingV1beta1().ServiceCIDRs().Create(ctx, makeServiceCIDR("cidr2", cidr2, ""), metav1.CreateOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal((err))
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
// wait the allocator process the new ServiceCIDR
|
// wait the allocator process the new ServiceCIDR
|
||||||
// Wait until is ready.
|
// Wait until is ready.
|
||||||
@ -237,7 +239,7 @@ func TestServiceCIDRDeletion(t *testing.T) {
|
|||||||
// add a new ServiceCIDR that overlaps the existing one
|
// add a new ServiceCIDR that overlaps the existing one
|
||||||
_, err = client.NetworkingV1beta1().ServiceCIDRs().Create(ctx, makeServiceCIDR("cidr3", cidr3, ""), metav1.CreateOptions{})
|
_, err = client.NetworkingV1beta1().ServiceCIDRs().Create(ctx, makeServiceCIDR("cidr3", cidr3, ""), metav1.CreateOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal((err))
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
// Wait until is ready.
|
// Wait until is ready.
|
||||||
if err := wait.PollUntilContextTimeout(context.Background(), 250*time.Millisecond, 30*time.Second, false, func(ctx context.Context) (bool, error) {
|
if err := wait.PollUntilContextTimeout(context.Background(), 250*time.Millisecond, 30*time.Second, false, func(ctx context.Context) (bool, error) {
|
||||||
@ -252,7 +254,7 @@ func TestServiceCIDRDeletion(t *testing.T) {
|
|||||||
// we should be able to delete the ServiceCIDR2 despite it contains IP addresses as it is contained on ServiceCIDR3
|
// 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.NetworkingV1beta1().ServiceCIDRs().Delete(ctx, "cidr2", metav1.DeleteOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal((err))
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := wait.PollUntilContextTimeout(context.Background(), 250*time.Millisecond, 30*time.Second, false, func(ctx context.Context) (bool, error) {
|
if err := wait.PollUntilContextTimeout(context.Background(), 250*time.Millisecond, 30*time.Second, false, func(ctx context.Context) (bool, error) {
|
||||||
@ -268,7 +270,7 @@ func TestServiceCIDRDeletion(t *testing.T) {
|
|||||||
// serviceCIDR3 will not be able to be deleted until the IPAddress is removed
|
// serviceCIDR3 will not be able to be deleted until the IPAddress is removed
|
||||||
err = client.NetworkingV1beta1().ServiceCIDRs().Delete(ctx, "cidr3", metav1.DeleteOptions{})
|
err = client.NetworkingV1beta1().ServiceCIDRs().Delete(ctx, "cidr3", metav1.DeleteOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal((err))
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
// Wait until is not ready.
|
// Wait until is not ready.
|
||||||
if err := wait.PollUntilContextTimeout(context.Background(), 250*time.Millisecond, 30*time.Second, false, func(ctx context.Context) (bool, error) {
|
if err := wait.PollUntilContextTimeout(context.Background(), 250*time.Millisecond, 30*time.Second, false, func(ctx context.Context) (bool, error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user