@@ -18,6 +18,7 @@ package autoscaling
1818
1919import (
2020 "fmt"
21+ "time"
2122
2223 autoscaling "k8s.io/api/autoscaling/v1"
2324 apiv1 "k8s.io/api/core/v1"
@@ -43,6 +44,7 @@ const (
4344)
4445
4546var _ = FullVpaE2eDescribe ("Pods under VPA" , func () {
47+ return
4648 var (
4749 rc * ResourceConsumer
4850 vpaClientSet * vpa_clientset.Clientset
@@ -91,30 +93,30 @@ var _ = FullVpaE2eDescribe("Pods under VPA", func() {
9193 ginkgo .It ("have cpu requests growing with usage" , func () {
9294 // initial CPU usage is low so a minimal recommendation is expected
9395 err := waitForResourceRequestInRangeInPods (
94- f , metav1.ListOptions {LabelSelector : "name=hamster" }, apiv1 .ResourceCPU ,
96+ f , pollTimeout , metav1.ListOptions {LabelSelector : "name=hamster" }, apiv1 .ResourceCPU ,
9597 ParseQuantityOrDie (minimalCPULowerBound ), ParseQuantityOrDie (minimalCPUUpperBound ))
9698 gomega .Expect (err ).NotTo (gomega .HaveOccurred ())
9799
98100 // consume more CPU to get a higher recommendation
99101 rc .ConsumeCPU (600 * replicas )
100102 err = waitForResourceRequestInRangeInPods (
101- f , metav1.ListOptions {LabelSelector : "name=hamster" }, apiv1 .ResourceCPU ,
103+ f , pollTimeout , metav1.ListOptions {LabelSelector : "name=hamster" }, apiv1 .ResourceCPU ,
102104 ParseQuantityOrDie ("500m" ), ParseQuantityOrDie ("900m" ))
103105 gomega .Expect (err ).NotTo (gomega .HaveOccurred ())
104106 })
105107
106108 ginkgo .It ("have memory requests growing with usage" , func () {
107109 // initial memory usage is low so a minimal recommendation is expected
108110 err := waitForResourceRequestInRangeInPods (
109- f , metav1.ListOptions {LabelSelector : "name=hamster" }, apiv1 .ResourceMemory ,
111+ f , pollTimeout , metav1.ListOptions {LabelSelector : "name=hamster" }, apiv1 .ResourceMemory ,
110112 ParseQuantityOrDie (minimalMemoryLowerBound ), ParseQuantityOrDie (minimalMemoryUpperBound ))
111113 gomega .Expect (err ).NotTo (gomega .HaveOccurred ())
112114
113115 // consume more memory to get a higher recommendation
114116 // NOTE: large range given due to unpredictability of actual memory usage
115117 rc .ConsumeMem (1024 * replicas )
116118 err = waitForResourceRequestInRangeInPods (
117- f , metav1.ListOptions {LabelSelector : "name=hamster" }, apiv1 .ResourceMemory ,
119+ f , pollTimeout , metav1.ListOptions {LabelSelector : "name=hamster" }, apiv1 .ResourceMemory ,
118120 ParseQuantityOrDie ("900Mi" ), ParseQuantityOrDie ("4000Mi" ))
119121 gomega .Expect (err ).NotTo (gomega .HaveOccurred ())
120122 })
@@ -157,14 +159,14 @@ var _ = FullVpaE2eDescribe("OOMing pods under VPA", func() {
157159 ginkgo .It ("have memory requests growing with OOMs" , func () {
158160 listOptions := metav1.ListOptions {LabelSelector : "name=hamster" , FieldSelector : getPodSelectorExcludingDonePodsOrDie ()}
159161 err := waitForResourceRequestInRangeInPods (
160- f , listOptions , apiv1 .ResourceMemory ,
162+ f , 7 * time . Minute , listOptions , apiv1 .ResourceMemory ,
161163 ParseQuantityOrDie ("1400Mi" ), ParseQuantityOrDie ("10000Mi" ))
162164 gomega .Expect (err ).NotTo (gomega .HaveOccurred ())
163165 })
164166})
165167
166- func waitForPodsMatch (f * framework.Framework , listOptions metav1.ListOptions , matcher func (pod apiv1.Pod ) bool ) error {
167- return wait .PollImmediate (pollInterval , pollTimeout , func () (bool , error ) {
168+ func waitForPodsMatch (f * framework.Framework , timeout time. Duration , listOptions metav1.ListOptions , matcher func (pod apiv1.Pod ) bool ) error {
169+ return wait .PollImmediate (pollInterval , timeout , func () (bool , error ) {
168170
169171 ns := f .Namespace .Name
170172 c := f .ClientSet
@@ -193,8 +195,8 @@ func waitForPodsMatch(f *framework.Framework, listOptions metav1.ListOptions, ma
193195 })
194196}
195197
196- func waitForResourceRequestInRangeInPods (f * framework.Framework , listOptions metav1.ListOptions , resourceName apiv1.ResourceName , lowerBound , upperBound resource.Quantity ) error {
197- err := waitForPodsMatch (f , listOptions ,
198+ func waitForResourceRequestInRangeInPods (f * framework.Framework , timeout time. Duration , listOptions metav1.ListOptions , resourceName apiv1.ResourceName , lowerBound , upperBound resource.Quantity ) error {
199+ err := waitForPodsMatch (f , timeout , listOptions ,
198200 func (pod apiv1.Pod ) bool {
199201 resourceRequest , found := pod .Spec .Containers [0 ].Resources .Requests [resourceName ]
200202 framework .Logf ("Comparing %v request %v against range of (%v, %v)" , resourceName , resourceRequest , lowerBound , upperBound )
0 commit comments