@@ -51,6 +51,7 @@ func TestValidateVPA(t *testing.T) {
51
51
isCreate bool
52
52
expectError error
53
53
inPlaceOrRecreateFeatureGateDisabled bool
54
+ PerVPAConfigDisabled bool
54
55
}{
55
56
{
56
57
name : "empty update" ,
@@ -319,10 +320,64 @@ func TestValidateVPA(t *testing.T) {
319
320
},
320
321
},
321
322
},
323
+ {
324
+ name : "per-vpa config active and used" ,
325
+ vpa : vpa_types.VerticalPodAutoscaler {
326
+ Spec : vpa_types.VerticalPodAutoscalerSpec {
327
+ UpdatePolicy : & vpa_types.PodUpdatePolicy {
328
+ UpdateMode : & validUpdateMode ,
329
+ },
330
+ ResourcePolicy : & vpa_types.PodResourcePolicy {
331
+ ContainerPolicies : []vpa_types.ContainerResourcePolicy {
332
+ {
333
+ ContainerName : "loot box" ,
334
+ Mode : & validScalingMode ,
335
+ MinAllowed : apiv1.ResourceList {
336
+ cpu : resource .MustParse ("10" ),
337
+ },
338
+ MaxAllowed : apiv1.ResourceList {
339
+ cpu : resource .MustParse ("100" ),
340
+ },
341
+ OOMBumpUpRatio : resource .NewQuantity (2 , resource .DecimalSI ),
342
+ },
343
+ },
344
+ },
345
+ },
346
+ },
347
+ PerVPAConfigDisabled : false ,
348
+ },
349
+ {
350
+ name : "per-vpa config disabled and used" ,
351
+ vpa : vpa_types.VerticalPodAutoscaler {
352
+ Spec : vpa_types.VerticalPodAutoscalerSpec {
353
+ UpdatePolicy : & vpa_types.PodUpdatePolicy {
354
+ UpdateMode : & validUpdateMode ,
355
+ },
356
+ ResourcePolicy : & vpa_types.PodResourcePolicy {
357
+ ContainerPolicies : []vpa_types.ContainerResourcePolicy {
358
+ {
359
+ ContainerName : "loot box" ,
360
+ Mode : & validScalingMode ,
361
+ MinAllowed : apiv1.ResourceList {
362
+ cpu : resource .MustParse ("10" ),
363
+ },
364
+ MaxAllowed : apiv1.ResourceList {
365
+ cpu : resource .MustParse ("100" ),
366
+ },
367
+ OOMMinBumpUp : resource .NewQuantity (2 , resource .DecimalSI ),
368
+ },
369
+ },
370
+ },
371
+ },
372
+ },
373
+ PerVPAConfigDisabled : true ,
374
+ expectError : fmt .Errorf ("OOMBumpUpRatio and OOMMinBumpUp are not supported when feature flag PerVPAConfig is disabled" ),
375
+ },
322
376
}
323
377
for _ , tc := range tests {
324
378
t .Run (fmt .Sprintf ("test case: %s" , tc .name ), func (t * testing.T ) {
325
379
featuregatetesting .SetFeatureGateDuringTest (t , features .MutableFeatureGate , features .InPlaceOrRecreate , ! tc .inPlaceOrRecreateFeatureGateDisabled )
380
+ featuregatetesting .SetFeatureGateDuringTest (t , features .MutableFeatureGate , features .PerVPAConfig , ! tc .PerVPAConfigDisabled )
326
381
err := ValidateVPA (& tc .vpa , tc .isCreate )
327
382
if tc .expectError == nil {
328
383
assert .NoError (t , err )
0 commit comments