in internal/testhelpers/resources.go [471:503]
func (cc *TestCaseClient) ExpectPodReady(ctx context.Context, podSelector *metav1.LabelSelector, allOrAny string) error {
var (
countBadPods int
countPods int
)
return RetryUntilSuccess(24, DefaultRetryInterval, func() error {
countBadPods = 0
pods, err := ListPods(ctx, cc.Client, cc.Namespace, podSelector)
if err != nil {
return err
}
countPods = len(pods.Items)
if len(pods.Items) == 0 {
return fmt.Errorf("got 0 pods, want at least 1 pod")
}
for _, pod := range pods.Items {
if !isPodReady(pod) {
countBadPods++
}
}
switch {
case allOrAny == "all" && countBadPods > 0:
return fmt.Errorf("got %d pods not ready of %d pods, want 0 pods not ready", countBadPods, len(pods.Items))
case allOrAny == "any" && countBadPods == countPods:
return fmt.Errorf("got %d pods not ready of %d pods, want at least 1 pod ready ", countBadPods, len(pods.Items))
default:
return nil
}
})
}