kube-apiserver/leaderelection/test: fixing waiting for informer

Signed-off-by: Dr. Stefan Schimanski <stefan.schimanski@gmail.com>
This commit is contained in:
Dr. Stefan Schimanski 2024-07-27 16:49:00 +02:00 committed by Jefftree
parent cd69335542
commit 8c971c5c15

View File

@ -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) {