Skip to content

Commit

Permalink
cephfs admin: poll mgr to see if mirroring module is enabled
Browse files Browse the repository at this point in the history
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 <jmulligan@redhat.com>
  • Loading branch information
phlogistonjohn authored and mergify[bot] committed Dec 7, 2021
1 parent a26d4b8 commit 1d9c3f8
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions cephfs/admin/mirror_workflow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 1d9c3f8

Please sign in to comment.