Report: Detailed results tables
[csit.git] / resources / tools / presentation / input_data_parser.py
index 73b9ea1..1ee5753 100644 (file)
@@ -220,6 +220,8 @@ class ExecutionChecker(ResultVisitor):
         r'Latency at 50% PDR:.*\[\'(.*)\', \'(.*)\'\].*\n'
         r'Latency at 10% PDR:.*\[\'(.*)\', \'(.*)\'\].*\n'
     )
+    REGEX_MRR_MSG_INFO = re.compile(r'.*\[(.*)\]')
+
     # TODO: Remove when not needed
     REGEX_NDRPDR_LAT_BASE = re.compile(
         r'LATENCY.*\[\'(.*)\', \'(.*)\'\]\s\n.*\n.*\n'
@@ -355,15 +357,34 @@ class ExecutionChecker(ResultVisitor):
         """
         return self._data
 
+    def _get_data_from_mrr_test_msg(self, msg):
+        """Get info from message of MRR performance tests.
+
+        :param msg: Message to be processed.
+        :type msg: str
+        :returns: Processed message or original message if a problem occurs.
+        :rtype: str
+        """
+
+        groups = re.search(self.REGEX_MRR_MSG_INFO, msg)
+        if not groups or groups.lastindex != 1:
+            return msg
+
+        try:
+            data = groups.group(1).split(u", ")
+        except (AttributeError, IndexError, ValueError, KeyError):
+            return msg
+
+        out_str = u"["
+        try:
+            for item in data:
+                out_str += f"{(float(item) / 1e6):.2f}, "
+            return out_str[:-2] + u"]"
+        except (AttributeError, IndexError, ValueError, KeyError):
+            return msg
+
     def _get_data_from_perf_test_msg(self, msg):
-        """Get
-            - NDR_LOWER
-            - LATENCY
-            - NDR_UPPER
-            - PDR_LOWER
-            - LATENCY
-            - PDR_UPPER
-        from message of NDRPDR performance tests.
+        """Get info from message of NDRPDR performance tests.
 
         :param msg: Message to be processed.
         :type msg: str
@@ -423,14 +444,19 @@ class ExecutionChecker(ResultVisitor):
                 return u""
 
             if hdr_lat_1 and hdr_lat_2:
-                return (
-                    f"{hdr_lat_1.get_value_at_percentile(50.0)} "
-                    f"{hdr_lat_1.get_value_at_percentile(90.0)} "
-                    f"{hdr_lat_1.get_value_at_percentile(99.0)} , "
-                    f"{hdr_lat_2.get_value_at_percentile(50.0)} "
-                    f"{hdr_lat_2.get_value_at_percentile(90.0)} "
-                    f"{hdr_lat_2.get_value_at_percentile(99.0)}"
-                )
+                hdr_lat_1_50 = hdr_lat_1.get_value_at_percentile(50.0)
+                hdr_lat_1_90 = hdr_lat_1.get_value_at_percentile(90.0)
+                hdr_lat_1_99 = hdr_lat_1.get_value_at_percentile(99.0)
+                hdr_lat_2_50 = hdr_lat_2.get_value_at_percentile(50.0)
+                hdr_lat_2_90 = hdr_lat_2.get_value_at_percentile(90.0)
+                hdr_lat_2_99 = hdr_lat_2.get_value_at_percentile(99.0)
+
+                if (hdr_lat_1_50 + hdr_lat_1_90 + hdr_lat_1_99 +
+                        hdr_lat_2_50 + hdr_lat_2_90 + hdr_lat_2_99):
+                    return (
+                        f"{hdr_lat_1_50} {hdr_lat_1_90} {hdr_lat_1_99}      "
+                        f"{hdr_lat_2_50} {hdr_lat_2_90} {hdr_lat_2_99}"
+                    )
 
             return u""
 
@@ -446,13 +472,13 @@ class ExecutionChecker(ResultVisitor):
             pdr_lat_90 = f"\n5. {pdr_lat_90}" if pdr_lat_90 else u""
 
             return (
-                u" |prein| "
-                f"1. {(data[u'ndr_low'] / 1e6):.2f} {data[u'ndr_low_b']:.2f}"
-                f"\n2. {(data[u'pdr_low'] / 1e6):.2f} {data[u'pdr_low_b']:.2f}"
+                f"1. {(data[u'ndr_low'] / 1e6):.2f}      "
+                f"{data[u'ndr_low_b']:.2f}"
+                f"\n2. {(data[u'pdr_low'] / 1e6):.2f}      "
+                f"{data[u'pdr_low_b']:.2f}"
                 f"{pdr_lat_10}"
                 f"{pdr_lat_50}"
                 f"{pdr_lat_90}"
-                u" |preout| "
             )
         except (AttributeError, IndexError, ValueError, KeyError):
             return msg
@@ -944,7 +970,7 @@ class ExecutionChecker(ResultVisitor):
             replace(u'\r', u'').\
             replace(u'[', u' |br| [').\
             replace(u' |br| [', u'[', 1)
-        test_result[u"msg"] = self._get_data_from_perf_test_msg(test.message).\
+        test_result[u"msg"] = test.message.\
             replace(u'\n', u' |br| ').\
             replace(u'\r', u'').\
             replace(u'"', u"'")
@@ -986,6 +1012,11 @@ class ExecutionChecker(ResultVisitor):
 
         if test.status == u"PASS":
             if u"NDRPDR" in tags:
+                test_result[u"msg"] = self._get_data_from_perf_test_msg(
+                    test.message). \
+                    replace(u'\n', u' |br| '). \
+                    replace(u'\r', u''). \
+                    replace(u'"', u"'")
                 test_result[u"type"] = u"NDRPDR"
                 test_result[u"throughput"], test_result[u"status"] = \
                     self._get_ndrpdr_throughput(test.message)
@@ -1000,6 +1031,11 @@ class ExecutionChecker(ResultVisitor):
                 groups = re.search(self.REGEX_TCP, test.message)
                 test_result[u"result"] = int(groups.group(2))
             elif u"MRR" in tags or u"FRMOBL" in tags or u"BMRR" in tags:
+                test_result[u"msg"] = self._get_data_from_mrr_test_msg(
+                    test.message). \
+                    replace(u'\n', u' |br| '). \
+                    replace(u'\r', u''). \
+                    replace(u'"', u"'")
                 if u"MRR" in tags:
                     test_result[u"type"] = u"MRR"
                 else:
@@ -1030,6 +1066,8 @@ class ExecutionChecker(ResultVisitor):
                     }
                 except (AttributeError, IndexError, ValueError, TypeError):
                     test_result[u"status"] = u"FAIL"
+            elif u"DEVICETEST" in tags:
+                test_result[u"type"] = u"DEVICETEST"
             else:
                 test_result[u"status"] = u"FAIL"
                 self._data[u"tests"][self._test_id] = test_result