From: Rishabh Dave Date: Wed, 20 Apr 2022 11:07:16 +0000 (+0530) Subject: qa/cephfs: don't use exclam mark in tests in test_cephfs_shell.py X-Git-Tag: v18.0.0~1027^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=faa506798d83a994942ad9e03e2a7c267a39c5fd;p=ceph.git qa/cephfs: don't use exclam mark in tests in test_cephfs_shell.py Exclamation mark is a special character for bash as well as cephfs-shell. For bash, it substitutes current command with matching command from command history and for cephfs-shell it runs the command as OS-level command and not inside the cephfs-shell. And evey command executed in tests (say "ls") is run by passing it as a parameter to cephfs-shell command (that is "cephfs-shell -c -- ls"). So, exclamation mark, when used in tests, is consumed by bash instead of cephfs-shell. To avoid these complications it's best (and even simpler!) to issue the command meant for bash on bash without going through cephfs-shell. Fixes: https://tracker.ceph.com/issues/55394 Signed-off-by: Rishabh Dave --- diff --git a/qa/tasks/cephfs/test_cephfs_shell.py b/qa/tasks/cephfs/test_cephfs_shell.py index ac82a1584b74..f9d6ad44cef5 100644 --- a/qa/tasks/cephfs/test_cephfs_shell.py +++ b/qa/tasks/cephfs/test_cephfs_shell.py @@ -336,7 +336,9 @@ class TestGetAndPut(TestCephFSShell): self.mount_a.run_shell_payload(f"rm -rf {tempdir}") self.run_cephfs_shell_cmd('get ' + tempdirname) - pwd = self.get_cephfs_shell_cmd_output('!pwd') + # NOTE: cwd=None because we want to run it at CWD, not at cephfs mntpt. + pwd = self.mount_a.run_shell('pwd', cwd=None).stdout.getvalue().\ + strip() for file_ in files: if file_ == tempdirname: self.mount_a.run_shell_payload(f"stat {path.join(pwd, file_)}") @@ -359,7 +361,9 @@ class TestGetAndPut(TestCephFSShell): o = self.get_cephfs_shell_cmd_output("get dump4 .") log.info("cephfs-shell output:\n{}".format(o)) - o = self.get_cephfs_shell_cmd_output("!cat dump4") + # NOTE: cwd=None because we want to run it at CWD, not at cephfs mntpt. + o = self.mount_a.run_shell('cat dump4', cwd=None).stdout.getvalue().\ + strip() o_hash = crypt.crypt(o, '.A') # s_hash must be equal to o_hash @@ -381,7 +385,9 @@ class TestGetAndPut(TestCephFSShell): # get dump5 should fail o = self.get_cephfs_shell_cmd_output("get dump5") - o = self.get_cephfs_shell_cmd_output("!stat dump5 || echo $?") + # NOTE: cwd=None because we want to run it at CWD, not at cephfs mntpt. + o = self.mount_a.run_shell('stat dump5 || echo $?', cwd=None).stdout.\ + getvalue().strip() log.info("cephfs-shell output:\n{}".format(o)) l = o.split('\n') try: