From: Neeraj Pratap Singh Date: Wed, 20 May 2026 17:23:09 +0000 (+0530) Subject: qa: fixing failures in TestShellOpts X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b066d4cd3a3c7821f93bb7cc5390b97a19e22e94;p=ceph.git qa: fixing failures in TestShellOpts We were seeing failures in TestShellOpts again and again due the (newline added within the output) output structure change with the cmd2 releases. Now, we directly extract the final output of 'set editor' command and use it, instead of traversing on complete output through hardcoded indexes.This fix is better than earlier hardcoded splitting/striping via indexes. Fixes: https://tracker.ceph.com/issues/71795 Signed-off-by: Neeraj Pratap Singh --- diff --git a/qa/tasks/cephfs/test_cephfs_shell.py b/qa/tasks/cephfs/test_cephfs_shell.py index 0864c1e5a79..0cc4dab7760 100644 --- a/qa/tasks/cephfs/test_cephfs_shell.py +++ b/qa/tasks/cephfs/test_cephfs_shell.py @@ -1109,6 +1109,17 @@ class TestShellOpts(TestCephFSShell): Contains tests for shell options from conf file and shell prompt. """ + def extract_set_editor_output(self, out): + res = None + for line in out.splitlines(): + line_parts = line.split() + if len(line_parts) > 4 and line_parts[0] == "editor": + res = line_parts + break + + self.assertIsNotNone(res, f"didn't find editor output in: {out}") + return res[1] + def setUp(self): super(type(self), self).setUp() @@ -1119,9 +1130,8 @@ class TestShellOpts(TestCephFSShell): # ==================================================================================================== # editor ? Program used by 'edit' self.editor_val = self.get_cephfs_shell_cmd_output( - 'set editor ?, set editor').split('\n')[4] - self.editor_val = self.editor_val.split()[1].strip(). \ - replace("'", "", 2) + 'set editor ?, set editor') + self.editor_val = self.extract_set_editor_output(self.editor_val) def write_tempconf(self, confcontents): self.tempconfpath = self.mount_a.client_remote.mktemp( @@ -1139,9 +1149,7 @@ class TestShellOpts(TestCephFSShell): # editor ??? Program used by 'edit' final_editor_val = self.get_cephfs_shell_cmd_output( cmd='set editor', shell_conf_path=self.tempconfpath) - final_editor_val = final_editor_val.split('\n')[2] - final_editor_val = final_editor_val.split()[1].strip(). \ - replace("'", "", 2) + final_editor_val = self.extract_set_editor_output(final_editor_val) self.assertNotEqual(self.editor_val, final_editor_val) @@ -1159,9 +1167,7 @@ class TestShellOpts(TestCephFSShell): # editor ? Program used by 'edit' final_editor_val = self.get_cephfs_shell_cmd_output( cmd='set editor', shell_conf_path=self.tempconfpath) - final_editor_val = final_editor_val.split('\n')[2] - final_editor_val = final_editor_val.split()[1].strip(). \ - replace("'", "", 2) + final_editor_val = self.extract_set_editor_output(final_editor_val) self.assertEqual(self.editor_val, final_editor_val) @@ -1177,8 +1183,6 @@ 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')[4] - final_editor_val = final_editor_val.split()[1].strip(). \ - replace("'", "", 2) + final_editor_val = self.extract_set_editor_output(final_editor_val) self.assertEqual(self.editor_val, final_editor_val)