From: Sage Weil Date: Thu, 19 Dec 2019 17:08:59 +0000 (-0600) Subject: qa/tasks/cephfs: os.write takes bytes, not str X-Git-Tag: v15.1.0~423^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=05eb2f647d16504a81ff17a8ef732cf0e2d90284;p=ceph.git qa/tasks/cephfs: os.write takes bytes, not str Signed-off-by: Sage Weil --- diff --git a/qa/tasks/cephfs/mount.py b/qa/tasks/cephfs/mount.py index fe7186fb57d5..b729d801ab70 100644 --- a/qa/tasks/cephfs/mount.py +++ b/qa/tasks/cephfs/mount.py @@ -394,10 +394,10 @@ class CephFSMount(object): import os import time - fd = os.open("{path}", os.O_RDWR | os.O_CREAT, 0644) + fd = os.open("{path}", os.O_RDWR | os.O_CREAT, 0o644) try: while True: - os.write(fd, 'content') + os.write(fd, b'content') time.sleep(1) if not {loop}: break diff --git a/qa/tasks/cephfs/test_full.py b/qa/tasks/cephfs/test_full.py index 9ebab53549cb..279c21ebe2db 100644 --- a/qa/tasks/cephfs/test_full.py +++ b/qa/tasks/cephfs/test_full.py @@ -250,7 +250,7 @@ class FullnessTestCase(CephFSTestCase): print("writing some data through which we expect to succeed") bytes = 0 f = os.open("{file_path}", os.O_WRONLY | os.O_CREAT) - bytes += os.write(f, 'a' * 512 * 1024) + bytes += os.write(f, b'a' * 512 * 1024) os.fsync(f) print("fsync'ed data successfully, will now attempt to fill fs") @@ -261,7 +261,7 @@ class FullnessTestCase(CephFSTestCase): full = False for n in range(0, int({fill_mb} * 0.9)): - bytes += os.write(f, 'x' * 1024 * 1024) + bytes += os.write(f, b'x' * 1024 * 1024) print("wrote {{0}} bytes via buffered write, may repeat".format(bytes)) print("done writing {{0}} bytes".format(bytes)) @@ -275,7 +275,7 @@ class FullnessTestCase(CephFSTestCase): print("starting buffered write") try: for n in range(0, int({fill_mb} * 0.2)): - bytes += os.write(f, 'x' * 1024 * 1024) + bytes += os.write(f, b'x' * 1024 * 1024) print("sleeping a bit as we've exceeded 90% of our expected full ratio") time.sleep({full_wait}) except OSError: @@ -321,7 +321,7 @@ class FullnessTestCase(CephFSTestCase): print("writing some data through which we expect to succeed") bytes = 0 f = os.open("{file_path}", os.O_WRONLY | os.O_CREAT) - bytes += os.write(f, 'a' * 4096) + bytes += os.write(f, b'a' * 4096) os.fsync(f) print("fsync'ed data successfully, will now attempt to fill fs") @@ -333,7 +333,7 @@ class FullnessTestCase(CephFSTestCase): for n in range(0, int({fill_mb} * 1.1)): try: - bytes += os.write(f, 'x' * 1024 * 1024) + bytes += os.write(f, b'x' * 1024 * 1024) print("wrote bytes via buffered write, moving on to fsync") except OSError as e: print("Unexpected error %s from write() instead of fsync()" % e) diff --git a/qa/tasks/cephfs/test_pool_perm.py b/qa/tasks/cephfs/test_pool_perm.py index 22775e71c1b0..f0efc43ec636 100644 --- a/qa/tasks/cephfs/test_pool_perm.py +++ b/qa/tasks/cephfs/test_pool_perm.py @@ -19,7 +19,7 @@ class TestPoolPerm(CephFSTestCase): if {check_read}: ret = os.read(fd, 1024) else: - os.write(fd, 'content') + os.write(fd, b'content') except OSError, e: if e.errno != errno.EPERM: raise