]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa: optionally check pattern string match in `health detail`
authorVenky Shankar <vshankar@redhat.com>
Tue, 24 Jan 2023 09:11:46 +0000 (04:11 -0500)
committerVenky Shankar <vshankar@redhat.com>
Thu, 30 Mar 2023 04:43:26 +0000 (10:13 +0530)
So that stricter checks can be enforced such as expecting
a certain client-id to be a part of health warnings.

Signed-off-by: Venky Shankar <vshankar@redhat.com>
(cherry picked from commit 527faaf8eebca7cec8e2e94746cc842f2348ae16)

qa/tasks/ceph_manager.py
qa/tasks/ceph_test_case.py

index 652d7d9ae3152b30dd3836f815aa1eef06618a8b..8c4d71ea383aedad30c5be299d618a88d7d9b3dd 100644 (file)
@@ -3160,11 +3160,14 @@ class CephManager:
                         raise
         self.log("quorum is size %d" % size)
 
-    def get_mon_health(self, debug=False):
+    def get_mon_health(self, debug=False, detail=False):
         """
         Extract all the monitor health information.
         """
-        out = self.raw_cluster_cmd('health', '--format=json')
+        if detail:
+            out = self.raw_cluster_cmd('health', 'detail', '--format=json')
+        else:
+            out = self.raw_cluster_cmd('health', '--format=json')
         if debug:
             self.log('health:\n{h}'.format(h=out))
         return json.loads(out)
index ad4834a6eb4ec3cdd723859ddb84fc4e4698c9d4..4070390fb5d204680e7288ef0c958891d60160e5 100644 (file)
@@ -140,12 +140,14 @@ class CephTestCase(unittest.TestCase):
 
         return ContextManager()
 
-    def wait_for_health(self, pattern, timeout):
+    def wait_for_health(self, pattern, timeout, check_in_detail=None):
         """
         Wait until 'ceph health' contains messages matching the pattern
+        Also check if @check_in_detail matches detailed health messages
+        only when @pattern is a code string.
         """
         def seen_health_warning():
-            health = self.ceph_cluster.mon_manager.get_mon_health()
+            health = self.ceph_cluster.mon_manager.get_mon_health(debug=False, detail=bool(check_in_detail))
             codes = [s for s in health['checks']]
             summary_strings = [s[1]['summary']['message'] for s in health['checks'].items()]
             if len(summary_strings) == 0:
@@ -156,7 +158,16 @@ class CephTestCase(unittest.TestCase):
                     if pattern in ss:
                          return True
                 if pattern in codes:
-                    return True
+                    if not check_in_detail:
+                        return True
+                    # check if the string is in detail list if asked
+                    detail_strings = [ss['message'] for ss in \
+                                      [s for s in health['checks'][pattern]['detail']]]
+                    log.debug(f'detail_strings: {detail_strings}')
+                    for ds in detail_strings:
+                        if check_in_detail in ds:
+                            return True
+                    log.debug(f'detail string "{check_in_detail}" not found')
 
             log.debug("Not found expected summary strings yet ({0})".format(summary_strings))
             return False