@@ -514,6 +514,7 @@ func TestSuccessPolicy(t *testing.T) {
514
514
wantActiveIndexes sets.Set [int ]
515
515
wantCompletedIndexes string
516
516
wantFailedIndexes * string
517
+ wantTerminating * int32
517
518
}
518
519
519
520
podTemplateSpec := v1.PodTemplateSpec {
@@ -561,6 +562,7 @@ func TestSuccessPolicy(t *testing.T) {
561
562
wantFailed : 0 ,
562
563
wantSucceeded : 1 ,
563
564
wantCompletedIndexes : "0" ,
565
+ wantTerminating : ptr .To (int32 (0 )),
564
566
},
565
567
},
566
568
wantConditionTypes : []batchv1.JobConditionType {batchv1 .JobSuccessCriteriaMet , batchv1 .JobComplete },
@@ -595,6 +597,7 @@ func TestSuccessPolicy(t *testing.T) {
595
597
wantFailed : 0 ,
596
598
wantSucceeded : 1 ,
597
599
wantCompletedIndexes : "0" ,
600
+ wantTerminating : ptr .To (int32 (0 )),
598
601
},
599
602
},
600
603
wantConditionTypes : []batchv1.JobConditionType {batchv1 .JobComplete },
@@ -630,6 +633,7 @@ func TestSuccessPolicy(t *testing.T) {
630
633
wantActiveIndexes : sets .New (0 , 1 ),
631
634
wantFailed : 0 ,
632
635
wantSucceeded : 0 ,
636
+ wantTerminating : ptr .To (int32 (0 )),
633
637
},
634
638
{
635
639
index : 1 ,
@@ -640,6 +644,7 @@ func TestSuccessPolicy(t *testing.T) {
640
644
wantFailed : 0 ,
641
645
wantSucceeded : 1 ,
642
646
wantCompletedIndexes : "1" ,
647
+ wantTerminating : ptr .To (int32 (1 )),
643
648
},
644
649
},
645
650
wantConditionTypes : []batchv1.JobConditionType {batchv1 .JobSuccessCriteriaMet , batchv1 .JobComplete },
@@ -675,6 +680,7 @@ func TestSuccessPolicy(t *testing.T) {
675
680
wantActiveIndexes : sets .New (0 , 1 ),
676
681
wantFailed : 0 ,
677
682
wantSucceeded : 0 ,
683
+ wantTerminating : ptr .To (int32 (0 )),
678
684
},
679
685
{
680
686
index : 1 ,
@@ -685,6 +691,7 @@ func TestSuccessPolicy(t *testing.T) {
685
691
wantFailed : 0 ,
686
692
wantSucceeded : 1 ,
687
693
wantCompletedIndexes : "1" ,
694
+ wantTerminating : ptr .To (int32 (1 )),
688
695
},
689
696
},
690
697
wantConditionTypes : []batchv1.JobConditionType {batchv1 .JobSuccessCriteriaMet , batchv1 .JobComplete },
@@ -723,6 +730,7 @@ func TestSuccessPolicy(t *testing.T) {
723
730
wantFailed : 1 ,
724
731
wantFailedIndexes : ptr .To ("0" ),
725
732
wantSucceeded : 0 ,
733
+ wantTerminating : ptr .To (int32 (0 )),
726
734
},
727
735
{
728
736
index : 1 ,
@@ -734,6 +742,7 @@ func TestSuccessPolicy(t *testing.T) {
734
742
wantSucceeded : 1 ,
735
743
wantFailedIndexes : ptr .To ("0" ),
736
744
wantCompletedIndexes : "1" ,
745
+ wantTerminating : ptr .To (int32 (0 )),
737
746
},
738
747
},
739
748
wantConditionTypes : []batchv1.JobConditionType {batchv1 .JobFailed },
@@ -774,7 +783,7 @@ func TestSuccessPolicy(t *testing.T) {
774
783
Succeeded : podTermination .wantSucceeded ,
775
784
Failed : podTermination .wantFailed ,
776
785
Ready : ptr.To [int32 ](0 ),
777
- Terminating : ptr. To [ int32 ]( 0 ) ,
786
+ Terminating : podTermination . wantTerminating ,
778
787
})
779
788
validateIndexedJobPods (ctx , t , clientSet , jobObj , podTermination .wantActiveIndexes , podTermination .wantCompletedIndexes , podTermination .wantFailedIndexes )
780
789
}
@@ -861,7 +870,7 @@ func TestSuccessPolicy_ReEnabling(t *testing.T) {
861
870
Active : 0 ,
862
871
Succeeded : 3 ,
863
872
Ready : ptr.To [int32 ](0 ),
864
- Terminating : ptr.To [int32 ](0 ),
873
+ Terminating : ptr.To [int32 ](2 ),
865
874
})
866
875
validateIndexedJobPods (ctx , t , clientSet , jobObj , sets .New [int ](), "0-2" , nil )
867
876
@@ -1168,6 +1177,7 @@ func TestBackoffLimitPerIndex(t *testing.T) {
1168
1177
wantCompletedIndexes string
1169
1178
wantFailedIndexes * string
1170
1179
wantReplacementPodFailureCount * int
1180
+ wantTerminating * int32
1171
1181
}
1172
1182
1173
1183
podTemplateSpec := v1.PodTemplateSpec {
@@ -1208,6 +1218,7 @@ func TestBackoffLimitPerIndex(t *testing.T) {
1208
1218
wantActiveIndexes : sets .New (0 , 1 ),
1209
1219
wantFailedIndexes : ptr .To ("" ),
1210
1220
wantReplacementPodFailureCount : ptr .To (1 ),
1221
+ wantTerminating : ptr .To (int32 (0 )),
1211
1222
},
1212
1223
},
1213
1224
wantJobConditionType : batchv1 .JobComplete ,
@@ -1238,6 +1249,7 @@ func TestBackoffLimitPerIndex(t *testing.T) {
1238
1249
wantActiveIndexes : sets .New (0 , 1 ),
1239
1250
wantFailedIndexes : ptr .To ("" ),
1240
1251
wantReplacementPodFailureCount : ptr .To (1 ),
1252
+ wantTerminating : ptr .To (int32 (0 )),
1241
1253
},
1242
1254
{
1243
1255
status : v1.PodStatus {
@@ -1248,6 +1260,7 @@ func TestBackoffLimitPerIndex(t *testing.T) {
1248
1260
wantActiveIndexes : sets .New (0 , 1 ),
1249
1261
wantFailedIndexes : ptr .To ("" ),
1250
1262
wantReplacementPodFailureCount : ptr .To (2 ),
1263
+ wantTerminating : ptr .To (int32 (0 )),
1251
1264
},
1252
1265
{
1253
1266
status : v1.PodStatus {
@@ -1257,6 +1270,7 @@ func TestBackoffLimitPerIndex(t *testing.T) {
1257
1270
wantFailed : 3 ,
1258
1271
wantActiveIndexes : sets .New (1 ),
1259
1272
wantFailedIndexes : ptr .To ("0" ),
1273
+ wantTerminating : ptr .To (int32 (0 )),
1260
1274
},
1261
1275
},
1262
1276
wantJobConditionType : batchv1 .JobFailed ,
@@ -1292,6 +1306,7 @@ func TestBackoffLimitPerIndex(t *testing.T) {
1292
1306
wantFailed : 1 ,
1293
1307
wantActiveIndexes : sets .New (0 , 1 , 2 ),
1294
1308
wantFailedIndexes : ptr .To ("" ),
1309
+ wantTerminating : ptr .To (int32 (0 )),
1295
1310
},
1296
1311
{
1297
1312
index : 1 ,
@@ -1302,6 +1317,7 @@ func TestBackoffLimitPerIndex(t *testing.T) {
1302
1317
wantFailed : 2 ,
1303
1318
wantActiveIndexes : sets .New (0 , 1 , 2 ),
1304
1319
wantFailedIndexes : ptr .To ("" ),
1320
+ wantTerminating : ptr .To (int32 (0 )),
1305
1321
},
1306
1322
{
1307
1323
index : 2 ,
@@ -1310,6 +1326,7 @@ func TestBackoffLimitPerIndex(t *testing.T) {
1310
1326
},
1311
1327
wantFailed : 5 ,
1312
1328
wantFailedIndexes : ptr .To ("" ),
1329
+ wantTerminating : ptr .To (int32 (2 )),
1313
1330
},
1314
1331
},
1315
1332
wantJobConditionType : batchv1 .JobFailed ,
@@ -1344,6 +1361,7 @@ func TestBackoffLimitPerIndex(t *testing.T) {
1344
1361
wantFailed : 1 ,
1345
1362
wantActiveIndexes : sets .New (1 ),
1346
1363
wantFailedIndexes : ptr .To ("0" ),
1364
+ wantTerminating : ptr .To (int32 (0 )),
1347
1365
},
1348
1366
{
1349
1367
index : 1 ,
@@ -1354,6 +1372,7 @@ func TestBackoffLimitPerIndex(t *testing.T) {
1354
1372
wantSucceeded : 1 ,
1355
1373
wantFailedIndexes : ptr .To ("0" ),
1356
1374
wantCompletedIndexes : "1" ,
1375
+ wantTerminating : ptr .To (int32 (0 )),
1357
1376
},
1358
1377
},
1359
1378
wantJobConditionType : batchv1 .JobFailed ,
@@ -1389,6 +1408,7 @@ func TestBackoffLimitPerIndex(t *testing.T) {
1389
1408
wantFailed : 1 ,
1390
1409
wantActiveIndexes : sets .New (1 , 2 ),
1391
1410
wantFailedIndexes : ptr .To ("0" ),
1411
+ wantTerminating : ptr .To (int32 (0 )),
1392
1412
},
1393
1413
{
1394
1414
index : 1 ,
@@ -1398,6 +1418,7 @@ func TestBackoffLimitPerIndex(t *testing.T) {
1398
1418
wantActive : 0 ,
1399
1419
wantFailed : 3 ,
1400
1420
wantFailedIndexes : ptr .To ("0,1" ),
1421
+ wantTerminating : ptr .To (int32 (1 )),
1401
1422
},
1402
1423
},
1403
1424
wantJobConditionType : batchv1 .JobFailed ,
@@ -1457,6 +1478,7 @@ func TestBackoffLimitPerIndex(t *testing.T) {
1457
1478
wantFailed : 1 ,
1458
1479
wantActiveIndexes : sets .New (1 ),
1459
1480
wantFailedIndexes : ptr .To ("0" ),
1481
+ wantTerminating : ptr .To (int32 (0 )),
1460
1482
},
1461
1483
{
1462
1484
index : 1 ,
@@ -1471,6 +1493,7 @@ func TestBackoffLimitPerIndex(t *testing.T) {
1471
1493
},
1472
1494
wantFailed : 2 ,
1473
1495
wantFailedIndexes : ptr .To ("0,1" ),
1496
+ wantTerminating : ptr .To (int32 (0 )),
1474
1497
},
1475
1498
},
1476
1499
wantJobConditionType : batchv1 .JobFailed ,
@@ -1517,7 +1540,7 @@ func TestBackoffLimitPerIndex(t *testing.T) {
1517
1540
Succeeded : podTermination .wantSucceeded ,
1518
1541
Failed : podTermination .wantFailed ,
1519
1542
Ready : ptr.To [int32 ](0 ),
1520
- Terminating : ptr. To [ int32 ]( 0 ) ,
1543
+ Terminating : podTermination . wantTerminating ,
1521
1544
})
1522
1545
validateIndexedJobPods (ctx , t , clientSet , jobObj , podTermination .wantActiveIndexes , podTermination .wantCompletedIndexes , podTermination .wantFailedIndexes )
1523
1546
if podTermination .wantReplacementPodFailureCount != nil {
@@ -2730,6 +2753,7 @@ func TestElasticIndexedJob(t *testing.T) {
2730
2753
wantFailed int
2731
2754
wantRemainingIndexes sets.Set [int ]
2732
2755
wantActivePods int
2756
+ wantTerminating * int32
2733
2757
}
2734
2758
cases := map [string ]struct {
2735
2759
featureGate bool
@@ -2739,7 +2763,8 @@ func TestElasticIndexedJob(t *testing.T) {
2739
2763
"feature flag off, mutation not allowed" : {
2740
2764
jobUpdates : []jobUpdate {
2741
2765
{
2742
- completions : ptr.To [int32 ](4 ),
2766
+ completions : ptr.To [int32 ](4 ),
2767
+ wantTerminating : ptr.To [int32 ](0 ),
2743
2768
},
2744
2769
},
2745
2770
wantErr : apierrors .NewInvalid (
@@ -2756,6 +2781,7 @@ func TestElasticIndexedJob(t *testing.T) {
2756
2781
completions : ptr.To [int32 ](4 ),
2757
2782
succeedIndexes : []int {0 , 1 , 2 , 3 },
2758
2783
wantSucceededIndexes : "0-3" ,
2784
+ wantTerminating : ptr.To [int32 ](0 ),
2759
2785
},
2760
2786
},
2761
2787
},
@@ -2770,6 +2796,7 @@ func TestElasticIndexedJob(t *testing.T) {
2770
2796
wantFailed : 1 ,
2771
2797
wantRemainingIndexes : sets .New (0 , 2 ),
2772
2798
wantActivePods : 2 ,
2799
+ wantTerminating : ptr.To [int32 ](0 ),
2773
2800
},
2774
2801
// Scale down completions 3->1, verify prev failure out of range still counts
2775
2802
// but succeeded out of range does not.
@@ -2778,6 +2805,7 @@ func TestElasticIndexedJob(t *testing.T) {
2778
2805
succeedIndexes : []int {0 },
2779
2806
wantSucceededIndexes : "0" ,
2780
2807
wantFailed : 1 ,
2808
+ wantTerminating : ptr.To [int32 ](0 ),
2781
2809
},
2782
2810
},
2783
2811
},
@@ -2790,26 +2818,30 @@ func TestElasticIndexedJob(t *testing.T) {
2790
2818
wantSucceededIndexes : "2" ,
2791
2819
wantRemainingIndexes : sets .New (0 , 1 ),
2792
2820
wantActivePods : 2 ,
2821
+ wantTerminating : ptr.To [int32 ](0 ),
2793
2822
},
2794
2823
// Scale completions down 3->2 to exclude previously succeeded index.
2795
2824
{
2796
2825
completions : ptr.To [int32 ](2 ),
2797
2826
wantRemainingIndexes : sets .New (0 , 1 ),
2798
2827
wantActivePods : 2 ,
2828
+ wantTerminating : ptr.To [int32 ](0 ),
2799
2829
},
2800
2830
// Scale completions back up to include previously succeeded index that was temporarily out of range.
2801
2831
{
2802
2832
completions : ptr.To [int32 ](3 ),
2803
2833
succeedIndexes : []int {0 , 1 , 2 },
2804
2834
wantSucceededIndexes : "0-2" ,
2835
+ wantTerminating : ptr.To [int32 ](0 ),
2805
2836
},
2806
2837
},
2807
2838
},
2808
2839
"scale down to 0, verify that the job succeeds" : {
2809
2840
featureGate : true ,
2810
2841
jobUpdates : []jobUpdate {
2811
2842
{
2812
- completions : ptr.To [int32 ](0 ),
2843
+ completions : ptr.To [int32 ](0 ),
2844
+ wantTerminating : ptr.To [int32 ](3 ),
2813
2845
},
2814
2846
},
2815
2847
},
@@ -2887,7 +2919,7 @@ func TestElasticIndexedJob(t *testing.T) {
2887
2919
Succeeded : len (update .succeedIndexes ),
2888
2920
Failed : update .wantFailed ,
2889
2921
Ready : ptr.To [int32 ](0 ),
2890
- Terminating : ptr. To [ int32 ]( 0 ) ,
2922
+ Terminating : update . wantTerminating ,
2891
2923
})
2892
2924
validateIndexedJobPods (ctx , t , clientSet , jobObj , update .wantRemainingIndexes , update .wantSucceededIndexes , nil )
2893
2925
}
0 commit comments