@@ -280,31 +280,18 @@ var _ = SIGDescribe("Job", func() {
280
280
job , err := e2ejob .CreateJob (ctx , f .ClientSet , f .Namespace .Name , job )
281
281
framework .ExpectNoError (err , "failed to create job in namespace: %s" , f .Namespace .Name )
282
282
283
- ginkgo .By ("Ensuring pods aren't created for job" )
284
- err = framework .Gomega ().Consistently (ctx , framework .HandleRetry (func (ctx context.Context ) ([]v1.Pod , error ) {
285
- pods , err := e2ejob .GetJobPods (ctx , f .ClientSet , f .Namespace .Name , job .Name )
286
- if err != nil {
287
- return nil , fmt .Errorf ("failed to list pod for a given job %s in namespace %s: %w" , job .Name , f .Namespace .Name , err )
288
- }
289
- return pods .Items , nil
290
- })).WithPolling (framework .Poll ).WithTimeout (wait .ForeverTestTimeout ).Should (gomega .BeEmpty ())
291
- framework .ExpectNoError (err , "failed to confirm that pods aren't created for job %s in namespace %s" , job .Name , f .Namespace .Name )
292
-
293
283
ginkgo .By ("Checking Job status to observe Suspended state" )
294
- job , err = e2ejob .GetJob (ctx , f .ClientSet , f .Namespace .Name , job .Name )
295
- framework .ExpectNoError (err , "failed to retrieve latest job object" )
296
- exists := false
297
- for _ , c := range job .Status .Conditions {
298
- if c .Type == batchv1 .JobSuspended {
299
- exists = true
300
- break
301
- }
302
- }
303
- if ! exists {
304
- framework .Failf ("Job was expected to be completed or failed" )
305
- }
284
+ err = e2ejob .WaitForJobSuspend (ctx , f .ClientSet , f .Namespace .Name , job .Name )
285
+ framework .ExpectNoError (err , "failed to observe suspend state: %s" , f .Namespace .Name )
286
+
287
+ ginkgo .By ("Ensuring pods aren't created for job" )
288
+ pods , err := e2ejob .GetJobPods (ctx , f .ClientSet , f .Namespace .Name , job .Name )
289
+ framework .ExpectNoError (err , "failed to list pod for a given job %s in namespace %s" , job .Name , f .Namespace .Name )
290
+ gomega .Expect (pods .Items ).To (gomega .BeEmpty ())
306
291
307
292
ginkgo .By ("Updating the job with suspend=false" )
293
+ job , err = f .ClientSet .BatchV1 ().Jobs (f .Namespace .Name ).Get (ctx , job .Name , metav1.GetOptions {})
294
+ framework .ExpectNoError (err , "failed to get job in namespace: %s" , f .Namespace .Name )
308
295
job .Spec .Suspend = pointer .BoolPtr (false )
309
296
job , err = e2ejob .UpdateJob (ctx , f .ClientSet , f .Namespace .Name , job )
310
297
framework .ExpectNoError (err , "failed to update job in namespace: %s" , f .Namespace .Name )
0 commit comments