mirror of https://github.com/ceph/go-ceph
cephfs admin: add in a test for canceling clones
This test is added after we add force delete functions as deleting a canceled clone requires a force remove function. Signed-off-by: John Mulligan <jmulligan@redhat.com>
This commit is contained in:
parent
c9ab11ad12
commit
e14bd1e436
|
@ -143,3 +143,66 @@ func TestCloneSubVolumeSnapshot(t *testing.T) {
|
||||||
time.Sleep(5 * time.Millisecond)
|
time.Sleep(5 * time.Millisecond)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCancelClone(t *testing.T) {
|
||||||
|
fsa := getFSAdmin(t)
|
||||||
|
volume := "cephfs"
|
||||||
|
group := "Park"
|
||||||
|
subname := "Jurrasic"
|
||||||
|
snapname := "dinodna0"
|
||||||
|
clonename := "babydino2"
|
||||||
|
|
||||||
|
err := fsa.CreateSubVolumeGroup(volume, group, nil)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
defer func() {
|
||||||
|
err := fsa.RemoveSubVolumeGroup(volume, group)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
}()
|
||||||
|
|
||||||
|
svopts := &SubVolumeOptions{
|
||||||
|
Mode: 0750,
|
||||||
|
Size: 20 * gibiByte,
|
||||||
|
}
|
||||||
|
err = fsa.CreateSubVolume(volume, group, subname, svopts)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
defer func() {
|
||||||
|
err := fsa.RemoveSubVolume(volume, group, subname)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
}()
|
||||||
|
|
||||||
|
err = fsa.CreateSubVolumeSnapshot(volume, group, subname, snapname)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
defer func() {
|
||||||
|
err := fsa.RemoveSubVolumeSnapshot(volume, group, subname, snapname)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
}()
|
||||||
|
|
||||||
|
err = fsa.CloneSubVolumeSnapshot(
|
||||||
|
volume, group, subname, snapname, clonename,
|
||||||
|
&CloneOptions{TargetGroup: group})
|
||||||
|
var x NotProtectedError
|
||||||
|
if errors.As(err, &x) {
|
||||||
|
err = fsa.ProtectSubVolumeSnapshot(volume, group, subname, snapname)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
defer func() {
|
||||||
|
err := fsa.UnprotectSubVolumeSnapshot(volume, group, subname, snapname)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
}()
|
||||||
|
|
||||||
|
err = fsa.CloneSubVolumeSnapshot(
|
||||||
|
volume, group, subname, snapname, clonename,
|
||||||
|
&CloneOptions{TargetGroup: group})
|
||||||
|
}
|
||||||
|
assert.NoError(t, err)
|
||||||
|
defer func() {
|
||||||
|
err := fsa.ForceRemoveSubVolume(volume, group, clonename)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
}()
|
||||||
|
|
||||||
|
// we can't guarantee that this clone is can be canceled here, especially
|
||||||
|
// if the clone happens fast on the ceph server side, but I have not yet
|
||||||
|
// seen an instance where it fails. If it happens we can adjust the test as
|
||||||
|
// needed.
|
||||||
|
err = fsa.CancelClone(volume, group, clonename)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue