]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test_rbd: add test for denying removal of protected parent
authorDan Mick <dan.mick@inktank.com>
Tue, 14 Aug 2012 22:32:30 +0000 (15:32 -0700)
committerDan Mick <dan.mick@inktank.com>
Sat, 18 Aug 2012 01:47:24 +0000 (18:47 -0700)
src/test/pybind/test_rbd.py

index 54f174b8023fe0077a369072426478e9b00355ee..3459b137567f1536eaf9e0e837f5c7608ed693fe 100644 (file)
@@ -428,6 +428,46 @@ class TestClone(object):
         assert_raises(InvalidArgument, self.rbd.clone, ioctx, IMG_NAME, 'snap2', ioctx, 'clone2', features)
         self.image.remove_snap('snap2')
 
+    def test_unprotect_with_children(self):
+        global features
+        # can't remove a snapshot that has dependent clones
+        assert_raises(ImageBusy, self.image.remove_snap, 'snap1')
+
+        # validate parent info of clone created by TestClone.setUp
+        (pool, image, snap) = self.clone.parent_info()
+        eq(pool, 'rbd')
+        eq(image, IMG_NAME)
+        eq(snap, 'snap1')
+
+        # create a new pool...
+        rados.create_pool('rbd2')
+        other_ioctx = rados.open_ioctx('rbd2')
+
+        # ...with a clone of the same parent
+        self.rbd.clone(ioctx, IMG_NAME, 'snap1', other_ioctx, 'other_clone', features)
+        self.other_clone = Image(other_ioctx, 'other_clone')
+        # validate its parent info
+        (pool, image, snap) = self.other_clone.parent_info()
+        eq(pool, 'rbd')
+        eq(image, IMG_NAME)
+        eq(snap, 'snap1')
+
+        # close and remove this pool's clone
+        self.clone.close()
+        self.rbd.remove(ioctx, 'clone')
+
+        # check that we cannot yet remove the parent snap
+        assert_raises(ImageBusy, self.image.remove_snap, 'snap1')
+
+        # close and remove other pool's clone
+        self.other_clone.close()
+        self.rbd.remove(other_ioctx, 'other_clone')
+
+        # now removing the parent snap should succeed
+        assert_raises(ImageBusy, self.image.remove_snap, 'snap1')
+
+        # unprotect, remove parent snap happen in cleanup, and should succeed
+
     def test_stat(self):
         image_info = self.image.stat()
         clone_info = self.clone.stat()