From 1d9c3f8533935c4e748c04f9c9f232cedc47eb61 Mon Sep 17 00:00:00 2001 From: John Mulligan Date: Mon, 15 Nov 2021 10:24:04 -0500 Subject: [PATCH] cephfs admin: poll mgr to see if mirroring module is enabled When testing the mirroing workflow, we will not explicitly check on the mgr for the presence of the mirroring module before proceeding with the tests. The plan is to have this cut down on test flakes. The previous workaround also had a bug in that the 2nd sleep was in the wrong location. Perhaps, fixing this alone would resolve the test flakes, but this is more proper anyway. Signed-off-by: John Mulligan --- cephfs/admin/mirror_workflow_test.go | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/cephfs/admin/mirror_workflow_test.go b/cephfs/admin/mirror_workflow_test.go index d7639360a..b02e03b22 100644 --- a/cephfs/admin/mirror_workflow_test.go +++ b/cephfs/admin/mirror_workflow_test.go @@ -25,6 +25,20 @@ const ( mirrorClient = "client.mirror_remote" ) +func waitForMirroring(t *testing.T, fsa *FSAdmin) { + for i := 0; i < 20; i++ { + modinfo, err := fsa.listModules() + require.NoError(t, err) + for _, emod := range modinfo.EnabledModules { + if emod == "mirroring" { + return + } + } + time.Sleep(100 * time.Millisecond) + } + t.Fatalf("timed out waiting for mirroring module") +} + func TestMirroring(t *testing.T) { if mirrorConfig() == "" { t.Skip("no mirror config available") @@ -41,7 +55,7 @@ func TestMirroring(t *testing.T) { assert.NoError(t, err) }() require.NoError(t, err) - time.Sleep(500 * time.Millisecond) // TODO: improve this + waitForMirroring(t, fsa1) smadmin1 := fsa1.SnapshotMirror() err = smadmin1.Enable(fsname) @@ -50,7 +64,6 @@ func TestMirroring(t *testing.T) { err := smadmin1.Disable(fsname) require.NoError(t, err) }() - time.Sleep(500 * time.Millisecond) // TODO: improve this fsa2 := newFSAdmin(t, mirrorConfig()) err = fsa2.EnableMirroringModule(noForce) @@ -59,6 +72,7 @@ func TestMirroring(t *testing.T) { err := fsa2.DisableMirroringModule() assert.NoError(t, err) }() + waitForMirroring(t, fsa2) smadmin2 := fsa2.SnapshotMirror() err = smadmin2.Enable(fsname)