From a6ee8599f184d74fcd83d9fd112171ad74104af7 Mon Sep 17 00:00:00 2001 From: googs1025 Date: Sat, 20 Jul 2024 16:13:36 +0800 Subject: [PATCH] chore: use WaitForCacheSync method after sharedInformerFactory Start --- test/integration/servicecidr/migration_test.go | 2 ++ test/integration/servicecidr/servicecidr_test.go | 2 ++ 2 files changed, 4 insertions(+) diff --git a/test/integration/servicecidr/migration_test.go b/test/integration/servicecidr/migration_test.go index 0bd3ee10824..abf1b7c21e6 100644 --- a/test/integration/servicecidr/migration_test.go +++ b/test/integration/servicecidr/migration_test.go @@ -82,6 +82,7 @@ func TestMigrateServiceCIDR(t *testing.T) { client1, ).Run(tCtx, 5) informers1.Start(tCtx.Done()) + informers1.WaitForCacheSync(tCtx.Done()) // 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) { @@ -220,6 +221,7 @@ func TestMigrateServiceCIDR(t *testing.T) { client2, ).Run(tCtx2, 5) informers2.Start(tCtx2.Done()) + informers2.WaitForCacheSync(tCtx.Done()) // delete the kubernetes.default service so the old DefaultServiceCIDR can be deleted // and the new apiserver can take over diff --git a/test/integration/servicecidr/servicecidr_test.go b/test/integration/servicecidr/servicecidr_test.go index a493e30e4cc..5fb84ebae3e 100644 --- a/test/integration/servicecidr/servicecidr_test.go +++ b/test/integration/servicecidr/servicecidr_test.go @@ -68,6 +68,7 @@ func TestServiceAllocNewServiceCIDR(t *testing.T) { client, ).Run(ctx, 5) informerFactory.Start(ctx.Done()) + informerFactory.WaitForCacheSync(ctx.Done()) // /29 = 6 services, kubernetes.default takes the first address // make 5 more services to take up all IPs @@ -169,6 +170,7 @@ func TestServiceCIDRDeletion(t *testing.T) { client, ).Run(ctx, 5) informerFactory.Start(ctx.Done()) + informerFactory.WaitForCacheSync(ctx.Done()) // /29 = 6 services, kubernetes.default takes the first address // make 5 more services to take up all IPs