From: Oleh Prypin Date: Fri, 24 Jun 2016 12:52:42 +0000 (+0300) Subject: tests: Make librbd tests compatible with Python 3 X-Git-Tag: ses5-milestone5~254^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b24b646ab966e77bfc8a94d3e5458dcb8ab415b8;p=ceph.git tests: Make librbd tests compatible with Python 3 Signed-off-by: Oleh Prypin --- diff --git a/src/test/librbd/rbdrw.py b/src/test/librbd/rbdrw.py index 717955110b48..8dbbda24c1c1 100644 --- a/src/test/librbd/rbdrw.py +++ b/src/test/librbd/rbdrw.py @@ -22,7 +22,7 @@ with rados.Rados(conffile='') as r: with rbd.Image(ioctx, sys.argv[1]) as image: image.lock_exclusive(sys.argv[2]) while True: - image.write('A' * 4096, 0) + image.write(b'A' * 4096, 0) r = image.read(0, 4096) except rbd.ConnectionShutdown: # it so happens that the errno here is 108, but diff --git a/src/test/librbd/test_notify.py b/src/test/librbd/test_notify.py index b62f017b0dc0..43034c741d84 100755 --- a/src/test/librbd/test_notify.py +++ b/src/test/librbd/test_notify.py @@ -70,7 +70,7 @@ def master(ioctx): while offset < IMG_SIZE: image.write(data, offset) offset += (1 << IMG_ORDER) - image.write('1', IMG_SIZE - 1) + image.write(b'1', IMG_SIZE - 1) assert(image.is_exclusive_lock_owner()) print("waiting for slave to complete") @@ -80,7 +80,7 @@ def master(ioctx): safe_delete_image(ioctx, CLONE_IMG_RENAME) safe_delete_image(ioctx, CLONE_IMG_NAME) delete_image(ioctx, PARENT_IMG_NAME) - print ("finished") + print("finished") def slave(ioctx): print("starting slave") @@ -89,7 +89,7 @@ def slave(ioctx): try: with Image(ioctx, CLONE_IMG_NAME) as image: if (image.list_lockers() != [] and - image.read(IMG_SIZE - 1, 1) == '1'): + image.read(IMG_SIZE - 1, 1) == b'1'): break except Exception: pass @@ -106,14 +106,15 @@ def slave(ioctx): assert(not image.is_exclusive_lock_owner()) print("resize") - image.resize(IMG_SIZE / 2) + image.resize(IMG_SIZE // 2) assert(not image.is_exclusive_lock_owner()) - assert(image.stat()['size'] == IMG_SIZE / 2) + assert(image.stat()['size'] == IMG_SIZE // 2) print("create_snap") image.create_snap('snap1') assert(not image.is_exclusive_lock_owner()) - assert('snap1' in map(lambda snap: snap['name'], image.list_snaps())) + assert(any(snap['name'] == 'snap1' + for snap in image.list_snaps())) print("protect_snap") image.protect_snap('snap1') @@ -128,8 +129,8 @@ def slave(ioctx): 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())) + assert(any(snap['name'] == 'snap1-new' + for snap in image.list_snaps())) print("remove_snap") image.remove_snap('snap1-new')