From: Jason Dillaman Date: Thu, 14 Jan 2016 00:02:39 +0000 (-0500) Subject: tests: snap rename and rebuild object map in client update test X-Git-Tag: v10.0.3~58^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4c3b6852af400f85044168e3dca5b2fb9d7efdd2;p=ceph.git tests: snap rename and rebuild object map in client update test Signed-off-by: Jason Dillaman --- diff --git a/src/test/librbd/test_notify.py b/src/test/librbd/test_notify.py index 4d3a7713fa58..2f191c6e87c7 100755 --- a/src/test/librbd/test_notify.py +++ b/src/test/librbd/test_notify.py @@ -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():