when the caller expects binary data, it should pass BytesIO as stdout.
this change shold address the failure of
```
2020-04-05T12:47:25.335 INFO:tasks.cephfs_test_runner:======================================================================
2020-04-05T12:47:25.336 INFO:tasks.cephfs_test_runner:ERROR: test_apply_tag (tasks.cephfs.test_forward_scrub.TestForwardScrub)
2020-04-05T12:47:25.336 INFO:tasks.cephfs_test_runner:----------------------------------------------------------------------
2020-04-05T12:47:25.336 INFO:tasks.cephfs_test_runner:Traceback (most recent call last):
2020-04-05T12:47:25.337 INFO:tasks.cephfs_test_runner: File "/home/teuthworker/src/github.com_tchaikov_ceph_wip-qa-py3/qa/tasks/cephfs/test_forward_scrub.py", line 75, in test_apply_tag
2020-04-05T12:47:25.337 INFO:tasks.cephfs_test_runner: self.assertTagged(inos[dirpath], tag, self.fs.get_metadata_pool_name())
2020-04-05T12:47:25.337 INFO:tasks.cephfs_test_runner: File "/home/teuthworker/src/github.com_tchaikov_ceph_wip-qa-py3/qa/tasks/cephfs/test_forward_scrub.py", line 98, in assertTagged
2020-04-05T12:47:25.338 INFO:tasks.cephfs_test_runner: "scrub_tag"
2020-04-05T12:47:25.338 INFO:tasks.cephfs_test_runner: File "/home/teuthworker/src/github.com_tchaikov_ceph_wip-qa-py3/qa/tasks/cephfs/test_forward_scrub.py", line 35, in _read_str_xattr
2020-04-05T12:47:25.339 INFO:tasks.cephfs_test_runner: strlen = struct.unpack('i', output[0:4])[0]
2020-04-05T12:47:25.339 INFO:tasks.cephfs_test_runner:TypeError: a bytes-like object is required, not 'str'
```
Signed-off-by: Kefu Chai <kchai@redhat.com>
import traceback
from io import BytesIO
+from six import StringIO
from teuthology.exceptions import CommandFailedError
from teuthology import misc
return True
def rados(self, args, pool=None, namespace=None, stdin_data=None,
- stdin_file=None):
+ stdin_file=None,
+ stdout_data=None):
"""
Call into the `rados` CLI from an MDS
"""
if stdin_file is not None:
args = ["bash", "-c", "cat " + stdin_file + " | " + " ".join(args)]
+ if stdout_data is None:
+ stdout_data = StringIO()
- output = remote.sh(args, stdin=stdin_data)
- return output.strip()
+ p = remote.run(args=args,
+ stdin=stdin_data,
+ stdout=stdout_data)
+ return p.stdout.getvalue().strip()
def list_dirfrag(self, dir_ino):
"""
import logging
import os
import time
-from textwrap import dedent
import traceback
+
+from io import BytesIO
from collections import namedtuple, defaultdict
+from textwrap import dedent
from teuthology.orchestra.run import CommandFailedError
from tasks.cephfs.cephfs_test_case import CephFSTestCase, for_teuthology
# introduce duplicated primary link
file1_key = "file1_head"
self.assertIn(file1_key, dirfrag1_keys)
- file1_omap_data = self.fs.rados(["getomapval", dirfrag1_oid, file1_key, '-'])
+ file1_omap_data = self.fs.rados(["getomapval", dirfrag1_oid, file1_key, '-'],
+ stdout_data=BytesIO())
self.fs.rados(["setomapval", dirfrag2_oid, file1_key], stdin_data=file1_omap_data)
self.assertIn(file1_key, self._dirfrag_keys(dirfrag2_oid))
import logging
from collections import namedtuple
+from io import BytesIO
from textwrap import dedent
from teuthology.orchestra.run import CommandFailedError
"""
Read a ceph-encoded string from a rados xattr
"""
- output = self.fs.rados(["getxattr", obj, attr], pool=pool)
+ output = self.fs.rados(["getxattr", obj, attr], pool=pool,
+ stdout_data=BytesIO())
strlen = struct.unpack('i', output[0:4])[0]
return output[4:(4 + strlen)]