]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/cephfs: don't use exclam mark in tests in test_cephfs_shell.py
authorRishabh Dave <ridave@redhat.com>
Wed, 20 Apr 2022 11:07:16 +0000 (16:37 +0530)
committerRishabh Dave <ridave@redhat.com>
Thu, 21 Apr 2022 11:10:29 +0000 (16:40 +0530)
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 <conf> --
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 <ridave@redhat.com>
qa/tasks/cephfs/test_cephfs_shell.py

index ac82a1584b741c1c8fc97a7db960877e9bd2dc33..f9d6ad44cef5502f2792b0d692c829decc62a7e9 100644 (file)
@@ -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: