Skip to content
This repository has been archived by the owner on Jan 19, 2022. It is now read-only.

Commit

Permalink
Add WaitForPodCount integration helper
Browse files Browse the repository at this point in the history
  • Loading branch information
Mario Manno committed Jan 12, 2021
1 parent 19bc6c4 commit 35e1751
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions testing/machine/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,19 @@ func (m *Machine) WaitForPods(namespace string, labels string) error {
})
}

// WaitForPodCount blocks until the specified number of pods is running
func (m *Machine) WaitForPodCount(namespace string, labels string, count int) error {
return wait.PollImmediate(m.PollInterval, m.PollTimeout, func() (bool, error) {
n, err := m.PodCount(namespace, labels, func(pod corev1.Pod) bool {
return pod.Status.Phase == corev1.PodRunning
})
if err != nil {
return false, err
}
return n == count, nil
})
}

// WaitForPodFailures blocks until all selected pods are failing. It fails after the timeout.
func (m *Machine) WaitForPodFailures(namespace string, labels string) error {
return wait.PollImmediate(5*time.Second, m.PollTimeout, func() (bool, error) {
Expand Down

0 comments on commit 35e1751

Please sign in to comment.