From 354224efa7d6fd3eaddde8356be85430c5d109df Mon Sep 17 00:00:00 2001 From: Xiubo Li Date: Wed, 22 Apr 2020 08:34:05 -0400 Subject: [PATCH] qa/tasks/cephfs/mount: switch to StringIO to fix TypeErrors TypeError: cannot use a string pattern on a bytes-like object Fixes: https://tracker.ceph.com/issues/45175 Signed-off-by: Xiubo Li (cherry picked from commit 0631342d105575fda009e9e97b26859616be2565) Conflicts: qa/tasks/cephfs/fuse_mount.py qa/tasks/cephfs/mount.py: drop the change not applicable to nautilus. --- qa/tasks/cephfs/filesystem.py | 7 ++++--- qa/tasks/cephfs/fuse_mount.py | 17 ++++++++--------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/qa/tasks/cephfs/filesystem.py b/qa/tasks/cephfs/filesystem.py index 2c2a63ab4b1ca..4b8b0c719a1aa 100644 --- a/qa/tasks/cephfs/filesystem.py +++ b/qa/tasks/cephfs/filesystem.py @@ -11,7 +11,7 @@ import random import traceback from io import BytesIO -from six import StringIO +from io import StringIO from teuthology.exceptions import CommandFailedError from teuthology import misc @@ -1065,7 +1065,7 @@ class Filesystem(MDSCluster): os.path.join(self._prefix, "rados"), "-p", pool, "getxattr", obj_name, xattr_name ] try: - proc = remote.run(args=args, stdout=BytesIO()) + proc = remote.run(args=args, stdout=StringIO()) except CommandFailedError as e: log.error(e.__str__()) raise ObjectNotFound(obj_name) @@ -1076,7 +1076,8 @@ class Filesystem(MDSCluster): "type", type, "import", "-", "decode", "dump_json"], - stdin=data + stdin=data, + stdout=StringIO() ) return json.loads(dump.strip()) diff --git a/qa/tasks/cephfs/fuse_mount.py b/qa/tasks/cephfs/fuse_mount.py index 28e892b9d5d06..d496a8f7aefcc 100644 --- a/qa/tasks/cephfs/fuse_mount.py +++ b/qa/tasks/cephfs/fuse_mount.py @@ -1,4 +1,3 @@ -from io import BytesIO from io import StringIO import json import time @@ -187,15 +186,15 @@ class FuseMount(CephFSMount): '--', self.mountpoint, ], - stdout=BytesIO(), - stderr=BytesIO(), + stdout=StringIO(), + stderr=StringIO(), wait=False, timeout=(15*60) ) try: proc.wait() except CommandFailedError: - error = six.ensure_str(proc.stderr.getvalue()) + error = proc.stderr.getvalue() if ("endpoint is not connected" in error or "Software caused connection abort" in error): # This happens is fuse is killed without unmount @@ -231,11 +230,11 @@ class FuseMount(CephFSMount): # Now that we're mounted, set permissions so that the rest of the test will have # unrestricted access to the filesystem mount. try: - stderr = BytesIO() + stderr = StringIO() self.client_remote.run(args=['sudo', 'chmod', '1777', self.mountpoint], timeout=(15*60), stderr=stderr) except run.CommandFailedError: stderr = stderr.getvalue() - if b"Read-only file system".lower() in stderr.lower(): + if "Read-only file system".lower() in stderr.lower(): pass else: raise @@ -277,7 +276,7 @@ class FuseMount(CephFSMount): """).format(self._fuse_conn)) self._fuse_conn = None - stderr = BytesIO() + stderr = StringIO() try: # make sure its unmounted self.client_remote.run( @@ -339,7 +338,7 @@ class FuseMount(CephFSMount): Prerequisite: the client is not mounted. """ - stderr = BytesIO() + stderr = StringIO() try: self.client_remote.run( args=[ @@ -351,7 +350,7 @@ class FuseMount(CephFSMount): timeout=(60*5) ) except CommandFailedError: - if b"No such file or directory" in stderr.getvalue(): + if "No such file or directory" in stderr.getvalue(): pass else: raise -- 2.39.5