diff --git a/test/e2e/functional/tests/e2e.go b/test/e2e/functional/tests/e2e.go index ad22e5883..1f8339e8a 100644 --- a/test/e2e/functional/tests/e2e.go +++ b/test/e2e/functional/tests/e2e.go @@ -280,7 +280,7 @@ var _ = Describe("metallb", func() { }, metallbutils.DeployTimeout, metallbutils.Interval).ShouldNot(HaveOccurred()) By("checking frr-k8s webhook deployment is in running state") - Eventually(func() error { + c := func() error { deploy, err := testclient.Client.Deployments(metallb.Namespace).Get(context.Background(), consts.FRRK8SWebhookDeploymentName, metav1.GetOptions{}) if err != nil { return err @@ -297,18 +297,21 @@ var _ = Describe("metallb", func() { } for _, pod := range pods.Items { - if pod.Status.Phase != corev1.PodRunning { + if !PodIsReady(&pod) { return fmt.Errorf("deployment %s pod %s is not running, expected status %s got %s", consts.MetalLBOperatorDeploymentName, pod.Name, corev1.PodRunning, pod.Status.Phase) } } return nil - }, metallbutils.DeployTimeout, metallbutils.Interval).ShouldNot(HaveOccurred()) + } + Eventually(c, metallbutils.DeployTimeout, metallbutils.Interval).ShouldNot(HaveOccurred()) + By("Consistently be running") + Consistently(c, 30*time.Second, metallbutils.Interval).ShouldNot(HaveOccurred()) }, Entry("Native Mode", metallbv1beta1.NativeMode), Entry("FRR Mode", metallbv1beta1.FRRMode), - Entry("FRR-K8s Mode", metallbv1beta1.FRRK8sMode), + FEntry("FRR-K8s Mode", metallbv1beta1.FRRK8sMode), ) }) @@ -799,3 +802,22 @@ var _ = Describe("metallb", func() { // Gomega transformation functions for v1.Container func envGetter(c v1.Container) []v1.EnvVar { return c.Env } func nameGetter(c v1.Container) string { return c.Name } + +func PodIsReady(p *corev1.Pod) bool { + return podConditionStatus(p, corev1.PodReady) == corev1.ConditionTrue && podConditionStatus(p, corev1.ContainersReady) == corev1.ConditionTrue +} + +// podConditionStatus returns the status of the condition for a given pod. +func podConditionStatus(p *corev1.Pod, condition corev1.PodConditionType) corev1.ConditionStatus { + if p == nil { + return corev1.ConditionUnknown + } + + for _, c := range p.Status.Conditions { + if c.Type == condition { + return c.Status + } + } + + return corev1.ConditionUnknown +}