From 8c971c5c159d22a7f181d0ce8599b1d7160ea5b8 Mon Sep 17 00:00:00 2001 From: "Dr. Stefan Schimanski" Date: Sat, 27 Jul 2024 16:49:00 +0200 Subject: [PATCH] kube-apiserver/leaderelection/test: fixing waiting for informer Signed-off-by: Dr. Stefan Schimanski --- .../leaderelection/leasecandidategc_controller_test.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pkg/controlplane/controller/leaderelection/leasecandidategc_controller_test.go b/pkg/controlplane/controller/leaderelection/leasecandidategc_controller_test.go index b845d62b8dd..0a381809dfc 100644 --- a/pkg/controlplane/controller/leaderelection/leasecandidategc_controller_test.go +++ b/pkg/controlplane/controller/leaderelection/leasecandidategc_controller_test.go @@ -115,9 +115,6 @@ func TestLeaseCandidateGCController(t *testing.T) { leaseCandidateInformer := informerFactory.Coordination().V1alpha1().LeaseCandidates() controller := NewLeaseCandidateGC(client, 10*time.Millisecond, leaseCandidateInformer) - informerFactory.Start(ctx.Done()) - informerFactory.WaitForCacheSync(ctx.Done()) - // Create lease candidates for _, lc := range tc.leaseCandidates { _, err := client.CoordinationV1alpha1().LeaseCandidates(lc.Namespace).Create(ctx, lc, metav1.CreateOptions{}) @@ -126,7 +123,8 @@ func TestLeaseCandidateGCController(t *testing.T) { } } - cache.WaitForCacheSync(ctx.Done(), controller.leaseCandidatesSynced) + informerFactory.Start(ctx.Done()) + informerFactory.WaitForCacheSync(ctx.Done()) go controller.Run(ctx) err := wait.PollUntilContextTimeout(ctx, 100*time.Millisecond, 600*time.Second, true, func(ctx context.Context) (done bool, err error) {