]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/cephfs: make code for generating health warnings reusable
authorRishabh Dave <ridave@redhat.com>
Wed, 8 May 2024 12:08:43 +0000 (17:38 +0530)
committerRishabh Dave <ridave@redhat.com>
Wed, 29 May 2024 12:01:15 +0000 (17:31 +0530)
Code to generate MDS_TRIM and MDS_CACHE_OVERSIZED health warnings is
repeated in test methods of TestMDSFail and TestFSFail. Move this code
to separate helper methods so that it can be reused instead of
duplicating it. And move these helper methods to TestAdminCommands so
to make them conveniently available for reuse.

Signed-off-by: Rishabh Dave <ridave@redhat.com>
qa/tasks/cephfs/test_admin.py

index 18d5ba01bf7d7b97d05ccff5d6198cb0b8061ea1..93ebe1a7c2bb794b36c171094822f55c731dc0ea 100644 (file)
@@ -122,6 +122,28 @@ class TestAdminCommands(CephFSTestCase):
                 if health_warn in health_report['checks']:
                     return
 
+    def gen_health_warn_mds_cache_oversized(self):
+        health_warn = 'MDS_CACHE_OVERSIZED'
+
+        self.config_set('mds', 'mds_cache_memory_limit', '1K')
+        self.config_set('mds', 'mds_health_cache_threshold', '1.00000')
+        self.mount_a.open_n_background('.', 400)
+
+        self.wait_till_health_warn(health_warn, active_mds_id)
+
+    def gen_health_warn_mds_trim(self):
+        health_warn = 'MDS_TRIM'
+
+        # for generating health warning MDS_TRIM
+        self.config_set('mds', 'mds_debug_subtrees', 'true')
+        # this will really really slow the trimming, so that MDS_TRIM stays
+        # for longer.
+        self.config_set('mds', 'mds_log_trim_decay_rate', '60')
+        self.config_set('mds', 'mds_log_trim_threshold', '1')
+        self.mount_a.open_n_background('.', 400)
+
+        self.wait_till_health_warn(health_warn, active_mds_id)
+
 
 @classhook('_add_valid_tell')
 class TestValidTell(TestAdminCommands):
@@ -2305,17 +2327,11 @@ class TestFSFail(TestAdminCommands):
         when confirmation flag is passed.
         '''
         health_warn = 'MDS_CACHE_OVERSIZED'
-        self.config_set('mds', 'mds_cache_memory_limit', '1K')
-        self.config_set('mds', 'mds_health_cache_threshold', '1.00000')
-        active_mds_id = self.fs.get_active_names()[0]
-
-        self.mount_a.open_n_background('.', 400)
-        self.wait_till_health_warn(health_warn, active_mds_id)
+        self.gen_health_warn_mds_cache_oversized()
 
         # actual testing begins now.
-        errmsg = 'mds_cache_oversized'
         self.negtest_ceph_cmd(args=f'fs fail {self.fs.name}',
-                              retval=1, errmsgs=errmsg)
+                              retval=1, errmsgs=health_warn)
         self.run_ceph_cmd(f'fs fail {self.fs.name} --yes-i-really-mean-it')
 
         # Bring and wait for MDS to be up since it is needed for unmounting
@@ -2330,21 +2346,11 @@ class TestFSFail(TestAdminCommands):
         confirmation flag is passed.
         '''
         health_warn = 'MDS_TRIM'
-        # for generating health warning MDS_TRIM
-        self.config_set('mds', 'mds_debug_subtrees', 'true')
-        # this will really really slow the trimming, so that MDS_TRIM stays
-        # for longer.
-        self.config_set('mds', 'mds_log_trim_decay_rate', '60')
-        self.config_set('mds', 'mds_log_trim_threshold', '1')
-        active_mds_id = self.fs.get_active_names()[0]
-
-        self.mount_a.open_n_background('.', 400)
-        self.wait_till_health_warn(health_warn, active_mds_id)
+        self.gen_health_warn_mds_trim()
 
         # actual testing begins now.
-        errmsg = 'mds_trim'
         self.negtest_ceph_cmd(args=f'fs fail {self.fs.name}',
-                              retval=1, errmsgs=errmsg)
+                              retval=1, errmsgs=health_warn)
         self.run_ceph_cmd(f'fs fail {self.fs.name} --yes-i-really-mean-it')
 
         # Bring and wait for MDS to be up since it is needed for unmounting
