]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/cephfs: improve and move _get_unhealthy_mds_name to TestMDSFail
authorRishabh Dave <ridave@redhat.com>
Wed, 8 May 2024 13:09:35 +0000 (18:39 +0530)
committerRishabh Dave <ridave@redhat.com>
Fri, 12 Jul 2024 14:56:54 +0000 (20:26 +0530)
1. Instead of accepting health report as argument, get one directly.
2. Since it is not being used elsewhere move it to the class where it is
   being used.

Signed-off-by: Rishabh Dave <ridave@redhat.com>
(cherry picked from commit b1918686a383e47d51ae0115c8d79ef250ddd0ec)

qa/tasks/cephfs/test_admin.py

index 2e96352a84eb4e1a488f2b9630aa0f2fc31bcc9c..09906c36dbd8b6d0512714660f103593fb15b548 100644 (file)
@@ -90,19 +90,6 @@ class TestAdminCommands(CephFSTestCase):
         if overwrites:
             self.run_ceph_cmd('osd', 'pool', 'set', n+"-data", 'allow_ec_overwrites', 'true')
 
-    def _get_unhealthy_mds_id(self, health_report, health_warn):
-        '''
-        Return MDS ID for which health warning in "health_warn" has been
-        generated.
-        '''
-        # variable "msg" should hold string something like this -
-        # 'mds.b(mds.0): Behind on trimming (865/10) max_segments: 10,
-        # num_segments: 86
-        msg = health_report['checks'][health_warn]['detail'][0]['message']
-        mds_id = msg.split('(')[0]
-        mds_id = mds_id.replace('mds.', '')
-        return mds_id
-
     def gen_health_warn_mds_cache_oversized(self):
         health_warn = 'MDS_CACHE_OVERSIZED'
 
@@ -1851,6 +1838,21 @@ class TestMDSFail(TestAdminCommands):
                               retval=1, errmsgs=health_warn)
         self.run_ceph_cmd(f'mds fail {active_mds_id} --yes-i-really-mean-it')
 
+    def _get_unhealthy_mds_id(self, health_warn):
+        '''
+        Return MDS ID for which health warning in "health_warn" has been
+        generated.
+        '''
+        health_report = json.loads(self.get_ceph_cmd_stdout('health detail '
+                                                            '--format json'))
+        # variable "msg" should hold string something like this -
+        # 'mds.b(mds.0): Behind on trimming (865/10) max_segments: 10,
+        # num_segments: 86
+        msg = health_report['checks'][health_warn]['detail'][0]['message']
+        mds_id = msg.split('(')[0]
+        mds_id = mds_id.replace('mds.', '')
+        return mds_id
+
     def test_with_health_warn_with_2_active_MDSs(self):
         '''
         Test when a CephFS has 2 active MDSs and one of them have either
@@ -1863,10 +1865,8 @@ class TestMDSFail(TestAdminCommands):
         self.gen_health_warn_mds_cache_oversized()
         mds1_id, mds2_id = self.fs.get_active_names()
 
-        health_report = json.loads(self.get_ceph_cmd_stdout('health detail '
-                                                            '--format json'))
         # MDS ID for which health warning has been generated.
-        hw_mds_id = self._get_unhealthy_mds_id(health_report, health_warn)
+        hw_mds_id = self._get_unhealthy_mds_id(health_warn)
         if mds1_id == hw_mds_id:
             non_hw_mds_id = mds2_id
         elif mds2_id == hw_mds_id: