]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
qa/workunits/fs/misc/direct_io.py: fix for py3
authorSage Weil <sage@redhat.com>
Thu, 19 Dec 2019 18:35:13 +0000 (12:35 -0600)
committerSage Weil <sage@redhat.com>
Thu, 19 Dec 2019 18:35:13 +0000 (12:35 -0600)
os.write takes bytes, os.read returns bytes

Signed-off-by: Sage Weil <sage@redhat.com>
qa/workunits/fs/misc/direct_io.py

index 6bdf239a44b4c4b23d825d1afb6b4e666b2af652..3419659630c5d389a966c8b41086e6c133dfde7d 100755 (executable)
@@ -21,26 +21,26 @@ def main():
     pool_name = get_data_pool()
 
     buf = mmap.mmap(-1, 1)
-    buf.write('1')
+    buf.write(b'1')
     os.write(fd, buf)
 
     proc = subprocess.Popen(['rados', '-p', pool_name, 'get', obj_name, 'tmpfile'])
     proc.wait()
 
-    with open('tmpfile', 'r') as tmpf:
-        out = tmpf.read()
-        if out != '1':
+    with open('tmpfile', 'rb') as tmpf:
+        out = tmpf.read(1)
+        if out != b'1':
             raise RuntimeError("data were not written to object store directly")
 
-    with open('tmpfile', 'w') as tmpf:
-        tmpf.write('2')
+    with open('tmpfile', 'wb') as tmpf:
+        tmpf.write(b'2')
 
     proc = subprocess.Popen(['rados', '-p', pool_name, 'put', obj_name, 'tmpfile'])
     proc.wait()
 
     os.lseek(fd, 0, os.SEEK_SET)
     out = os.read(fd, 1)
-    if out != '2':
+    if out != b'2':
         raise RuntimeError("data were not directly read from object store")
 
     os.close(fd)