From: Venky Shankar Date: Tue, 24 Jan 2023 09:11:46 +0000 (-0500) Subject: qa: optionally check pattern string match in `health detail` X-Git-Tag: v18.2.4~434^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=101308ba34a3d350f4c00517ac59aa6bf669250c;p=ceph.git qa: optionally check pattern string match in `health detail` 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 (cherry picked from commit 527faaf8eebca7cec8e2e94746cc842f2348ae16) --- diff --git a/qa/tasks/ceph_manager.py b/qa/tasks/ceph_manager.py index 516c409e8a6c..135c40521c98 100644 --- a/qa/tasks/ceph_manager.py +++ b/qa/tasks/ceph_manager.py @@ -3152,11 +3152,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) diff --git a/qa/tasks/ceph_test_case.py b/qa/tasks/ceph_test_case.py index 3f8a152d75dd..3f355825c6f3 100644 --- a/qa/tasks/ceph_test_case.py +++ b/qa/tasks/ceph_test_case.py @@ -148,12 +148,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: @@ -164,7 +166,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