From c95ecaff0e144d8559a397e66f4bc0eaa8161a16 Mon Sep 17 00:00:00 2001 From: Travis Nielsen Date: Fri, 4 Dec 2020 15:37:30 -0700 Subject: [PATCH] ceph: retry mirror status update in tests The TestCephBlockPoolController test is failing intermittently due to a failure to update the rbd mirroring status on the pool CR. Improve the test reliability by trying again several times if needed. Signed-off-by: Travis Nielsen --- pkg/operator/ceph/pool/controller_test.go | 24 +++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/pkg/operator/ceph/pool/controller_test.go b/pkg/operator/ceph/pool/controller_test.go index a578e8196..dc08c8a90 100644 --- a/pkg/operator/ceph/pool/controller_test.go +++ b/pkg/operator/ceph/pool/controller_test.go @@ -348,19 +348,27 @@ func TestCephBlockPoolController(t *testing.T) { pool.Spec.Mirroring.Mode = "image" err = r.client.Update(context.TODO(), pool) assert.NoError(t, err) - res, err = r.Reconcile(req) - assert.NoError(t, err) - assert.False(t, res.Requeue) - err = r.client.Get(context.TODO(), req.NamespacedName, pool) - assert.NoError(t, err) - assert.Equal(t, cephv1.ConditionReady, pool.Status.Phase) + for i := 0; i < 5; i++ { + res, err = r.Reconcile(req) + assert.NoError(t, err) + assert.False(t, res.Requeue) + err = r.client.Get(context.TODO(), req.NamespacedName, pool) + assert.NoError(t, err) + assert.Equal(t, cephv1.ConditionReady, pool.Status.Phase) + if _, ok := pool.Status.Info[RBDMirrorBootstrapPeerSecretName]; ok { + break + } + logger.Infof("FIX: trying again to update the mirroring status") + } assert.NotEmpty(t, pool.Status.Info[RBDMirrorBootstrapPeerSecretName], pool.Status.Info) // fetch the secret myPeerSecret, err := c.Clientset.CoreV1().Secrets(namespace).Get(ctx, pool.Status.Info[RBDMirrorBootstrapPeerSecretName], metav1.GetOptions{}) assert.NoError(t, err) - assert.NotEmpty(t, myPeerSecret.Data["token"], myPeerSecret.Data) - assert.NotEmpty(t, myPeerSecret.Data["pool"]) + if myPeerSecret != nil { + assert.NotEmpty(t, myPeerSecret.Data["token"], myPeerSecret.Data) + assert.NotEmpty(t, myPeerSecret.Data["pool"]) + } } func TestConfigureRBDStats(t *testing.T) {