Skip to content

Commit ffb736e

Browse files
committed
Remove duplicated test case for unsuspending PyTorchJobs
Signed-off-by: Yuki Iwai <[email protected]>
1 parent b397f7b commit ffb736e

File tree

1 file changed

+25
-68
lines changed

1 file changed

+25
-68
lines changed

pkg/controller.v1/pytorch/pytorchjob_controller_test.go

+25-68
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ var _ = Describe("PyTorchJob controller", func() {
196196
Expect(cond.Status).To(Equal(corev1.ConditionTrue))
197197
})
198198

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() {
200200
By("By creating a new PyTorchJob with suspend=true")
201201
job.Spec.RunPolicy.Suspend = pointer.Bool(true)
202202
job.Spec.PyTorchReplicaSpecs[kubeflowv1.PyTorchJobReplicaTypeWorker].Replicas = pointer.Int32(1)
@@ -247,68 +247,6 @@ var _ = Describe("PyTorchJob controller", func() {
247247
Message: fmt.Sprintf("PyTorchJob %s is suspended.", name),
248248
},
249249
}, 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))
312250
})
313251

314252
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() {
440378
},
441379
}, testutil.IgnoreJobConditionsTimes))
442380

443-
By("Updating the PytorchJob with suspend=false")
381+
By("Unsuspending the PyTorchJob")
444382
Eventually(func() error {
445383
Expect(testK8sClient.Get(ctx, jobKey, created)).Should(Succeed())
446384
created.Spec.RunPolicy.Suspend = pointer.Bool(false)
447385
return testK8sClient.Update(ctx, created)
448386
}, 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())
449391

450-
By("Updating the pod's phase with Running")
392+
By("Check if the pods and services are created")
451393
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")
455407
Eventually(func() error {
456408
Expect(testK8sClient.Get(ctx, masterKey, masterPod)).Should(Succeed())
457409
masterPod.Status.Phase = corev1.PodRunning
458410
return testK8sClient.Status().Update(ctx, masterPod)
459411
}, 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())
460417

461418
By("Checking if the PyTorchJob has resumed conditions")
462419
Eventually(func() []kubeflowv1.JobCondition {

0 commit comments

Comments
 (0)