]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
util/scanner.py: Don't throw error if unable to parse xml wip-xmlscanner-fix
authorVallari Agrawal <val.agl002@gmail.com>
Fri, 17 Jan 2025 05:15:34 +0000 (10:45 +0530)
committerVallari Agrawal <val.agl002@gmail.com>
Fri, 17 Jan 2025 05:15:34 +0000 (10:45 +0530)
If xml files are faulty, don't fail tests.

Fixes: https://tracker.ceph.com/issues/67420
Signed-off-by: Vallari Agrawal <val.agl002@gmail.com>
teuthology/util/scanner.py

index 421d5a028b0719899d5415ed3a18e69a65edda41..f660ffc8deefa7eaf6834eb6ee11a6308f9702a9 100644 (file)
@@ -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