From: Vallari Agrawal Date: Fri, 17 Jan 2025 05:15:34 +0000 (+0530) Subject: util/scanner.py: Don't throw error if unable to parse xml X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fheads%2Fwip-xmlscanner-fix;p=teuthology.git 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 --- 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