]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/tasks/cephfs/mount: switch to StringIO to fix TypeErrors
authorXiubo Li <xiubli@redhat.com>
Wed, 22 Apr 2020 12:34:05 +0000 (08:34 -0400)
committerKefu Chai <kchai@redhat.com>
Wed, 3 Jun 2020 11:57:00 +0000 (19:57 +0800)
TypeError: cannot use a string pattern on a bytes-like object

Fixes: https://tracker.ceph.com/issues/45175
Signed-off-by: Xiubo Li <xiubli@redhat.com>
(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
qa/tasks/cephfs/fuse_mount.py

index 2c2a63ab4b1caa3e279b7d123cfc139889552bd2..4b8b0c719a1aac0b5805193e6edece6673b72339 100644 (file)
@@ -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())
index 28e892b9d5d06df0dae593e213efd9c20b5822d9..d496a8f7aefccaeba89e728b9f1c485d0eef61f8 100644 (file)
@@ -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