test_cephfs_shell: run cephfs-shell with conf file

And set colors to False and debug to True in this conf file.

stdout captured by Python code in this testsuite can contain the colour
codes along with the expected string output. Setting colors to False in
cephfs-shell.conf should fix this.

Setting debug to False should help with analyzing test failures since
it enables printing messages that helps debugging (stacktrace for
cephfs-shell code, for example).

Signed-off-by: Rishabh Dave <ridave@redhat.com>
This commit is contained in:
Rishabh Dave 2020-05-26 17:30:03 +05:30
parent 57734cf105
commit 58c7c7e8f4

View File

@ -34,6 +34,15 @@ def humansize(nbytes):
class TestCephFSShell(CephFSTestCase):
CLIENTS_REQUIRED = 1
def setUp(self):
super(TestCephFSShell, self).setUp()
conf_contents = "[cephfs-shell]\ncolors = False\ndebug = True\n"
confpath = self.mount_a.run_shell(args=['mktemp']).stdout.\
getvalue().strip()
sudo_write_file(self.mount_a.client_remote, confpath, conf_contents)
self.default_shell_conf_path = confpath
def run_cephfs_shell_cmd(self, cmd, mount_x=None, shell_conf_path=None,
opts=None, stdout=None, stderr=None, stdin=None,
check_status=True):
@ -41,13 +50,12 @@ class TestCephFSShell(CephFSTestCase):
stderr = stderr or StringIO()
if mount_x is None:
mount_x = self.mount_a
if isinstance(cmd, list):
cmd = " ".join(cmd)
if not shell_conf_path:
shell_conf_path = self.default_shell_conf_path
args = ["cephfs-shell"]
if shell_conf_path:
args += ["-c", shell_conf_path]
args = ["cephfs-shell", "-c", shell_conf_path]
if opts:
args += opts
args.extend(("--", cmd))