]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
tests: snap rename and rebuild object map in client update test 7224/head
authorJason Dillaman <dillaman@redhat.com>
Thu, 14 Jan 2016 00:02:39 +0000 (19:02 -0500)
committerJason Dillaman <dillaman@redhat.com>
Thu, 14 Jan 2016 00:03:13 +0000 (19:03 -0500)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/test/librbd/test_notify.py

index 4d3a7713fa5889f2b6816b751d22d96f3c8a5c92..2f191c6e87c74ee45ef849f0bb3222fdf42aa3a2 100755 (executable)
@@ -8,7 +8,10 @@ from rbd import (RBD,
                  Image,
                  ImageNotFound,
                  RBD_FEATURE_EXCLUSIVE_LOCK,
-                 RBD_FEATURE_LAYERING)
+                 RBD_FEATURE_LAYERING,
+                 RBD_FEATURE_OBJECT_MAP,
+                 RBD_FEATURE_FAST_DIFF,
+                 RBD_FLAG_OBJECT_MAP_INVALID)
 
 POOL_NAME='rbd'
 PARENT_IMG_NAME='test_notify_parent'
@@ -47,6 +50,7 @@ def get_features():
 
 def master(ioctx):
     print("starting master")
+    safe_delete_image(ioctx, CLONE_IMG_RENAME)
     safe_delete_image(ioctx, CLONE_IMG_NAME)
     safe_delete_image(ioctx, PARENT_IMG_NAME)
 
@@ -72,7 +76,8 @@ def master(ioctx):
         while image.is_exclusive_lock_owner():
             time.sleep(5)
 
-    delete_image(ioctx, CLONE_IMG_NAME)
+    safe_delete_image(ioctx, CLONE_IMG_RENAME)
+    safe_delete_image(ioctx, CLONE_IMG_NAME)
     delete_image(ioctx, PARENT_IMG_NAME)
     print ("finished")
 
@@ -87,9 +92,13 @@ def slave(ioctx):
         except Exception:
             pass
 
-    with Image(ioctx, CLONE_IMG_NAME) as image:
-        print("detected master")
+    print("detected master")
+
+    print("rename")
+    RBD().rename(ioctx, CLONE_IMG_NAME, CLONE_IMG_RENAME);
+    assert(not image.is_exclusive_lock_owner())
 
+    with Image(ioctx, CLONE_IMG_RENAME) as image:
         print("flatten")
         image.flatten()
         assert(not image.is_exclusive_lock_owner())
@@ -107,26 +116,38 @@ def slave(ioctx):
         print("protect_snap")
         image.protect_snap('snap1')
         assert(not image.is_exclusive_lock_owner())
-        assert(image.is_protected_snap())
+        assert(image.is_protected_snap('snap1'))
 
         print("unprotect_snap")
         image.unprotect_snap('snap1')
         assert(not image.is_exclusive_lock_owner())
-        assert(not image.is_protected_snap())
+        assert(not image.is_protected_snap('snap1'))
+
+        print("rename_snap")
+        image.rename_snap('snap1', 'snap1-new')
+        assert(not image.is_exclusive_lock_owner())
+        assert('snap1-new' in map(lambda snap: snap['name'],
+                                  image.list_snaps()))
 
         print("remove_snap")
-        image.remove_snap('snap1')
+        image.remove_snap('snap1-new')
         assert(not image.is_exclusive_lock_owner())
         assert(list(image.list_snaps()) == [])
 
+        print("rebuild object map")
+        image.update_features(RBD_FEATURE_OBJECT_MAP | RBD_FEATURE_FAST_DIFF,
+                              False)
+        image.update_features(RBD_FEATURE_OBJECT_MAP, True)
+        assert((image.flags() & RBD_FLAG_OBJECT_MAP_INVALID) != 0)
+        image.rebuild_object_map()
+        assert(not image.is_exclusive_lock_owner())
+        assert((image.flags() & RBD_FLAG_OBJECT_MAP_INVALID) == 0)
+
         print("write")
         data = os.urandom(512)
         image.write(data, 0)
         assert(image.is_exclusive_lock_owner())
 
-    print("rename")
-    RBD().rename(ioctx, CLONE_IMG_NAME, CLONE_IMG_RENAME);
-
     print("finished")
 
 def main():