Skip to content

Commit 4625d85

Browse files
test: fix issue "No primary found" in replica mode E2E
Co-authored-by: Gabriele Quaresima <gabriele.quaresima@enterprisedb.com>
1 parent 6a4d1cf commit 4625d85

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

tests/e2e/asserts_test.go

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -183,16 +183,22 @@ func AssertClusterIsReady(namespace string, clusterName string, timeout int, env
183183
Name: clusterName,
184184
}
185185
// Eventually the number of ready instances should be equal to the
186-
// amount of instances defined in the cluster
186+
// amount of instances defined in the cluster and
187+
// the cluster status should be in healthy state
187188
cluster := &apiv1.Cluster{}
188189
err := env.Client.Get(env.Ctx, namespacedName, cluster)
189190
Expect(err).ToNot(HaveOccurred())
190-
Eventually(func() (int, error) {
191+
Eventually(func() (string, error) {
191192
podList, err := env.GetClusterPodList(namespace, clusterName)
192-
Expect(err).ToNot(HaveOccurred())
193-
readyInstances := utils.CountReadyPods(podList.Items)
194-
return readyInstances, err
195-
}, timeout).Should(BeEquivalentTo(cluster.Spec.Instances))
193+
if err != nil {
194+
return "", err
195+
}
196+
if cluster.Spec.Instances == int32(utils.CountReadyPods(podList.Items)) {
197+
err = env.Client.Get(env.Ctx, namespacedName, cluster)
198+
return cluster.Status.Phase, err
199+
}
200+
return "", nil
201+
}, timeout, 2).Should(BeEquivalentTo(apiv1.PhaseHealthy))
196202
})
197203
}
198204

@@ -647,7 +653,7 @@ func AssertReplicaModeCluster(
647653
Eventually(func() error {
648654
primarySrcCluster, err = env.GetClusterPrimary(namespace, srcClusterName)
649655
return err
650-
}, 5).Should(BeNil())
656+
}, 30, 3).Should(BeNil())
651657
})
652658

653659
By("creating test data in source cluster", func() {
@@ -663,7 +669,7 @@ func AssertReplicaModeCluster(
663669
Eventually(func() error {
664670
primaryReplicaCluster, err = env.GetClusterPrimary(namespace, replicaClusterName)
665671
return err
666-
}, 5).Should(BeNil())
672+
}, 30, 3).Should(BeNil())
667673
})
668674

669675
By("verifying that replica cluster primary is in recovery mode", func() {

0 commit comments

Comments
 (0)