@@ -2361,19 +2367,11 @@ class TestFSFail(TestAdminCommands):
         '''
         health_warn = 'MDS_CACHE_OVERSIZED'
         self.fs.set_max_mds(2)
-        self.config_set('mds', 'mds_cache_memory_limit', '1K')
-        self.config_set('mds', 'mds_health_cache_threshold', '1.00000')
-        self.fs.wait_for_daemons()
-        mds1_id, mds2_id = self.fs.get_active_names()
-
-        self.mount_a.open_n_background('.', 400)
-        # MDS ID for which health warning has been generated.
-        self.wait_till_health_warn(health_warn, mds1_id)
+        self.gen_health_warn_mds_cache_oversized()
 
         # actual testing begins now.
-        errmsg = 'mds_cache_oversized'
         self.negtest_ceph_cmd(args=f'fs fail {self.fs.name}',
-                              retval=1, errmsgs=errmsg)
+                              retval=1, errmsgs=health_warn)
         self.run_ceph_cmd(f'fs fail {self.fs.name} --yes-i-really-mean-it')
 
         # Bring and wait for MDS to be up since it is needed for unmounting
@@ -2394,17 +2392,12 @@ class TestMDSFail(TestAdminCommands):
         passes when confirmation flag is passed.
         '''
         health_warn = 'MDS_CACHE_OVERSIZED'
-        self.config_set('mds', 'mds_cache_memory_limit', '1K')
-        self.config_set('mds', 'mds_health_cache_threshold', '1.00000')
-        active_mds_id = self.fs.get_active_names()[0]
-
-        self.mount_a.open_n_background('.', 400)
-        self.wait_till_health_warn(health_warn, active_mds_id)
+        self.gen_health_warn_mds_cache_oversized()
 
         # actual testing begins now.
-        errmsg = 'mds_cache_oversized'
+        active_mds_id = self.fs.get_active_names()[0]
         self.negtest_ceph_cmd(args=f'mds fail {active_mds_id}',
-                              retval=1, errmsgs=errmsg)
+                              retval=1, errmsgs=health_warn)
         self.run_ceph_cmd(f'mds fail {active_mds_id} --yes-i-really-mean-it')
 
     def test_with_health_warn_trim(self):
@@ -2414,21 +2407,12 @@ class TestMDSFail(TestAdminCommands):
         confirmation is passed.
         '''
         health_warn = 'MDS_TRIM'
-        # for generating health warning MDS_TRIM
-        self.config_set('mds', 'mds_debug_subtrees', 'true')
-        # this will really really slow the trimming, so that MDS_TRIM stays
-        # for longer.
-        self.config_set('mds', 'mds_log_trim_decay_rate', '60')
-        self.config_set('mds', 'mds_log_trim_threshold', '1')
-        active_mds_id = self.fs.get_active_names()[0]
-
-        self.mount_a.open_n_background('.', 400)
-        self.wait_till_health_warn(health_warn, active_mds_id)
+        self.gen_health_warn_mds_trim()
 
         # actual testing begins now...
-        errmsg = 'mds_trim'
+        active_mds_id = self.fs.get_active_names()[0]
         self.negtest_ceph_cmd(args=f'mds fail {active_mds_id}',
-                              retval=1, errmsgs=errmsg)
+                              retval=1, errmsgs=health_warn)
         self.run_ceph_cmd(f'mds fail {active_mds_id} --yes-i-really-mean-it')
 
     def test_with_health_warn_with_2_active_MDSs(self):
@@ -2440,14 +2424,9 @@ class TestMDSFail(TestAdminCommands):
         '''
         health_warn = 'MDS_CACHE_OVERSIZED'
         self.fs.set_max_mds(2)
-        self.config_set('mds', 'mds_cache_memory_limit', '1K')
-        self.config_set('mds', 'mds_health_cache_threshold', '1.00000')
-        self.fs.wait_for_daemons()
+        self.gen_health_warn_mds_cache_oversized()
         mds1_id, mds2_id = self.fs.get_active_names()
 
-        self.mount_a.open_n_background('.', 400)
-        self.wait_till_health_warn(health_warn, mds1_id)
-
         health_report = json.loads(self.get_ceph_cmd_stdout('health detail '
                                                             '--format json'))
         # MDS ID for which health warning has been generated.
@@ -2462,10 +2441,9 @@ class TestMDSFail(TestAdminCommands):
                                'than these two. This is definitely an error.')
 
         # actual testing begins now...
-        errmsg = 'mds_cache_oversized'
         self.negtest_ceph_cmd(args=f'mds fail {non_hw_mds_id}', retval=1,
-                              errmsgs=errmsg)
+                              errmsgs=health_warn)
         self.negtest_ceph_cmd(args=f'mds fail {hw_mds_id}', retval=1,
-                              errmsgs=errmsg)
+                              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')