PAL: Add processing of throughput in Gbps
[csit.git] / resources / tools / presentation / input_data_parser.py
index 27db6a8..0a6efc7 100644 (file)
@@ -216,6 +216,12 @@ class ExecutionChecker(ResultVisitor):
         r'PDR_LOWER:\s(\d+.\d+).*\n.*\n'
         r'PDR_UPPER:\s(\d+.\d+)'
     )
+    REGEX_NDRPDR_GBPS = re.compile(
+        r'NDR_LOWER:.*,\s(\d+.\d+).*\n.*\n'
+        r'NDR_UPPER:.*,\s(\d+.\d+).*\n'
+        r'PDR_LOWER:.*,\s(\d+.\d+).*\n.*\n'
+        r'PDR_UPPER:.*,\s(\d+.\d+)'
+    )
     REGEX_PERF_MSG_INFO = re.compile(
         r'NDR_LOWER:\s(\d+.\d+)\s.*\s(\d+.\d+)\s.*\n.*\n.*\n'
         r'PDR_LOWER:\s(\d+.\d+)\s.*\s(\d+.\d+)\s.*\n.*\n.*\n'
@@ -713,6 +719,35 @@ class ExecutionChecker(ResultVisitor):
 
         return throughput, status
 
+    def _get_ndrpdr_throughput_gbps(self, msg):
+        """Get NDR_LOWER, NDR_UPPER, PDR_LOWER and PDR_UPPER in Gbps from the
+        test message.
+
+        :param msg: The test message to be parsed.
+        :type msg: str
+        :returns: Parsed data as a dict and the status (PASS/FAIL).
+        :rtype: tuple(dict, str)
+        """
+
+        gbps = {
+            u"NDR": {u"LOWER": -1.0, u"UPPER": -1.0},
+            u"PDR": {u"LOWER": -1.0, u"UPPER": -1.0}
+        }
+        status = u"FAIL"
+        groups = re.search(self.REGEX_NDRPDR_GBPS, msg)
+
+        if groups is not None:
+            try:
+                gbps[u"NDR"][u"LOWER"] = float(groups.group(1))
+                gbps[u"NDR"][u"UPPER"] = float(groups.group(2))
+                gbps[u"PDR"][u"LOWER"] = float(groups.group(3))
+                gbps[u"PDR"][u"UPPER"] = float(groups.group(4))
+                status = u"PASS"
+            except (IndexError, ValueError):
+                pass
+
+        return gbps, status
+
     def _get_plr_throughput(self, msg):
         """Get PLRsearch lower bound and PLRsearch upper bound from the test
         message.
@@ -1071,6 +1106,8 @@ class ExecutionChecker(ResultVisitor):
                 test_result[u"type"] = u"NDRPDR"
                 test_result[u"throughput"], test_result[u"status"] = \
                     self._get_ndrpdr_throughput(test.message)
+                test_result[u"gbps"], test_result[u"status"] = \
+                    self._get_ndrpdr_throughput_gbps(test.message)
                 test_result[u"latency"], test_result[u"status"] = \
                     self._get_ndrpdr_latency(test.message)
             elif u"SOAK" in tags:
@@ -1095,8 +1132,9 @@ class ExecutionChecker(ResultVisitor):
                 groups = re.search(self.REGEX_BMRR, test.message)
                 if groups is not None:
                     items_str = groups.group(1)
-                    items_float = [float(item.strip()) for item
-                                   in items_str.split(",")]
+                    items_float = [
+                        float(item.strip()) for item in items_str.split(",")
+                    ]
                     # Use whole list in CSIT-1180.
                     stats = jumpavg.AvgStdevStats.for_runs(items_float)
                     test_result[u"result"][u"receive-rate"] = stats.avg
@@ -1454,17 +1492,17 @@ class InputData:
             do_repeat -= 1
         if not success:
             logging.error(
-                 f"It is not possible to download the input data file from the "
-                 f"job {job}, build {build[u'build']}, or it is damaged. "
-                 f"Skipped."
+                f"It is not possible to download the input data file from the "
+                f"job {job}, build {build[u'build']}, or it is damaged. "
+                f"Skipped."
             )
         if success:
             logging.info(f"    Processing data from build {build[u'build']}")
             data = self._parse_tests(job, build)
             if data is None:
                 logging.error(
-                     f"Input data file from the job {job}, build "
-                     f"{build[u'build']} is damaged. Skipped."
+                    f"Input data file from the job {job}, build "
+                    f"{build[u'build']} is damaged. Skipped."
                 )
             else:
                 state = u"processed"
@@ -1592,7 +1630,7 @@ class InputData:
         self._cfg.add_build(job, build)
 
         logging.info(f"Processing {job}: {build_nr:2d}: {local_file}")
-        data = self._parse_tests(job, build, list())
+        data = self._parse_tests(job, build)
         if data is None:
             raise PresentationError(
                 f"Error occurred while parsing the file {local_file}"