@@ -1098,6 +1098,122 @@ var _ = AdmissionControllerE2eDescribe("Admission-controller", func() {
10981098 })
10991099})
11001100
1101+ var _ = AdmissionControllerE2eDescribe ("Admission-controller" , func () {
1102+ f := framework .NewDefaultFramework ("vertical-pod-autoscaling" )
1103+ f .NamespacePodSecurityEnforceLevel = podsecurity .LevelBaseline
1104+
1105+ ginkgo .BeforeEach (func () {
1106+ waitForVpaWebhookRegistration (f )
1107+ })
1108+
1109+ f .It ("boosts CPU by factor on pod creation" , framework .WithFeatureGate (features .CPUStartupBoost ), func () {
1110+ initialCPU := ParseQuantityOrDie ("100m" )
1111+ expectedCPU := ParseQuantityOrDie ("200m" )
1112+ d := NewHamsterDeploymentWithResources (f , initialCPU , ParseQuantityOrDie ("100Mi" ))
1113+
1114+ ginkgo .By ("Setting up a VPA with a startup boost policy (factor)" )
1115+ containerName := utils .GetHamsterContainerNameByIndex (0 )
1116+ factor := int32 (2 )
1117+ vpaCRD := test .VerticalPodAutoscaler ().
1118+ WithName ("hamster-vpa" ).
1119+ WithNamespace (f .Namespace .Name ).
1120+ WithTargetRef (utils .HamsterTargetRef ).
1121+ WithContainer (containerName ).
1122+ WithCPUStartupBoost (vpa_types .FactorStartupBoostType , & factor , nil , "15s" ).
1123+ AppendRecommendation (
1124+ test .Recommendation ().
1125+ WithContainer (containerName ).
1126+ WithTarget ("100m" , "100Mi" ).
1127+ GetContainerResources (),
1128+ ).
1129+ Get ()
1130+ utils .InstallVPA (f , vpaCRD )
1131+
1132+ ginkgo .By ("Starting the deployment and verifying the pod is boosted" )
1133+ podList := utils .StartDeploymentPods (f , d )
1134+ pod := podList .Items [0 ]
1135+ gomega .Expect (pod .Spec .Containers [0 ].Resources .Requests .Cpu ().Cmp (expectedCPU )).To (gomega .Equal (0 ))
1136+ gomega .Expect (pod .Spec .Containers [0 ].Resources .Limits .Cpu ().Cmp (expectedCPU )).To (gomega .Equal (0 ))
1137+ })
1138+
1139+ f .It ("boosts CPU by quantity on pod creation" , framework .WithFeatureGate (features .CPUStartupBoost ), func () {
1140+ initialCPU := ParseQuantityOrDie ("100m" )
1141+ boostCPUQuantity := ParseQuantityOrDie ("500m" )
1142+ expectedCPU := ParseQuantityOrDie ("600m" )
1143+ d := NewHamsterDeploymentWithResources (f , initialCPU , ParseQuantityOrDie ("100Mi" ))
1144+
1145+ ginkgo .By ("Setting up a VPA with a startup boost policy (quantity)" )
1146+ containerName := utils .GetHamsterContainerNameByIndex (0 )
1147+ vpaCRD := test .VerticalPodAutoscaler ().
1148+ WithName ("hamster-vpa" ).
1149+ WithNamespace (f .Namespace .Name ).
1150+ WithTargetRef (utils .HamsterTargetRef ).
1151+ WithContainer (containerName ).
1152+ WithCPUStartupBoost (vpa_types .QuantityStartupBoostType , nil , & boostCPUQuantity , "15s" ).
1153+ AppendRecommendation (
1154+ test .Recommendation ().
1155+ WithContainer (containerName ).
1156+ WithTarget ("100m" , "100Mi" ).
1157+ GetContainerResources (),
1158+ ).
1159+ Get ()
1160+ utils .InstallVPA (f , vpaCRD )
1161+
1162+ ginkgo .By ("Starting the deployment and verifying the pod is boosted" )
1163+ podList := utils .StartDeploymentPods (f , d )
1164+ pod := podList .Items [0 ]
1165+ gomega .Expect (pod .Spec .Containers [0 ].Resources .Requests .Cpu ().Cmp (expectedCPU )).To (gomega .Equal (0 ))
1166+ gomega .Expect (pod .Spec .Containers [0 ].Resources .Limits .Cpu ().Cmp (expectedCPU )).To (gomega .Equal (0 ))
1167+ })
1168+
1169+ f .It ("boosts CPU on pod creation when VPA update mode is Off" , framework .WithFeatureGate (features .CPUStartupBoost ), func () {
1170+ initialCPU := ParseQuantityOrDie ("100m" )
1171+ expectedCPU := ParseQuantityOrDie ("200m" )
1172+ d := NewHamsterDeploymentWithResources (f , initialCPU , ParseQuantityOrDie ("100Mi" ))
1173+
1174+ ginkgo .By ("Setting up a VPA with updateMode Off and a startup boost policy" )
1175+ containerName := utils .GetHamsterContainerNameByIndex (0 )
1176+ factor := int32 (2 )
1177+ vpaCRD := test .VerticalPodAutoscaler ().
1178+ WithName ("hamster-vpa" ).
1179+ WithNamespace (f .Namespace .Name ).
1180+ WithTargetRef (utils .HamsterTargetRef ).
1181+ WithContainer (containerName ).
1182+ WithUpdateMode (vpa_types .UpdateModeOff ). // VPA is off, but boost should still work
1183+ WithCPUStartupBoost (vpa_types .FactorStartupBoostType , & factor , nil , "15s" ).
1184+ Get ()
1185+ utils .InstallVPA (f , vpaCRD )
1186+
1187+ ginkgo .By ("Starting the deployment and verifying the pod is boosted" )
1188+ podList := utils .StartDeploymentPods (f , d )
1189+ pod := podList .Items [0 ]
1190+ gomega .Expect (pod .Spec .Containers [0 ].Resources .Requests .Cpu ().Cmp (expectedCPU )).To (gomega .Equal (0 ))
1191+ })
1192+
1193+ f .It ("doesn't boost CPU on pod creation when scaling mode is Off" , framework .WithFeatureGate (features .CPUStartupBoost ), func () {
1194+ initialCPU := ParseQuantityOrDie ("100m" )
1195+ d := NewHamsterDeploymentWithResources (f , initialCPU , ParseQuantityOrDie ("100Mi" ))
1196+
1197+ ginkgo .By ("Setting up a VPA with a startup boost policy and scaling mode Off" )
1198+ containerName := utils .GetHamsterContainerNameByIndex (0 )
1199+ factor := int32 (2 )
1200+ vpaCRD := test .VerticalPodAutoscaler ().
1201+ WithName ("hamster-vpa" ).
1202+ WithNamespace (f .Namespace .Name ).
1203+ WithTargetRef (utils .HamsterTargetRef ).
1204+ WithContainer (containerName ).
1205+ WithCPUStartupBoost (vpa_types .FactorStartupBoostType , & factor , nil , "15s" ).
1206+ WithScalingMode (containerName , vpa_types .ContainerScalingModeOff ).
1207+ Get ()
1208+ utils .InstallVPA (f , vpaCRD )
1209+
1210+ ginkgo .By ("Starting the deployment and verifying the pod is NOT boosted" )
1211+ podList := utils .StartDeploymentPods (f , d )
1212+ pod := podList .Items [0 ]
1213+ gomega .Expect (pod .Spec .Containers [0 ].Resources .Requests .Cpu ().Cmp (initialCPU )).To (gomega .Equal (0 ))
1214+ })
1215+ })
1216+
11011217func waitForVpaWebhookRegistration (f * framework.Framework ) {
11021218 ginkgo .By ("Waiting for VPA webhook registration" )
11031219 gomega .Eventually (func () bool {
0 commit comments