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 <jmulligan@redhat.com>
This commit is contained in:
John Mulligan 2021-11-15 10:24:04 -05:00 committed by mergify[bot]
parent a26d4b8563
commit 1d9c3f8533
1 changed files with 16 additions and 2 deletions

View File

@ -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)