From aa0ef26953535a05b762388f85da72b9049822b9 Mon Sep 17 00:00:00 2001 From: Yuki Iwai Date: Fri, 8 Mar 2024 05:06:18 +0900 Subject: [PATCH] WIP: JobTest: TestSuccessPolicy_GetCompleteConditionAfterAllPodsAreTerminated Signed-off-by: Yuki Iwai --- test/integration/job/job_test.go | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/test/integration/job/job_test.go b/test/integration/job/job_test.go index 32e28edd0d16..9e8a56ae2829 100644 --- a/test/integration/job/job_test.go +++ b/test/integration/job/job_test.go @@ -825,10 +825,20 @@ func TestSuccessPolicy_GetCompleteConditionAfterAllPodsAreTerminated(t *testing. }) validateIndexedJobPods(ctx, t, clientSet, jobObj, sets.New[int](), "0", nil) - // Verify the job has "SuccessCriteriaMet" and doesn't have "Complete" since all pods are still counting. - validateJobCondition(ctx, t, clientSet, jobObj, batchv1.JobSuccessCriteriaMet) - if getJobConditionStatus(ctx, jobObj, batchv1.JobComplete) != "" { - t.Fatalf("Should not get Complete condition, yet") + if err = wait.PollUntilContextTimeout(ctx, 10*time.Millisecond, time.Minute, true, func(ctx context.Context) (bool, error) { + job, err := clientSet.BatchV1().Jobs(jobObj.Namespace).Get(ctx, jobObj.Name, metav1.GetOptions{}) + if err != nil { + return true, err + } + if getJobConditionStatus(ctx, job, batchv1.JobSuccessCriteriaMet) != v1.ConditionTrue { + return true, nil + } + if getJobConditionStatus(ctx, job, batchv1.JobComplete) != "" { + t.Fatalf("Should not added Complete condition, yet") + } + return false, nil + }); err != nil { + t.Fatalf("Job should have only SuccessCriteriaMet, and should not have Complete") } // Verify if the Job get Complete condition after the next reconciliation.