From: Rishabh Dave Date: Wed, 8 May 2024 13:09:35 +0000 (+0530) Subject: qa/cephfs: improve and move _get_unhealthy_mds_name to TestMDSFail X-Git-Tag: v20.0.0~1549^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b1918686a383e47d51ae0115c8d79ef250ddd0ec;p=ceph.git qa/cephfs: improve and move _get_unhealthy_mds_name to TestMDSFail 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 --- diff --git a/qa/tasks/cephfs/test_admin.py b/qa/tasks/cephfs/test_admin.py index 2c2c6d03325..625e64af561 100644 --- a/qa/tasks/cephfs/test_admin.py +++ b/qa/tasks/cephfs/test_admin.py @@ -91,19 +91,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' @@ -2397,6 +2384,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 @@ -2409,10 +2411,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: