From 05eb2f647d16504a81ff17a8ef732cf0e2d90284 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 19 Dec 2019 11:08:59 -0600 Subject: [PATCH] qa/tasks/cephfs: os.write takes bytes, not str Signed-off-by: Sage Weil --- qa/tasks/cephfs/mount.py | 4 ++-- qa/tasks/cephfs/test_full.py | 10 +++++----- qa/tasks/cephfs/test_pool_perm.py | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/qa/tasks/cephfs/mount.py b/qa/tasks/cephfs/mount.py index fe7186fb57d..b729d801ab7 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 9ebab53549c..279c21ebe2d 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 22775e71c1b..f0efc43ec63 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 -- 2.39.5