]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa: testcase test_get_without_target_name fixed 46297/head
authordparmar18 <dparmar@redhat.com>
Tue, 26 Apr 2022 19:03:18 +0000 (00:33 +0530)
committerdparmar18 <dparmar@redhat.com>
Tue, 17 May 2022 08:21:23 +0000 (13:51 +0530)
Signed-off-by: Dhairya Parmar <dparmar@redhat.com>
(cherry picked from commit 1e3fb3c8741d90de3dc8a7a6748f1136ad0afdc1)

qa/tasks/cephfs/test_cephfs_shell.py

index 51c97fa389829a46ddb29107164c5560c83a0fc5..8995d260ffdc76d84a0a5012a5d4ddfd16702fea 100644 (file)
@@ -335,31 +335,23 @@ class TestGetAndPut(TestCephFSShell):
 
     def test_get_without_target_name(self):
         """
-        Test that get passes with target name
+        Test that get should fail when there is no target name
         """
-        s = 'D' * 1024
-        o = self.get_cephfs_shell_cmd_output("put - dump5", stdin=s)
-        log.info("cephfs-shell output:\n{}".format(o))
-
+        s = 'Somedata'
         # put - dump5 should pass
-        o = self.mount_a.stat('dump5')
-        log.info("mount_a output:\n{}".format(o))
+        self.get_cephfs_shell_cmd_output("put - dump5", stdin=s)
 
-        # get dump5 should fail
-        o = self.get_cephfs_shell_cmd_output("get dump5")
-        o = self.get_cephfs_shell_cmd_output("!stat dump5 || echo $?")
-        log.info("cephfs-shell output:\n{}".format(o))
-        l = o.split('\n')
-        try:
-            ret = int(l[1])
-            # verify that stat dump5 passes
-            # if ret == 1, then that implies the stat failed
-            # which implies that there was a problem with "get dump5"
-            assert(ret != 1)
-        except ValueError:
-            # we have a valid stat output; so this is good
-            # if the int() fails then that means there's a valid stat output
-            pass
+        self.mount_a.stat('dump5')
+
+        # get dump5 should fail as there is no local_path mentioned
+        with self.assertRaises(CommandFailedError):
+            self.get_cephfs_shell_cmd_output("get dump5")
+
+        # stat dump would return non-zero exit code as get dump failed
+        # cwd=None because we want to run it at CWD, not at cephfs mntpt.
+        r = self.mount_a.run_shell('stat dump5', cwd=None,
+                                   check_status=False).returncode
+        self.assertEqual(r, 1)
 
     def test_get_doesnt_create_dir(self):
         # if get cmd is creating subdirs on its own then dump7 will be