Skip to content

Commit

Permalink
update lifecycle_test.go to check StatefulSetReady condition
Browse files Browse the repository at this point in the history
Signed-off-by: YZ775 <yuzuki-mimura@cybozu.co.jp>
  • Loading branch information
YZ775 committed Aug 8, 2023
1 parent acfbef5 commit bff9639
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions e2e/lifecycle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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())
})

Expand Down

0 comments on commit bff9639

Please sign in to comment.