From 775193adda09a71ff074c3cb04284c4c22bcd436 Mon Sep 17 00:00:00 2001 From: Vallari Agrawal Date: Fri, 17 Jan 2025 10:45:34 +0530 Subject: [PATCH] util/scanner.py: Don't throw error if unable to parse xml If xml files are faulty, don't fail tests. Fixes: https://tracker.ceph.com/issues/67420 Signed-off-by: Vallari Agrawal --- teuthology/util/scanner.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/teuthology/util/scanner.py b/teuthology/util/scanner.py index 421d5a028b..f660ffc8de 100644 --- a/teuthology/util/scanner.py +++ b/teuthology/util/scanner.py @@ -74,8 +74,12 @@ class UnitTestScanner(Scanner): super().__init__(remote) def _parse(self, file_content: str) -> Tuple[Optional[str], Optional[dict]]: - xml_tree = etree.fromstring(file_content) - + try: + xml_tree = etree.fromstring(file_content) + except Exception as e: + log.debug(f"Unable to parse xml file: {e}") + return None, None + failed_testcases = xml_tree.xpath('.//failure/.. | .//error/..') if len(failed_testcases) == 0: return None, None @@ -129,7 +133,12 @@ class ValgrindScanner(Scanner): super().__init__(remote) def _parse(self, file_content: str) -> Tuple[Optional[str], Optional[dict]]: - xml_tree = etree.fromstring(file_content) + try: + xml_tree = etree.fromstring(file_content) + except Exception as e: + log.debug(f"Unable to parse xml file, {e}") + return None, None + if xml_tree is None: return None, None -- 2.39.5