]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
qa/cephfs: add tests for confirmationn required to change max_mds
authorRishabh Dave <ridave@redhat.com>
Tue, 27 Aug 2024 07:34:35 +0000 (13:04 +0530)
committerRishabh Dave <ridave@redhat.com>
Tue, 17 Jun 2025 07:50:33 +0000 (13:20 +0530)
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 <ridave@redhat.com>
(cherry picked from commit 4d5ec87ab404c2b94aab6865061175eb5870fa33)

Conflicts:
qa/tasks/cephfs/test_admin.py
- This file is bit different than main branch version which led to
  conflict in applying the patch in this commit.

qa/tasks/cephfs/filesystem.py
qa/tasks/cephfs/test_admin.py

index 7d81a7ae11ca992f2b85f7be76e65e302b55595a..9b17c48350159c90c3bebbba8e7d04dc166de86f 100644 (file)
@@ -631,8 +631,11 @@ class FilesystemBase(MDSClusterBase):
     def set_joinable(self, joinable=True):
         self.set_var("joinable", joinable)
 
-    def set_max_mds(self, max_mds):
-        self.set_var("max_mds", "%d" % max_mds)
+    def set_max_mds(self, max_mds, confirm=True):
+        if confirm:
+            self.set_var('max_mds', f'{max_mds}', '--yes-i-really-mean-it')
+        else:
+            self.set_var("max_mds", f"{max_mds}",)
 
     def set_session_timeout(self, timeout):
         self.set_var("session_timeout", "%d" % timeout)
index 5ffc6f281694fed307fc8760a845cc5f7d6fa791..ea27eafc3c268dd0635d71917ff2b78cf41dad21 100644 (file)
@@ -2595,6 +2595,63 @@ class TestMDSFail(TestAdminCommands):
         self.run_ceph_cmd(f'mds fail {mds2_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.