Merge pull request #87205 from mortent/DeflakePdbE2eTest

Make sure PDB has observed pods before doing eviction in e2e test
This commit is contained in:
Kubernetes Prow Robot
2020-01-14 22:21:54 -08:00
committed by GitHub

View File

@@ -223,6 +223,7 @@ var _ = SIGDescribe("DisruptionController", func() {
ginkgo.By("Trying to evict the same pod we tried earlier which should now be evictable") ginkgo.By("Trying to evict the same pod we tried earlier which should now be evictable")
waitForPodsOrDie(cs, ns, 3) waitForPodsOrDie(cs, ns, 3)
waitForPdbToObserveHealthyPods(cs, ns, 3)
err = cs.CoreV1().Pods(ns).Evict(e) err = cs.CoreV1().Pods(ns).Evict(e)
framework.ExpectNoError(err) // the eviction is now allowed framework.ExpectNoError(err) // the eviction is now allowed
}) })
@@ -402,3 +403,18 @@ func waitForPdbToBeProcessed(cs kubernetes.Interface, ns string) {
}) })
framework.ExpectNoError(err, "Waiting for the pdb to be processed in namespace %s", ns) framework.ExpectNoError(err, "Waiting for the pdb to be processed in namespace %s", ns)
} }
func waitForPdbToObserveHealthyPods(cs kubernetes.Interface, ns string, healthyCount int32) {
ginkgo.By("Waiting for the pdb to observed all healthy pods")
err := wait.PollImmediate(framework.Poll, wait.ForeverTestTimeout, func() (bool, error) {
pdb, err := cs.PolicyV1beta1().PodDisruptionBudgets(ns).Get("foo", metav1.GetOptions{})
if err != nil {
return false, err
}
if pdb.Status.CurrentHealthy != healthyCount {
return false, nil
}
return true, nil
})
framework.ExpectNoError(err, "Waiting for the pdb in namespace %s to observed %d healthy pods", ns, healthyCount)
}