Skip to content

Commit

Permalink
cephfs admin: remove explicit subvol delete from snap retention test
Browse files Browse the repository at this point in the history
On ceph quincy, removing the subvolume explicitly (even with --force)
triggered an error. Due to the discussion in
https://tracker.ceph.com/issues/54625
I was informed that the explicit delete was not necessary, and while
the error on quincy was not correct, even on previous versions the
call is basically a no-op.

Rather than wait for this to be changed back to a no-op on quincy,
we remove the unneeded call. While we're at it, change the polling
loop to use the assert lib's Eventually call which is much nicer
to read and expires based on a duration avoiding the need to
think about loop iterations. :-)

Signed-off-by: John Mulligan <[email protected]>
  • Loading branch information
phlogistonjohn authored and mergify[bot] committed May 2, 2022
1 parent ae44f69 commit 13bdb3e
Showing 1 changed file with 22 additions and 18 deletions.
40 changes: 22 additions & 18 deletions cephfs/admin/subvolume_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ import (
"github.com/stretchr/testify/assert"
)

var shortDuration = 50 * time.Millisecond

func delay() {
// ceph seems to do this (partly?) async. So for now, we cheat
// and sleep a little to make subsequent tests more reliable
time.Sleep(50 * time.Millisecond)
time.Sleep(shortDuration)
}

func TestCreateSubVolume(t *testing.T) {
Expand Down Expand Up @@ -198,24 +200,26 @@ func TestRemoveSubVolume(t *testing.T) {

err = fsa.RemoveSubVolumeSnapshot(volume, NoGroup, subname, snapname)
assert.NoError(t, err)
err = fsa.RemoveSubVolumeWithFlags(
volume, NoGroup, subname, SubVolRmFlags{Force: true})
assert.NoError(t, err)

// this seems to take longer than other removals. Try a few times to
// verify the subvolume is gone before asserting that the test failed
removed := false
for i := 0; i < 100; i++ {
delay()
lsv, err = fsa.ListSubVolumes(volume, NoGroup)
assert.NoError(t, err)
nowCount := len(lsv)
if nowCount == beforeCount {
removed = true
break
}
}
assert.True(t, removed, "volume count did not return to previous value")
// The deletion of a subvolume in snapshot-retained state is triggered
// by the deletion of the last snapshot. It does not need to be
// explicitly deleted.
// This may also be why we need to wait longer for the subvolume
// to be removed from the listing.
// See also: https://tracker.ceph.com/issues/54625

assert.Eventually(t,
func() bool {
lsv, err := fsa.ListSubVolumes(volume, NoGroup)
if !assert.NoError(t, err) {
return false
}
return len(lsv) == beforeCount
},
2*time.Minute,
shortDuration,
"subvolume count did not return to previous value")

})
}

Expand Down

0 comments on commit 13bdb3e

Please sign in to comment.