]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
cephfs-shell: fixing TestShellOpts in test_cephfs_shell.py
authorneeraj pratap singh <neerajpratapsingh@li-ff7f0d4c-3462-11b2-a85c-d4004c0fa1a0.ibm.com>
Fri, 23 Feb 2024 05:47:30 +0000 (11:17 +0530)
committerneeraj pratap singh <neerajpratapsingh@li-ff7f0d4c-3462-11b2-a85c-d4004c0fa1a0.ibm.com>
Tue, 16 Apr 2024 04:28:09 +0000 (09:58 +0530)
The issue arose due to the change in the output format of the
command `set editor`. Earlier the output format was like:
`editor: 'vim' ` which has been changed to:
```Name    Value                           Description
====================================================================================================
editor  vim                             Program used by 'edit' ```

Due to which fetching the list using indexes was `out of range`.

Introduced by: https://github.com/python-cmd2/cmd2/pull/1269/commits/fd38e706e33ff382a403e8b6956a9c1d24995ed0
Fixes: https://tracker.ceph.com/issues/63699
Signed-off-by: Neeraj Pratap Singh <neesingh@redhat.com>
(cherry picked from commit 118ac67dffdd686592dabd956ff1d285638e053e)

qa/tasks/cephfs/test_cephfs_shell.py

index 9f743476270b8de066c90f50edd2edaeb8899266..8466260e360ef4a9b4eb042f99a9c010f577d20c 100644 (file)
@@ -1110,9 +1110,9 @@ class TestShellOpts(TestCephFSShell):
         # now: '?'
         # editor: '?'
         self.editor_val = self.get_cephfs_shell_cmd_output(
-            'set editor ?, set editor').split('\n')[2]
-        self.editor_val = self.editor_val.split(':')[1]. \
-            replace("'", "", 2).strip()
+            'set editor ?, set editor').split('\n')[4]
+        self.editor_val = self.editor_val.split()[1].strip(). \
+            replace("'", "", 2)
 
     def write_tempconf(self, confcontents):
         self.tempconfpath = self.mount_a.client_remote.mktemp(
@@ -1128,8 +1128,9 @@ class TestShellOpts(TestCephFSShell):
         # editor: 'vim'
         final_editor_val = self.get_cephfs_shell_cmd_output(
             cmd='set editor', shell_conf_path=self.tempconfpath)
-        final_editor_val = final_editor_val.split(': ')[1]
-        final_editor_val = final_editor_val.replace("'", "", 2)
+        final_editor_val = final_editor_val.split('\n')[2]
+        final_editor_val = final_editor_val.split()[1].strip(). \
+            replace("'", "", 2)
 
         self.assertNotEqual(self.editor_val, final_editor_val)
 
@@ -1145,8 +1146,9 @@ class TestShellOpts(TestCephFSShell):
         # editor: 'vim'
         final_editor_val = self.get_cephfs_shell_cmd_output(
             cmd='set editor', shell_conf_path=self.tempconfpath)
-        final_editor_val = final_editor_val.split(': ')[1]
-        final_editor_val = final_editor_val.replace("'", "", 2)
+        final_editor_val = final_editor_val.split('\n')[2]
+        final_editor_val = final_editor_val.split()[1].strip(). \
+            replace("'", "", 2)
 
         self.assertEqual(self.editor_val, final_editor_val)
 
@@ -1160,8 +1162,8 @@ class TestShellOpts(TestCephFSShell):
         final_editor_val = self.get_cephfs_shell_cmd_output(
             cmd='set editor %s, set editor' % self.editor_val,
             shell_conf_path=self.tempconfpath)
-        final_editor_val = final_editor_val.split('\n')[2]
-        final_editor_val = final_editor_val.split(': ')[1]
-        final_editor_val = final_editor_val.replace("'", "", 2)
+        final_editor_val = final_editor_val.split('\n')[4]
+        final_editor_val = final_editor_val.split()[1].strip(). \
+            replace("'", "", 2)
 
         self.assertEqual(self.editor_val, final_editor_val)