]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/tasks/util/rgw: use StringIO for capturing strings
authorKefu Chai <kchai@redhat.com>
Mon, 6 Apr 2020 04:48:18 +0000 (12:48 +0800)
committerKefu Chai <kchai@redhat.com>
Wed, 3 Jun 2020 11:56:59 +0000 (19:56 +0800)
this change should address the failure of
```
2020-04-06T03:07:59.152 ERROR:teuthology.contextutil:Saw exception from nested tasks
Traceback (most recent call last):
  File "/home/teuthworker/src/git.ceph.com_git_teuthology_wip-py3/teuthology/contextutil.py", line 32, in nested
    vars.append(enter())
  File "/usr/lib/python3.5/contextlib.py", line 59, in __enter__
    return next(self.gen)
  File "/home/teuthworker/src/github.com_tchaikov_ceph_wip-qa-py3/qa/tasks/rgw.py", line 266, in configure_compression
    rgwadmin(ctx, client, cmd=['user', 'list'], check_status=True)
  File "/home/teuthworker/src/github.com_tchaikov_ceph_wip-qa-py3/qa/tasks/util/rgw.py", line 43, in rgwadmin
    j = json.loads(out)
  File "/usr/lib/python3.5/json/__init__.py", line 312, in loads
    s.__class__.__name__))
TypeError: the JSON object must be str, not 'bytes'
```

Signed-off-by: Kefu Chai <kchai@redhat.com>
(cherry picked from commit 5d0dc8346c7c025a868fd32b112cdb32fa5dc9ea)

qa/tasks/util/rgw.py

index a4fa21f370a8c65e4b7b4b6a005ded6c936ed212..3229f0a5073e7d01502431364f26aa148a1f8424 100644 (file)
@@ -1,13 +1,14 @@
-from io import BytesIO
 import logging
 import json
 import time
 
+from six import StringIO
+
 from teuthology import misc as teuthology
 
 log = logging.getLogger(__name__)
 
-def rgwadmin(ctx, client, cmd, stdin=BytesIO(), check_status=False,
+def rgwadmin(ctx, client, cmd, stdin=StringIO(), check_status=False,
              format='json', decode=True, log_level=logging.DEBUG):
     log.info('rgwadmin: {client} : {cmd}'.format(client=client,cmd=cmd))
     testdir = teuthology.get_testdir(ctx)
@@ -29,8 +30,8 @@ def rgwadmin(ctx, client, cmd, stdin=BytesIO(), check_status=False,
     proc = remote.run(
         args=pre,
         check_status=check_status,
-        stdout=BytesIO(),
-        stderr=BytesIO(),
+        stdout=StringIO(),
+        stderr=StringIO(),
         stdin=stdin,
         )
     r = proc.exitstatus
@@ -81,9 +82,9 @@ def wait_for_radosgw(url, remote):
         proc = remote.run(
             args=curl_cmd,
             check_status=False,
-            stdout=BytesIO(),
-            stderr=BytesIO(),
-            stdin=BytesIO(),
+            stdout=StringIO(),
+            stderr=StringIO(),
+            stdin=StringIO(),
             )
         exit_status = proc.exitstatus
         if exit_status == 0: