Skip to content

Commit b191868

Browse files
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 <[email protected]>
1 parent 5972caf commit b191868

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

qa/tasks/cephfs/test_admin.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -91,19 +91,6 @@ def setup_ec_pools(self, n, metadata=True, overwrites=True):
9191
if overwrites:
9292
self.run_ceph_cmd('osd', 'pool', 'set', n+"-data", 'allow_ec_overwrites', 'true')
9393

94-
def _get_unhealthy_mds_id(self, health_report, health_warn):
95-
'''
96-
Return MDS ID for which health warning in "health_warn" has been
97-
generated.
98-
'''
99-
# variable "msg" should hold string something like this -
100-
# 'mds.b(mds.0): Behind on trimming (865/10) max_segments: 10,
101-
# num_segments: 86
102-
msg = health_report['checks'][health_warn]['detail'][0]['message']
103-
mds_id = msg.split('(')[0]
104-
mds_id = mds_id.replace('mds.', '')
105-
return mds_id
106-
10794
def gen_health_warn_mds_cache_oversized(self):
10895
health_warn = 'MDS_CACHE_OVERSIZED'
10996

@@ -2397,6 +2384,21 @@ def test_with_health_warn_trim(self):
23972384
retval=1, errmsgs=health_warn)
23982385
self.run_ceph_cmd(f'mds fail {active_mds_id} --yes-i-really-mean-it')
23992386

2387+
def _get_unhealthy_mds_id(self, health_warn):
2388+
'''
2389+
Return MDS ID for which health warning in "health_warn" has been
2390+
generated.
2391+
'''
2392+
health_report = json.loads(self.get_ceph_cmd_stdout('health detail '
2393+
'--format json'))
2394+
# variable "msg" should hold string something like this -
2395+
# 'mds.b(mds.0): Behind on trimming (865/10) max_segments: 10,
2396+
# num_segments: 86
2397+
msg = health_report['checks'][health_warn]['detail'][0]['message']
2398+
mds_id = msg.split('(')[0]
2399+
mds_id = mds_id.replace('mds.', '')
2400+
return mds_id
2401+
24002402
def test_with_health_warn_with_2_active_MDSs(self):
24012403
'''
24022404
Test when a CephFS has 2 active MDSs and one of them have either
@@ -2409,10 +2411,8 @@ def test_with_health_warn_with_2_active_MDSs(self):
24092411
self.gen_health_warn_mds_cache_oversized()
24102412
mds1_id, mds2_id = self.fs.get_active_names()
24112413

2412-
health_report = json.loads(self.get_ceph_cmd_stdout('health detail '
2413-
'--format json'))
24142414
# MDS ID for which health warning has been generated.
2415-
hw_mds_id = self._get_unhealthy_mds_id(health_report, health_warn)
2415+
hw_mds_id = self._get_unhealthy_mds_id(health_warn)
24162416
if mds1_id == hw_mds_id:
24172417
non_hw_mds_id = mds2_id
24182418
elif mds2_id == hw_mds_id:

0 commit comments

Comments
 (0)