From ec983bd3fb99313a8ae9069c89ea3f51019a4ae4 Mon Sep 17 00:00:00 2001 From: Michal Wozniak Date: Wed, 16 Oct 2024 18:45:11 +0200 Subject: [PATCH] Use Consistently in the e2e for Job --- test/e2e/apps/job.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/test/e2e/apps/job.go b/test/e2e/apps/job.go index ebc9b5e9110..4d356bc9cc7 100644 --- a/test/e2e/apps/job.go +++ b/test/e2e/apps/job.go @@ -1257,12 +1257,11 @@ done`} framework.ExpectNoError(err, "failed to create job in namespace: %s/%s", job.Namespace, job.Name) ginkgo.By(fmt.Sprintf("Verify the Job %s/%s status isn't updated by the built-in controller", job.Namespace, job.Name)) - // Wait a little to give the built-in Job controller time to update the - // status (if it was enabled) - time.Sleep(time.Second) - job, err = e2ejob.GetJob(ctx, f.ClientSet, f.Namespace.Name, job.Name) - framework.ExpectNoError(err, "failed to get the latest object for the Job %s/%s", job.Namespace, job.Name) - gomega.Expect(job.Status).To(gomega.BeEquivalentTo(batchv1.JobStatus{}), "expected status for the Job %s/%s to be empty", job.Namespace, job.Name) + // This get function uses HandleRetry to retry on transient API errors + get := framework.GetObject(f.ClientSet.BatchV1().Jobs(f.Namespace.Name).Get, job.Name, metav1.GetOptions{}) + gomega.Consistently(ctx, get). + WithPolling(time.Second).WithTimeout(3 * time.Second). + Should(gomega.HaveField("Status", gomega.BeEquivalentTo(batchv1.JobStatus{}))) }) })