From: Rishabh Dave Date: Thu, 27 Jun 2019 13:40:28 +0000 (+0530) Subject: test_cephfs_shell: allow running CephFS shell script X-Git-Tag: v15.1.0~2061^2~6 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=fef0180c93393b4890093b782cc113494fa6d236;p=ceph.git test_cephfs_shell: allow running CephFS shell script Add a method to test_cephfs_shell.py that allows running CephFS shell script using option "-b" of cephfs-shell. Signed-off-by: Rishabh Dave --- diff --git a/qa/tasks/cephfs/test_cephfs_shell.py b/qa/tasks/cephfs/test_cephfs_shell.py index 31f16b44a257..ab267e521847 100644 --- a/qa/tasks/cephfs/test_cephfs_shell.py +++ b/qa/tasks/cephfs/test_cephfs_shell.py @@ -1,6 +1,7 @@ import os import crypt import logging +from tempfile import mkstemp as tempfile_mkstemp from StringIO import StringIO from tasks.cephfs.cephfs_test_case import CephFSTestCase from tasks.cephfs.fuse_mount import FuseMount @@ -23,6 +24,22 @@ class TestCephFSShell(CephFSTestCase): stdin=stdin) return status.stdout.getvalue().strip() + def run_cephfs_shell_script(self, script, mount_x=None, stdin=None): + if mount_x is None: + mount_x = self.mount_a + + scriptpath = tempfile_mkstemp(prefix='test-cephfs', text=True)[1] + with open(scriptpath, 'w') as scriptfile: + scriptfile.write(script) + # copy script to the machine running cephfs-shell. + mount_x.client_remote.put_file(scriptpath, scriptpath) + mount_x.run_shell('chmod 755 ' + scriptpath) + + args = ["cephfs-shell", "-c", mount_x.config_path, '-b', scriptpath] + log.info('Running script \"' + scriptpath + '\"') + return mount_x.client_remote.run(args=args, stdout=StringIO(), + stderr=StringIO(), stdin=stdin) + def test_help(self): """ Test that help outputs commands.