diff --git a/e2e/lifecycle_test.go b/e2e/lifecycle_test.go index d1dbf5698..5831cf2d0 100644 --- a/e2e/lifecycle_test.go +++ b/e2e/lifecycle_test.go @@ -15,6 +15,7 @@ import ( "github.com/prometheus/common/expfmt" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/api/meta" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -33,16 +34,21 @@ var _ = Context("lifecycle", func() { if err != nil { return err } - for _, cond := range cluster.Status.Conditions { - if cond.Type != mocov1beta2.ConditionHealthy { - continue - } - if cond.Status == metav1.ConditionTrue { - return nil - } - return fmt.Errorf("cluster is not healthy: %s", cond.Status) + if cluster.Generation != cluster.Status.ReconcileInfo.Generation { + return fmt.Errorf("cluster is not reconciled yet") + } + conditionStatefulSetReady := meta.FindStatusCondition(cluster.Status.Conditions, mocov1beta2.ConditionStatefulSetReady) + conditionHealthy := meta.FindStatusCondition(cluster.Status.Conditions, mocov1beta2.ConditionHealthy) + if conditionStatefulSetReady == nil { + return fmt.Errorf("statefulset is not ready") } - return errors.New("no health condition") + if conditionHealthy == nil { + return fmt.Errorf("cluster is not healthy") + } + if conditionStatefulSetReady.Status != metav1.ConditionTrue && conditionHealthy.Status != metav1.ConditionTrue { + return fmt.Errorf("cluster is not ready") + } + return nil }).Should(Succeed()) })