Trending: Add DPDK version to alerts
[csit.git] / resources / tools / presentation / input_data_parser.py
index fc64087..250032e 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'
@@ -524,8 +530,8 @@ class ExecutionChecker(ResultVisitor):
         """
 
         if msg.message.count(u"return STDOUT Version:") or \
-            msg.message.count(u"VPP Version:") or \
-            msg.message.count(u"VPP version:"):
+                msg.message.count(u"VPP Version:") or \
+                msg.message.count(u"VPP version:"):
             self._version = str(re.search(self.REGEX_VERSION_VPP, msg.message).
                                 group(2))
             self._data[u"metadata"][u"version"] = self._version
@@ -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
@@ -1194,9 +1232,6 @@ class ExecutionChecker(ResultVisitor):
                 test_kw.name.count(u"Show Runtime Counters On All Duts"):
             self._msg_type = u"test-show-runtime"
             self._sh_run_counter += 1
-        elif test_kw.name.count(u"Install Dpdk Test On All Duts") and \
-                not self._version:
-            self._msg_type = u"dpdk-version"
         else:
             return
         test_kw.messages.visit(self)
@@ -1233,6 +1268,9 @@ class ExecutionChecker(ResultVisitor):
         if setup_kw.name.count(u"Show Vpp Version On All Duts") \
                 and not self._version:
             self._msg_type = u"vpp-version"
+        elif setup_kw.name.count(u"Install Dpdk Framework On All Duts") and \
+                not self._version:
+            self._msg_type = u"dpdk-version"
         elif setup_kw.name.count(u"Set Global Variable") \
                 and not self._timestamp:
             self._msg_type = u"timestamp"