]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/tasks: use StringIO for capturing string output
authorKefu Chai <kchai@redhat.com>
Sun, 5 Apr 2020 10:35:42 +0000 (18:35 +0800)
committerKefu Chai <kchai@redhat.com>
Tue, 7 Apr 2020 13:51:22 +0000 (21:51 +0800)
see d8d44ed1566b19eec055e07da2a0fed88fed4152

Signed-off-by: Kefu Chai <kchai@redhat.com>
qa/tasks/ceph_manager.py
qa/tasks/cephadm.py
qa/tasks/watch_notify_same_primary.py

index 1ec5840d77bbba0b2b48c847bbf6492606592a7c..9ba9725932fc2c9c08e52121f6adfa8cca39bc8e 100644 (file)
@@ -16,6 +16,7 @@ import os
 import six
 
 from io import BytesIO
+from six import StringIO
 from teuthology import misc as teuthology
 from tasks.scrub import Scrubber
 from tasks.util.rados import cmd_erasure_code_profile
@@ -1409,7 +1410,7 @@ class CephManager:
         if watch_channel is not None:
             args.append("--watch-channel")
             args.append(watch_channel)
-        return self.controller.run(args=args, wait=False, stdout=BytesIO(), stdin=run.PIPE)
+        return self.controller.run(args=args, wait=False, stdout=StringIO(), stdin=run.PIPE)
 
     def get_mon_socks(self):
         """
@@ -1592,7 +1593,7 @@ class CephManager:
 
     def osd_admin_socket(self, osd_id, command, check_status=True, timeout=0, stdout=None):
         if stdout is None:
-            stdout = BytesIO()
+            stdout = StringIO()
         return self.admin_socket('osd', osd_id, command, check_status, timeout, stdout)
 
     def find_remote(self, service_type, service_id):
@@ -1616,7 +1617,7 @@ class CephManager:
                         to the admin socket
         """
         if stdout is None:
-            stdout = BytesIO()
+            stdout = StringIO()
 
         remote = self.find_remote(service_type, service_id)
 
@@ -1745,7 +1746,7 @@ class CephManager:
         five seconds and try again.
         """
         if stdout is None:
-            stdout = BytesIO()
+            stdout = StringIO()
         tries = 0
         while True:
             proc = self.admin_socket(service_type, service_id,
index 046cda1f0d38c266e1ba3120628487b8c0976fca..5703c7ad27227ba0c4b7bebbaa3be7887a7bf550 100644 (file)
@@ -1,8 +1,6 @@
 """
 Ceph cluster task, deployed via cephadm orchestrator
 """
-from io import BytesIO
-
 import argparse
 import configobj
 import contextlib
@@ -12,6 +10,8 @@ import json
 import re
 import uuid
 
+from io import BytesIO
+from six import StringIO
 from tarfile import ReadError
 from tasks.ceph_manager import CephManager
 from teuthology import misc as teuthology
@@ -189,7 +189,7 @@ def ceph_log(ctx, config):
                 run.Raw('|'), 'head', '-n', '1',
             ])
             r = ctx.ceph[cluster_name].bootstrap_remote.run(
-                stdout=BytesIO(),
+                stdout=StringIO(),
                 args=args,
             )
             stdout = r.stdout.getvalue()
@@ -312,7 +312,7 @@ def ceph_bootstrap(ctx, config):
             remote=bootstrap_remote,
             path='{}/seed.{}.conf'.format(testdir, cluster_name),
             data=conf_fp.getvalue())
-        log.debug('Final config:\n' + conf_fp.getvalue())
+        log.debug('Final config:\n' + conf_fp.getvalue().decode())
         ctx.ceph[cluster_name].conf = seed_config
 
         # register initial daemons
@@ -429,7 +429,7 @@ def ceph_bootstrap(ctx, config):
             ])
             r = _shell(ctx, cluster_name, remote,
                        ['ceph', 'orch', 'host', 'ls', '--format=json'],
-                       stdout=BytesIO())
+                       stdout=StringIO())
             hosts = [node['hostname'] for node in json.loads(r.stdout.getvalue())]
             assert remote.shortname in hosts
 
@@ -501,7 +501,7 @@ def ceph_mons(ctx, config):
                             args=[
                                 'ceph', 'mon', 'dump', '-f', 'json',
                             ],
-                            stdout=BytesIO(),
+                            stdout=StringIO(),
                         )
                         j = json.loads(r.stdout.getvalue())
                         if len(j['mons']) == num_mons:
@@ -516,7 +516,7 @@ def ceph_mons(ctx, config):
             args=[
                 'ceph', 'config', 'generate-minimal-conf',
             ],
-            stdout=BytesIO(),
+            stdout=StringIO(),
         )
         ctx.ceph[cluster_name].config_file = r.stdout.getvalue()
 
@@ -756,7 +756,7 @@ def ceph_clients(ctx, config):
                     'mds', 'allow *',
                     'mgr', 'allow *',
                 ],
-                stdout=BytesIO(),
+                stdout=StringIO(),
             )
             keyring = r.stdout.getvalue()
             teuthology.sudo_write_file(
index 7160979119b38ff0c640d5caee33ed04b0cf4f32..7c034961c3824f6abc378f539ea2e7b2f5976203 100644 (file)
@@ -2,7 +2,7 @@
 """
 watch_notify_same_primary task
 """
-from io import BytesIO
+from six import StringIO
 import contextlib
 import logging
 
@@ -68,8 +68,8 @@ def task(ctx, config):
                 "watch",
                 obj(n)],
             stdin=run.PIPE,
-            stdout=BytesIO(),
-            stderr=BytesIO(),
+            stdout=StringIO(),
+            stderr=StringIO(),
             wait=False)
         return proc