'''
health_warn = 'MDS_CACHE_OVERSIZED'
self.fs.set_max_mds(2)
- self.gen_health_warn_mds_cache_oversized()
- mds1_id, mds2_id = self.fs.get_active_names()
+
+ self.mount_a.run_shell_payload("mkdir dir1")
+ self.mount_a.setfattr("dir1", "ceph.dir.pin", "0")
+ self._wait_subtrees([('/dir1', 0)], rank=0)
+
+ mds0_id, mds1_id = self.fs.get_active_names()
+ self.gen_health_warn_mds_cache_oversized(mds_id=mds0_id, path="dir1")
# MDS ID for which health warning has been generated.
- 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:
- non_hw_mds_id = mds1_id
- else:
- raise RuntimeError('There are only 2 MDSs right now but apparently'
- 'health warning was raised for an MDS other '
- 'than these two. This is definitely an error.')
+ count, hw_mds_id = self._get_unhealthy_mds_id(health_warn)
+ # Validate the warning is raised on only one mds
+ self.assertEqual(count, 1)
+ self.assertEqual(hw_mds_id, mds0_id)
# actual testing begins now...
- self.negtest_ceph_cmd(args=f'mds fail {non_hw_mds_id}', retval=1,
- errmsgs=health_warn)
- self.negtest_ceph_cmd(args=f'mds fail {hw_mds_id}', retval=1,
+ self.negtest_ceph_cmd(args=f'mds fail {mds0_id}', retval=1,
errmsgs=health_warn)
- self.run_ceph_cmd(f'mds fail {mds1_id} --yes-i-really-mean-it')
- self.run_ceph_cmd(f'mds fail {mds2_id} --yes-i-really-mean-it')
+ self.run_ceph_cmd(f'mds fail {mds1_id}')
+ self.run_ceph_cmd(f'mds fail {mds0_id} --yes-i-really-mean-it')
+ class TestFSSetMaxMDS(TestAdminCommands):
+
+ def test_when_unhealthy_without_confirm(self):
+ '''
+ Test that command "ceph fs set <fsname> max_mds <num>" without the
+ confirmation flag (--yes-i-really-mean-it) fails when cluster is
+ unhealthy.
+ '''
+ self.gen_health_warn_mds_cache_oversized()
+
+ with self.assertRaises(CommandFailedError) as cfe:
+ self.fs.set_max_mds(2, confirm=False)
+ self.assertEqual(cfe.exception.exitstatus, errno.EPERM)
+
+ def test_when_unhealthy_with_confirm(self):
+ '''
+ Test that command "ceph fs set <fsname> max_mds <num>
+ --yes-i-really-mean-it" runs successfully when cluster is unhealthy.
+ '''
+ self.gen_health_warn_mds_cache_oversized()
+
+ self.fs.set_max_mds(2, confirm=True)
+ self.assertEqual(self.fs.get_var('max_mds'), 2)
+
+ def test_when_mds_trim_without_confirm(self):
+ '''
+ Test that command "ceph fs set <fsname> max_mds <num>" without the
+ confirmation flag (--yes-i-really-mean-it) fails when cluster has
+ MDS_TRIM health warning.
+ '''
+ self.gen_health_warn_mds_trim()
+
+ with self.assertRaises(CommandFailedError) as cfe:
+ self.fs.set_max_mds(2, confirm=False)
+ self.assertEqual(cfe.exception.exitstatus, errno.EPERM)
+
+ def test_when_mds_trim_when_with_confirm(self):
+ '''
+ Test that command "ceph fs set <fsname> max_mds <num>
+ --yes-i-really-mean-it" runs successfully when cluster has MDS_TRIM
+ health warning.
+ '''
+ self.gen_health_warn_mds_trim()
+
+ self.fs.set_max_mds(2, confirm=True)
+ self.assertEqual(self.fs.get_var('max_mds'), 2)
+
+ def test_when_healthy_with_confirm(self):
+ '''
+ Test that command "ceph fs set <fsname> max_mds <num>
+ --yes-i-really-mean-it" runs successfully also when cluster is
+ healthy.
+ '''
+ self.fs.set_max_mds(2, confirm=True)
+ self.assertEqual(self.fs.get_var('max_mds'), 2)
+
+
class TestToggleVolumes(CephFSTestCase):
'''
Contains code for enabling/disabling mgr/volumes plugin.