diff --git a/test/e2e/framework/util.go b/test/e2e/framework/util.go index c596a0d5d8a..b5c466346f5 100644 --- a/test/e2e/framework/util.go +++ b/test/e2e/framework/util.go @@ -2811,7 +2811,11 @@ func WaitForControlledPodsRunning(c clientset.Interface, ns, name string, kind s if err != nil { return err } - err = testutils.WaitForPodsWithLabelRunning(c, ns, selector) + replicas, err := getReplicasFromRuntimeObject(rtObject) + if err != nil { + return err + } + err = testutils.WaitForEnoughPodsWithLabelRunning(c, ns, selector, int(replicas)) if err != nil { return fmt.Errorf("Error while waiting for replication controller %s pods to be running: %v", name, err) } diff --git a/test/utils/runners.go b/test/utils/runners.go index 638dc2cb2a4..da5dd49f5ff 100644 --- a/test/utils/runners.go +++ b/test/utils/runners.go @@ -828,20 +828,29 @@ func StartPods(c clientset.Interface, replicas int, namespace string, podNamePre // Wait up to 10 minutes for all matching pods to become Running and at least one // matching pod exists. func WaitForPodsWithLabelRunning(c clientset.Interface, ns string, label labels.Selector) error { + return WaitForEnoughPodsWithLabelRunning(c, ns, label, -1) +} + +// Wait up to 10 minutes for at least 'replicas' many pods to be Running and at least +// one matching pod exists. If 'replicas' is < 0, wait for all matching pods running. +func WaitForEnoughPodsWithLabelRunning(c clientset.Interface, ns string, label labels.Selector, replicas int) error { running := false PodStore := NewPodStore(c, ns, label, fields.Everything()) defer PodStore.Stop() -waitLoop: for start := time.Now(); time.Since(start) < 10*time.Minute; time.Sleep(5 * time.Second) { pods := PodStore.List() if len(pods) == 0 { - continue waitLoop + continue } + runningPodsCount := 0 for _, p := range pods { - if p.Status.Phase != v1.PodRunning { - continue waitLoop + if p.Status.Phase == v1.PodRunning { + runningPodsCount++ } } + if (replicas < 0 && runningPodsCount < len(pods)) || (runningPodsCount < replicas) { + continue + } running = true break }