Trending: Add 3n-alt - fixes
[csit.git] / resources / tools / presentation / generator_alerts.py
index 9a0a03a..3c5c6f9 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (c) 2021 Cisco and/or its affiliates.
+# Copyright (c) 2022 Cisco and/or its affiliates.
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 # You may obtain a copy of the License at:
@@ -279,6 +279,38 @@ class Alerting:
                         line, error_msg = line[:-1].split(u'###', maxsplit=1)
                         test = line.split(u'-')
                         name = u'-'.join(test[3:-1])
+                        if len(error_msg) > 128:
+                            if u";" in error_msg[128:256]:
+                                error_msg = \
+                                    f"{error_msg[:128]}" \
+                                    f"{error_msg[128:].split(u';', 1)[0]}..."
+                            elif u":" in error_msg[128:256]:
+                                error_msg = \
+                                    f"{error_msg[:128]}" \
+                                    f"{error_msg[128:].split(u':', 1)[0]}..."
+                            elif u"." in error_msg[128:256]:
+                                error_msg = \
+                                    f"{error_msg[:128]}" \
+                                    f"{error_msg[128:].split(u'.', 1)[0]}..."
+                            elif u"?" in error_msg[128:256]:
+                                error_msg = \
+                                    f"{error_msg[:128]}" \
+                                    f"{error_msg[128:].split(u'?', 1)[0]}..."
+                            elif u"!" in error_msg[128:256]:
+                                error_msg = \
+                                    f"{error_msg[:128]}" \
+                                    f"{error_msg[128:].split(u'!', 1)[0]}..."
+                            elif u"," in error_msg[128:256]:
+                                error_msg = \
+                                    f"{error_msg[:128]}" \
+                                    f"{error_msg[128:].split(u',', 1)[0]}..."
+                            elif u" " in error_msg[128:256]:
+                                error_msg = \
+                                    f"{error_msg[:128]}" \
+                                    f"{error_msg[128:].split(u' ', 1)[0]}..."
+                            else:
+                                error_msg = error_msg[:128]
+
                     except ValueError:
                         continue
 
@@ -331,7 +363,7 @@ class Alerting:
         :param idx: Index of the test set as it is specified in the
             specification file.
         :param header: The header of the list of [re|pro]gressions.
-        :param re_pro: 'regression' or 'progression'.
+        :param re_pro: 'regressions' or 'progressions'.
         :type alert: dict
         :type idx: int
         :type header: str
@@ -375,13 +407,37 @@ class Alerting:
             )
 
         text = u""
+
+        legend = (f"Legend: Test-name  NIC  Frame-size  Trend[Mpps]  Runs[#]  "
+                  f"Long-Term change[%]")
+
+        out_file = (
+            f"{self.configs[alert[u'way']][u'output-dir']}/"
+            f"trending-regressions.txt"
+        )
+        try:
+            with open(out_file, u'w') as reg_file:
+                reg_file.write(legend)
+        except IOError:
+            logging.error(f"Not possible to write the file {out_file}.txt.")
+
+        out_file = (
+            f"{self.configs[alert[u'way']][u'output-dir']}/"
+            f"trending-progressions.txt"
+        )
+        try:
+            with open(out_file, u'w') as reg_file:
+                reg_file.write(legend)
+        except IOError:
+            logging.error(f"Not possible to write the file {out_file}.txt.")
+
         for idx, test_set in enumerate(alert.get(u"include", list())):
             test_set_short = u""
             device = u""
             try:
                 groups = re.search(
                     re.compile(
-                        r'((vpp|dpdk)-\dn-(skx|clx|tsh|dnv|zn2|tx2)-.*)'
+                        r'((vpp|dpdk)-\dn-(skx|clx|tsh|dnv|zn2|tx2|icx|alt)-.*)'
                     ),
                     test_set
                 )