Skip to content

Commit 4d5ec87

Browse files
qa/cephfs: add tests for confirmationn required to change max_mds
Add tests to ensure that when cluster has any health warning, especially MDS_TRIM, confirmation flag is mandatory to change max_mds. Signed-off-by: Rishabh Dave <[email protected]>
1 parent a55a75c commit 4d5ec87

File tree

2 files changed

+62
-2
lines changed

2 files changed

+62
-2
lines changed

qa/tasks/cephfs/filesystem.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -640,8 +640,11 @@ def set_down(self, down=True):
640640
def set_joinable(self, joinable=True):
641641
self.set_var("joinable", joinable)
642642

643-
def set_max_mds(self, max_mds):
644-
self.set_var("max_mds", "%d" % max_mds)
643+
def set_max_mds(self, max_mds, confirm=True):
644+
if confirm:
645+
self.set_var('max_mds', f'{max_mds}', '--yes-i-really-mean-it')
646+
else:
647+
self.set_var("max_mds", f"{max_mds}",)
645648

646649
def set_session_timeout(self, timeout):
647650
self.set_var("session_timeout", "%d" % timeout)

qa/tasks/cephfs/test_admin.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2659,3 +2659,60 @@ def test_with_health_warn_with_2_active_MDSs(self):
26592659
errmsgs=health_warn)
26602660
self.run_ceph_cmd(f'mds fail {mds1_id} --yes-i-really-mean-it')
26612661
self.run_ceph_cmd(f'mds fail {mds2_id} --yes-i-really-mean-it')
2662+
2663+
2664+
class TestFSSetMaxMDS(TestAdminCommands):
2665+
2666+
def test_when_unhealthy_without_confirm(self):
2667+
'''
2668+
Test that command "ceph fs set <fsname> max_mds <num>" without the
2669+
confirmation flag (--yes-i-really-mean-it) fails when cluster is
2670+
unhealthy.
2671+
'''
2672+
self.gen_health_warn_mds_cache_oversized()
2673+
2674+
with self.assertRaises(CommandFailedError) as cfe:
2675+
self.fs.set_max_mds(2, confirm=False)
2676+
self.assertEqual(cfe.exception.exitstatus, errno.EPERM)
2677+
2678+
def test_when_unhealthy_with_confirm(self):
2679+
'''
2680+
Test that command "ceph fs set <fsname> max_mds <num>
2681+
--yes-i-really-mean-it" runs successfully when cluster is unhealthy.
2682+
'''
2683+
self.gen_health_warn_mds_cache_oversized()
2684+
2685+
self.fs.set_max_mds(2, confirm=True)
2686+
self.assertEqual(self.fs.get_var('max_mds'), 2)
2687+
2688+
def test_when_mds_trim_without_confirm(self):
2689+
'''
2690+
Test that command "ceph fs set <fsname> max_mds <num>" without the
2691+
confirmation flag (--yes-i-really-mean-it) fails when cluster has
2692+
MDS_TRIM health warning.
2693+
'''
2694+
self.gen_health_warn_mds_trim()
2695+
2696+
with self.assertRaises(CommandFailedError) as cfe:
2697+
self.fs.set_max_mds(2, confirm=False)
2698+
self.assertEqual(cfe.exception.exitstatus, errno.EPERM)
2699+
2700+
def test_when_mds_trim_when_with_confirm(self):
2701+
'''
2702+
Test that command "ceph fs set <fsname> max_mds <num>
2703+
--yes-i-really-mean-it" runs successfully when cluster has MDS_TRIM
2704+
health warning.
2705+
'''
2706+
self.gen_health_warn_mds_trim()
2707+
2708+
self.fs.set_max_mds(2, confirm=True)
2709+
self.assertEqual(self.fs.get_var('max_mds'), 2)
2710+
2711+
def test_when_healthy_with_confirm(self):
2712+
'''
2713+
Test that command "ceph fs set <fsname> max_mds <num>
2714+
--yes-i-really-mean-it" runs successfully also when cluster is
2715+
healthy.
2716+
'''
2717+
self.fs.set_max_mds(2, confirm=True)
2718+
self.assertEqual(self.fs.get_var('max_mds'), 2)

0 commit comments

Comments
 (0)