mirror of
https://github.com/ceph/go-ceph
synced 2024-12-22 22:24:03 +00:00
cephfs admin: remove explicit subvol delete from snap retention test
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 <jmulligan@redhat.com>
This commit is contained in:
parent
ae44f69791
commit
13bdb3e26c
@ -8,10 +8,12 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var shortDuration = 50 * time.Millisecond
|
||||||
|
|
||||||
func delay() {
|
func delay() {
|
||||||
// ceph seems to do this (partly?) async. So for now, we cheat
|
// ceph seems to do this (partly?) async. So for now, we cheat
|
||||||
// and sleep a little to make subsequent tests more reliable
|
// and sleep a little to make subsequent tests more reliable
|
||||||
time.Sleep(50 * time.Millisecond)
|
time.Sleep(shortDuration)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCreateSubVolume(t *testing.T) {
|
func TestCreateSubVolume(t *testing.T) {
|
||||||
@ -198,24 +200,26 @@ func TestRemoveSubVolume(t *testing.T) {
|
|||||||
|
|
||||||
err = fsa.RemoveSubVolumeSnapshot(volume, NoGroup, subname, snapname)
|
err = fsa.RemoveSubVolumeSnapshot(volume, NoGroup, subname, snapname)
|
||||||
assert.NoError(t, err)
|
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
|
// The deletion of a subvolume in snapshot-retained state is triggered
|
||||||
// verify the subvolume is gone before asserting that the test failed
|
// by the deletion of the last snapshot. It does not need to be
|
||||||
removed := false
|
// explicitly deleted.
|
||||||
for i := 0; i < 100; i++ {
|
// This may also be why we need to wait longer for the subvolume
|
||||||
delay()
|
// to be removed from the listing.
|
||||||
lsv, err = fsa.ListSubVolumes(volume, NoGroup)
|
// See also: https://tracker.ceph.com/issues/54625
|
||||||
assert.NoError(t, err)
|
|
||||||
nowCount := len(lsv)
|
assert.Eventually(t,
|
||||||
if nowCount == beforeCount {
|
func() bool {
|
||||||
removed = true
|
lsv, err := fsa.ListSubVolumes(volume, NoGroup)
|
||||||
break
|
if !assert.NoError(t, err) {
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
}
|
return len(lsv) == beforeCount
|
||||||
assert.True(t, removed, "volume count did not return to previous value")
|
},
|
||||||
|
2*time.Minute,
|
||||||
|
shortDuration,
|
||||||
|
"subvolume count did not return to previous value")
|
||||||
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user