Skip to content

Commit 65d6e37

Browse files
authored
Merge pull request #8775 from adrianmoisey/test-polling
Refactor e2e test to poll, rather than wait
2 parents 329691b + a286951 commit 65d6e37

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

vertical-pod-autoscaler/e2e/v1/actuation.go

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import (
3636
"k8s.io/autoscaler/vertical-pod-autoscaler/e2e/utils"
3737
vpa_types "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1"
3838
restriction "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/updater/restriction"
39+
3940
updaterutils "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/updater/utils"
4041
"k8s.io/autoscaler/vertical-pod-autoscaler/pkg/utils/annotations"
4142
clientset "k8s.io/client-go/kubernetes"
@@ -208,6 +209,7 @@ var _ = ActuationSuiteE2eDescribe("Actuation", func() {
208209
})
209210

210211
// Consumes the entire node's CPU, causing other pods to be pending - requires WithSerial()
212+
// issue.k8s.io/135107 could change the need for WithSerial()
211213
framework.It("falls back to evicting pods when resize is Deferred and more than 5 minute has elapsed since last in-place update when update mode is InPlaceOrRecreate", framework.WithSerial(), framework.WithSlow(), func() {
212214
ginkgo.By("Setting up a hamster deployment")
213215
replicas := int32(2)
@@ -500,12 +502,23 @@ var _ = ActuationSuiteE2eDescribe("Actuation", func() {
500502
gomega.Expect(err).NotTo(gomega.HaveOccurred())
501503

502504
ginkgo.By(fmt.Sprintf("Waiting for pods to be evicted, sleep for %s", VpaEvictionTimeout.String()))
503-
time.Sleep(VpaEvictionTimeout)
505+
err = wait.PollUntilContextTimeout(context.TODO(), 10*time.Second, VpaEvictionTimeout, false, func(ctx context.Context) (done bool, err error) {
506+
currentPodList, err := GetHamsterPods(f)
507+
if err != nil {
508+
framework.Logf("Error listing hamster pods: %v", err)
509+
return false, err
510+
}
511+
512+
evictedCount := GetEvictedPodsCount(MakePodSet(currentPodList), podSet)
513+
514+
return evictedCount >= permissiveMaxUnavailable, nil
515+
})
516+
517+
framework.ExpectNoError(err)
504518
ginkgo.By("Checking enough pods were evicted.")
505519
currentPodList, err := GetHamsterPods(f)
506-
gomega.Expect(err).NotTo(gomega.HaveOccurred())
520+
framework.ExpectNoError(err)
507521
evictedCount := GetEvictedPodsCount(MakePodSet(currentPodList), podSet)
508-
gomega.Expect(err).NotTo(gomega.HaveOccurred())
509522
gomega.Expect(evictedCount >= permissiveMaxUnavailable).To(gomega.BeTrue())
510523
})
511524

0 commit comments

Comments
 (0)