From efe3cede3e491880f64cb9f43c38b45099cc1e71 Mon Sep 17 00:00:00 2001 From: neeraj pratap singh Date: Fri, 23 Feb 2024 11:17:30 +0530 Subject: [PATCH] cephfs-shell: fixing TestShellOpts in test_cephfs_shell.py 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 (cherry picked from commit 118ac67dffdd686592dabd956ff1d285638e053e) --- qa/tasks/cephfs/test_cephfs_shell.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/qa/tasks/cephfs/test_cephfs_shell.py b/qa/tasks/cephfs/test_cephfs_shell.py index 9f743476270..8466260e360 100644 --- a/qa/tasks/cephfs/test_cephfs_shell.py +++ b/qa/tasks/cephfs/test_cephfs_shell.py @@ -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) -- 2.39.5