@@ -326,55 +326,44 @@ func TestReconcileBatchJob(t *testing.T) {
326
326
g := gomega .NewGomegaWithT (t )
327
327
mockManagerClient .EXPECT ().DeleteTrialObservationLog (gomock .Any ()).Return (nil , nil )
328
328
329
- trial := newFakeTrialBatchJob (commonv1beta1 .StdOutCollector , "test-failed-batch-job" )
330
- trialKey := types.NamespacedName {Name : "test-failed-batch-job" , Namespace : namespace }
329
+ // Manually update BatchJob status to failed
331
330
batchJob := & batchv1.Job {}
331
+ batchJobFailedMessage := "BatchJob completed test message"
332
+ batchJobFailedReason := "BatchJob completed test reason"
333
+ g .Expect (c .Get (ctx , batchJobKey , batchJob )).NotTo (gomega .HaveOccurred ())
334
+ g .Expect (c .Get (ctx , batchJobKey , batchJob )).Should (gomega .Succeed ())
335
+ batchJob .Status = batchv1.JobStatus {
336
+ Conditions : []batchv1.JobCondition {
337
+ {
338
+ Type : batchv1 .JobFailureTarget ,
339
+ Status : corev1 .ConditionTrue ,
340
+ Message : batchJobFailedMessage ,
341
+ Reason : batchJobFailedReason ,
342
+ },
343
+ {
344
+ Type : batchv1 .JobFailed ,
345
+ Status : corev1 .ConditionTrue ,
346
+ Message : batchJobFailedMessage ,
347
+ Reason : batchJobFailedReason ,
348
+ },
349
+ {
350
+ Type : batchv1 .JobSuccessCriteriaMet ,
351
+ Status : corev1 .ConditionFalse ,
352
+ Message : batchJobFailedMessage ,
353
+ Reason : batchJobFailedReason ,
354
+ },
355
+ },
356
+ StartTime : & metav1.Time {Time : startTime },
357
+ }
358
+ g .Expect (c .Status ().Update (ctx , batchJob )).Should (gomega .Succeed ())
332
359
333
360
// Create the Trial with StdOut MC
361
+ trial := newFakeTrialBatchJob (commonv1beta1 .StdOutCollector , "test-failed-batch-job" )
362
+ trialKey := types.NamespacedName {Name : "test-failed-batch-job" , Namespace : namespace }
334
363
g .Expect (c .Create (ctx , trial )).NotTo (gomega .HaveOccurred ())
335
364
336
- // Expect that BatchJob with appropriate name is created
337
- g .Eventually (func (g gomega.Gomega ) {
338
- g .Expect (c .Get (ctx , batchJobKey , batchJob )).Should (gomega .Succeed ())
339
- }, timeout ).Should (gomega .Succeed ())
340
-
341
- // Expect that Trial status is running
342
- g .Eventually (func (g gomega.Gomega ) {
343
- g .Expect (c .Get (ctx , trialKey , trial )).Should (gomega .Succeed ())
344
- t .Log (* trial )
345
- g .Expect (trial .IsRunning ()).Should (gomega .BeTrue ())
346
- }, timeout ).Should (gomega .Succeed ())
347
-
348
- // Manually update BatchJob status to failed
349
365
// Expect that Trial status is failed
350
- batchJobFailedMessage := "BatchJob completed test message"
351
- batchJobFailedReason := "BatchJob completed test reason"
352
366
g .Eventually (func (g gomega.Gomega ) {
353
- g .Expect (c .Get (ctx , batchJobKey , batchJob )).Should (gomega .Succeed ())
354
- batchJob .Status = batchv1.JobStatus {
355
- Conditions : []batchv1.JobCondition {
356
- {
357
- Type : batchv1 .JobFailureTarget ,
358
- Status : corev1 .ConditionTrue ,
359
- Message : batchJobFailedMessage ,
360
- Reason : batchJobFailedReason ,
361
- },
362
- {
363
- Type : batchv1 .JobFailed ,
364
- Status : corev1 .ConditionTrue ,
365
- Message : batchJobFailedMessage ,
366
- Reason : batchJobFailedReason ,
367
- },
368
- {
369
- Type : batchv1 .JobSuccessCriteriaMet ,
370
- Status : corev1 .ConditionFalse ,
371
- Message : batchJobFailedMessage ,
372
- Reason : batchJobFailedReason ,
373
- },
374
- },
375
- StartTime : & metav1.Time {Time : startTime },
376
- }
377
- g .Expect (c .Status ().Update (ctx , batchJob )).Should (gomega .Succeed ())
378
367
g .Expect (c .Get (ctx , trialKey , trial )).Should (gomega .Succeed ())
379
368
g .Expect (trial .IsFailed ()).Should (gomega .BeTrue ())
380
369
}, timeout ).Should (gomega .Succeed ())
0 commit comments