]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
tests: Make librbd tests compatible with Python 3
authorOleh Prypin <oleh@pryp.in>
Fri, 24 Jun 2016 12:52:42 +0000 (15:52 +0300)
committerOleh Prypin <oleh@pryp.in>
Thu, 21 Jul 2016 15:35:17 +0000 (18:35 +0300)
Signed-off-by: Oleh Prypin <oleh@pryp.in>
src/test/librbd/rbdrw.py
src/test/librbd/test_notify.py

index 717955110b482f0d6c920e75d77367c851f74a1e..8dbbda24c1c1b8b3720320a74884c530cb858d4e 100644 (file)
@@ -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
index b62f017b0dc06e24f25faaefae750bbea3dc8a6f..43034c741d84620f821bdb665c07eb5445be242d 100755 (executable)
@@ -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')