@@ -128,16 +128,16 @@ var _ = ginkgo.Describe("MPIJob", func() {
128
128
mpiJob .Spec .RunPolicy .Suspend = pointer .Bool (true )
129
129
})
130
130
ginkgo .It ("should not create pods when suspended and succeed when resumed" , func () {
131
- mpiJob := createJob (mpiJob )
132
-
133
131
ctx := context .Background ()
132
+ mpiJob := createJob (ctx , mpiJob )
133
+
134
134
ginkgo .By ("verifying there are no pods (neither launcher nor pods) running for the suspended MPIJob" )
135
135
pods , err := k8sClient .CoreV1 ().Pods (mpiJob .Namespace ).List (ctx , metav1.ListOptions {})
136
136
gomega .Expect (err ).ToNot (gomega .HaveOccurred ())
137
137
gomega .Expect (pods .Items ).To (gomega .HaveLen (0 ))
138
138
139
- mpiJob = resumeJob (mpiJob )
140
- mpiJob = waitForCompletion (mpiJob )
139
+ mpiJob = resumeJob (ctx , mpiJob )
140
+ mpiJob = waitForCompletion (ctx , mpiJob )
141
141
expectConditionToBeTrue (mpiJob , kubeflow .JobSucceeded )
142
142
})
143
143
})
@@ -231,8 +231,7 @@ var _ = ginkgo.Describe("MPIJob", func() {
231
231
})
232
232
})
233
233
234
- func resumeJob (mpiJob * kubeflow.MPIJob ) * kubeflow.MPIJob {
235
- ctx := context .Background ()
234
+ func resumeJob (ctx context.Context , mpiJob * kubeflow.MPIJob ) * kubeflow.MPIJob {
236
235
mpiJob .Spec .RunPolicy .Suspend = pointer .Bool (false )
237
236
ginkgo .By ("Resuming MPIJob" )
238
237
mpiJob , err := mpiClient .KubeflowV2beta1 ().MPIJobs (mpiJob .Namespace ).Update (ctx , mpiJob , metav1.UpdateOptions {})
@@ -241,21 +240,20 @@ func resumeJob(mpiJob *kubeflow.MPIJob) *kubeflow.MPIJob {
241
240
}
242
241
243
242
func createJobAndWaitForCompletion (mpiJob * kubeflow.MPIJob ) * kubeflow.MPIJob {
244
- mpiJob = createJob (mpiJob )
245
- return waitForCompletion (mpiJob )
243
+ ctx := context .Background ()
244
+ mpiJob = createJob (ctx , mpiJob )
245
+ return waitForCompletion (ctx , mpiJob )
246
246
}
247
247
248
- func createJob (mpiJob * kubeflow.MPIJob ) * kubeflow.MPIJob {
249
- ctx := context .Background ()
248
+ func createJob (ctx context.Context , mpiJob * kubeflow.MPIJob ) * kubeflow.MPIJob {
250
249
ginkgo .By ("Creating MPIJob" )
251
250
mpiJob , err := mpiClient .KubeflowV2beta1 ().MPIJobs (mpiJob .Namespace ).Create (ctx , mpiJob , metav1.CreateOptions {})
252
251
gomega .Expect (err ).ToNot (gomega .HaveOccurred ())
253
252
return mpiJob
254
253
}
255
254
256
- func waitForCompletion (mpiJob * kubeflow.MPIJob ) * kubeflow.MPIJob {
255
+ func waitForCompletion (ctx context. Context , mpiJob * kubeflow.MPIJob ) * kubeflow.MPIJob {
257
256
var err error
258
- ctx := context .Background ()
259
257
260
258
ginkgo .By ("Waiting for MPIJob to finish" )
261
259
err = wait .Poll (waitInterval , foreverTimeout , func () (bool , error ) {
0 commit comments