@@ -1414,6 +1414,7 @@ func TestJobBackoffForOnFailure(t *testing.T) {
1414
1414
// pod setup
1415
1415
jobKeyForget bool
1416
1416
restartCounts []int32
1417
+ podPhase v1.PodPhase
1417
1418
1418
1419
// expectations
1419
1420
expectedActive int32
@@ -1424,32 +1425,47 @@ func TestJobBackoffForOnFailure(t *testing.T) {
1424
1425
}{
1425
1426
"backoffLimit 0 should have 1 pod active" : {
1426
1427
1 , 1 , 0 ,
1427
- true , []int32 {0 },
1428
+ true , []int32 {0 }, v1 . PodRunning ,
1428
1429
1 , 0 , 0 , nil , "" ,
1429
1430
},
1430
1431
"backoffLimit 1 with restartCount 0 should have 1 pod active" : {
1431
1432
1 , 1 , 1 ,
1432
- true , []int32 {0 },
1433
+ true , []int32 {0 }, v1 . PodRunning ,
1433
1434
1 , 0 , 0 , nil , "" ,
1434
1435
},
1435
- "backoffLimit 1 with restartCount 1 should have 0 pod active" : {
1436
+ "backoffLimit 1 with restartCount 1 and podRunning should have 0 pod active" : {
1436
1437
1 , 1 , 1 ,
1437
- true , []int32 {1 },
1438
+ true , []int32 {1 }, v1 . PodRunning ,
1438
1439
0 , 0 , 1 , & jobConditionFailed , "BackoffLimitExceeded" ,
1439
1440
},
1440
- "too many job failures - single pod" : {
1441
+ "backoffLimit 1 with restartCount 1 and podPending should have 0 pod active" : {
1442
+ 1 , 1 , 1 ,
1443
+ true , []int32 {1 }, v1 .PodPending ,
1444
+ 0 , 0 , 1 , & jobConditionFailed , "BackoffLimitExceeded" ,
1445
+ },
1446
+ "too many job failures with podRunning - single pod" : {
1441
1447
1 , 5 , 2 ,
1442
- true , []int32 {2 },
1448
+ true , []int32 {2 }, v1 . PodRunning ,
1443
1449
0 , 0 , 1 , & jobConditionFailed , "BackoffLimitExceeded" ,
1444
1450
},
1445
- "too many job failures - multiple pods" : {
1451
+ "too many job failures with podPending - single pod" : {
1452
+ 1 , 5 , 2 ,
1453
+ true , []int32 {2 }, v1 .PodPending ,
1454
+ 0 , 0 , 1 , & jobConditionFailed , "BackoffLimitExceeded" ,
1455
+ },
1456
+ "too many job failures with podRunning - multiple pods" : {
1457
+ 2 , 5 , 2 ,
1458
+ true , []int32 {1 , 1 }, v1 .PodRunning ,
1459
+ 0 , 0 , 2 , & jobConditionFailed , "BackoffLimitExceeded" ,
1460
+ },
1461
+ "too many job failures with podPending - multiple pods" : {
1446
1462
2 , 5 , 2 ,
1447
- true , []int32 {1 , 1 },
1463
+ true , []int32 {1 , 1 }, v1 . PodPending ,
1448
1464
0 , 0 , 2 , & jobConditionFailed , "BackoffLimitExceeded" ,
1449
1465
},
1450
1466
"not enough failures" : {
1451
1467
2 , 5 , 3 ,
1452
- true , []int32 {1 , 1 },
1468
+ true , []int32 {1 , 1 }, v1 . PodRunning ,
1453
1469
2 , 0 , 0 , nil , "" ,
1454
1470
},
1455
1471
}
@@ -1474,7 +1490,7 @@ func TestJobBackoffForOnFailure(t *testing.T) {
1474
1490
job .Spec .Template .Spec .RestartPolicy = v1 .RestartPolicyOnFailure
1475
1491
sharedInformerFactory .Batch ().V1 ().Jobs ().Informer ().GetIndexer ().Add (job )
1476
1492
podIndexer := sharedInformerFactory .Core ().V1 ().Pods ().Informer ().GetIndexer ()
1477
- for i , pod := range newPodList (int32 (len (tc .restartCounts )), v1 . PodRunning , job ) {
1493
+ for i , pod := range newPodList (int32 (len (tc .restartCounts )), tc . podPhase , job ) {
1478
1494
pod .Status .ContainerStatuses = []v1.ContainerStatus {{RestartCount : tc .restartCounts [i ]}}
1479
1495
podIndexer .Add (& pod )
1480
1496
}
0 commit comments