@@ -196,7 +196,7 @@ var _ = Describe("PyTorchJob controller", func() {
196
196
Expect (cond .Status ).To (Equal (corev1 .ConditionTrue ))
197
197
})
198
198
199
- It ("Shouldn't create resources if PyTorchJob is suspended; Should create resources once PyTorchJob is unsuspended " , func () {
199
+ It ("Shouldn't create resources if PyTorchJob is suspended" , func () {
200
200
By ("By creating a new PyTorchJob with suspend=true" )
201
201
job .Spec .RunPolicy .Suspend = pointer .Bool (true )
202
202
job .Spec .PyTorchReplicaSpecs [kubeflowv1 .PyTorchJobReplicaTypeWorker ].Replicas = pointer .Int32 (1 )
@@ -247,68 +247,6 @@ var _ = Describe("PyTorchJob controller", func() {
247
247
Message : fmt .Sprintf ("PyTorchJob %s is suspended." , name ),
248
248
},
249
249
}, testutil .IgnoreJobConditionsTimes ))
250
-
251
- By ("Unsuspending the PyTorchJob" )
252
- Eventually (func () error {
253
- Expect (testK8sClient .Get (ctx , jobKey , created )).Should (Succeed ())
254
- created .Spec .RunPolicy .Suspend = pointer .Bool (false )
255
- return testK8sClient .Update (ctx , created )
256
- }, testutil .Timeout , testutil .Interval ).Should (Succeed ())
257
- Eventually (func () * metav1.Time {
258
- Expect (testK8sClient .Get (ctx , jobKey , created )).Should (Succeed ())
259
- return created .Status .StartTime
260
- }, testutil .Timeout , testutil .Interval ).ShouldNot (BeNil ())
261
-
262
- By ("Check if the pods and services are created" )
263
- Eventually (func () error {
264
- return testK8sClient .Get (ctx , masterKey , masterPod )
265
- }, testutil .Timeout , testutil .Interval ).Should (BeNil ())
266
- Eventually (func () error {
267
- return testK8sClient .Get (ctx , worker0Key , workerPod )
268
- }, testutil .Timeout , testutil .Interval ).Should (BeNil ())
269
- Eventually (func () error {
270
- return testK8sClient .Get (ctx , masterKey , masterSvc )
271
- }, testutil .Timeout , testutil .Interval ).Should (BeNil ())
272
- Eventually (func () error {
273
- return testK8sClient .Get (ctx , worker0Key , workerSvc )
274
- }, testutil .Timeout , testutil .Interval ).Should (BeNil ())
275
-
276
- By ("Updating Pod's condition with running" )
277
- Eventually (func () error {
278
- Expect (testK8sClient .Get (ctx , masterKey , masterPod )).Should (Succeed ())
279
- masterPod .Status .Phase = corev1 .PodRunning
280
- return testK8sClient .Status ().Update (ctx , masterPod )
281
- }, testutil .Timeout , testutil .Interval ).Should (Succeed ())
282
- Eventually (func () error {
283
- Expect (testK8sClient .Get (ctx , worker0Key , workerPod )).Should (Succeed ())
284
- workerPod .Status .Phase = corev1 .PodRunning
285
- return testK8sClient .Status ().Update (ctx , workerPod )
286
- }, testutil .Timeout , testutil .Interval ).Should (Succeed ())
287
-
288
- By ("Checking the PyTorchJob has resumed conditions" )
289
- Eventually (func () []kubeflowv1.JobCondition {
290
- Expect (testK8sClient .Get (ctx , jobKey , created )).Should (Succeed ())
291
- return created .Status .Conditions
292
- }, testutil .Timeout , testutil .Interval ).Should (BeComparableTo ([]kubeflowv1.JobCondition {
293
- {
294
- Type : kubeflowv1 .JobCreated ,
295
- Status : corev1 .ConditionTrue ,
296
- Reason : commonutil .NewReason (kubeflowv1 .PytorchJobKind , commonutil .JobCreatedReason ),
297
- Message : fmt .Sprintf ("PyTorchJob %s is created." , name ),
298
- },
299
- {
300
- Type : kubeflowv1 .JobSuspended ,
301
- Status : corev1 .ConditionFalse ,
302
- Reason : commonutil .NewReason (kubeflowv1 .PytorchJobKind , commonutil .JobResumedReason ),
303
- Message : fmt .Sprintf ("PyTorchJob %s is resumed." , name ),
304
- },
305
- {
306
- Type : kubeflowv1 .JobRunning ,
307
- Status : corev1 .ConditionTrue ,
308
- Reason : commonutil .NewReason (kubeflowv1 .PytorchJobKind , commonutil .JobRunningReason ),
309
- Message : fmt .Sprintf ("PyTorchJob %s is running." , name ),
310
- },
311
- }, testutil .IgnoreJobConditionsTimes ))
312
250
})
313
251
314
252
It ("Should delete resources after PyTorchJob is suspended; Should resume PyTorchJob after PyTorchJob is unsuspended" , func () {
@@ -440,23 +378,42 @@ var _ = Describe("PyTorchJob controller", func() {
440
378
},
441
379
}, testutil .IgnoreJobConditionsTimes ))
442
380
443
- By ("Updating the PytorchJob with suspend=false " )
381
+ By ("Unsuspending the PyTorchJob " )
444
382
Eventually (func () error {
445
383
Expect (testK8sClient .Get (ctx , jobKey , created )).Should (Succeed ())
446
384
created .Spec .RunPolicy .Suspend = pointer .Bool (false )
447
385
return testK8sClient .Update (ctx , created )
448
386
}, testutil .Timeout , testutil .Interval ).Should (Succeed ())
387
+ Eventually (func () * metav1.Time {
388
+ Expect (testK8sClient .Get (ctx , jobKey , created )).Should (Succeed ())
389
+ return created .Status .StartTime
390
+ }, testutil .Timeout , testutil .Interval ).ShouldNot (BeNil ())
449
391
450
- By ("Updating the pod's phase with Running " )
392
+ By ("Check if the pods and services are created " )
451
393
Eventually (func () error {
452
- errMaster := testK8sClient .Get (ctx , masterKey , masterPod )
453
- return errMaster
454
- }, testutil .Timeout , testutil .Interval ).Should (Succeed ())
394
+ return testK8sClient .Get (ctx , masterKey , masterPod )
395
+ }, testutil .Timeout , testutil .Interval ).Should (BeNil ())
396
+ Eventually (func () error {
397
+ return testK8sClient .Get (ctx , worker0Key , workerPod )
398
+ }, testutil .Timeout , testutil .Interval ).Should (BeNil ())
399
+ Eventually (func () error {
400
+ return testK8sClient .Get (ctx , masterKey , masterSvc )
401
+ }, testutil .Timeout , testutil .Interval ).Should (BeNil ())
402
+ Eventually (func () error {
403
+ return testK8sClient .Get (ctx , worker0Key , workerSvc )
404
+ }, testutil .Timeout , testutil .Interval ).Should (BeNil ())
405
+
406
+ By ("Updating Pod's condition with running" )
455
407
Eventually (func () error {
456
408
Expect (testK8sClient .Get (ctx , masterKey , masterPod )).Should (Succeed ())
457
409
masterPod .Status .Phase = corev1 .PodRunning
458
410
return testK8sClient .Status ().Update (ctx , masterPod )
459
411
}, testutil .Timeout , testutil .Interval ).Should (Succeed ())
412
+ Eventually (func () error {
413
+ Expect (testK8sClient .Get (ctx , worker0Key , workerPod )).Should (Succeed ())
414
+ workerPod .Status .Phase = corev1 .PodRunning
415
+ return testK8sClient .Status ().Update (ctx , workerPod )
416
+ }, testutil .Timeout , testutil .Interval ).Should (Succeed ())
460
417
461
418
By ("Checking if the PyTorchJob has resumed conditions" )
462
419
Eventually (func () []kubeflowv1.JobCondition {
0 commit comments