X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=resources%2Ftools%2Fpresentation%2Fgenerator_alerts.py;h=a71b775485703b8d17186cdbfaf0e957465f88ab;hb=ec79cd31fd974372fd6cd02be6a504dff6d50e8e;hp=10c6734aad5eadc198db68a000a5b20e3e2bc5fa;hpb=cbfa26dc0f5334bcd367c161b4eaad342355bbde;p=csit.git diff --git a/resources/tools/presentation/generator_alerts.py b/resources/tools/presentation/generator_alerts.py index 10c6734aad..a71b775485 100644 --- a/resources/tools/presentation/generator_alerts.py +++ b/resources/tools/presentation/generator_alerts.py @@ -1,4 +1,4 @@ -# Copyright (c) 2019 Cisco and/or its affiliates. +# Copyright (c) 2021 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: @@ -20,13 +20,13 @@ import smtplib import logging +import re from email.mime.text import MIMEText from email.mime.multipart import MIMEMultipart from os.path import isdir from collections import OrderedDict -from pal_utils import get_last_completed_build_number from pal_errors import PresentationError @@ -314,7 +314,7 @@ class Alerting: in_file = ( f"{self.configs[alert[u'way']][u'output-dir']}/" - f"cpta-{re_pro}-{alert[u'urls'][idx].split(u'/')[-1]}.txt" + f"{re_pro}-{alert[u'urls'][idx].split(u'/')[-1]}.txt" ) out_file = ( f"{self.configs[alert[u'way']][u'output-dir']}/" @@ -346,26 +346,36 @@ class Alerting: ) text = u"" - for idx, test_set in enumerate(alert.get(u"include", [])): + 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|hsw|tsh|dnv|zn2|tx2)-.*)' + ), + test_set + ) + test_set_short = groups.group(1) + device = groups.group(2) + except (AttributeError, IndexError): + logging.error( + f"The test set {test_set} does not include information " + f"about test bed. Using empty string instead." + ) build, version, passed, failed, failed_tests = \ self._get_compressed_failed_tests(alert, test_set) if build is None: - ret_code, build_nr, _ = get_last_completed_build_number( - self._spec.environment[u"urls"][u"URL[JENKINS,CSIT]"], - alert[u"urls"][idx].split(u'/')[-1]) - if ret_code != 0: - build_nr = u'' text += ( - f"\n\nNo input data available for " - f"{u'-'.join(test_set.split('-')[-2:])}. See CSIT build " - f"{alert[u'urls'][idx]}/{build_nr} for more information.\n" + f"\n\nNo input data available for {test_set_short}. " + f"See CSIT job {alert[u'urls'][idx]} for more " + f"information.\n" ) continue text += ( - f"\n\n{test_set.split('-')[-2]}-{test_set.split('-')[-1]}, " - f"{failed} tests failed, " - f"{passed} tests passed, CSIT build: " - f"{alert[u'urls'][idx]}/{build}, VPP version: {version}\n\n" + f"\n\n{test_set_short}, {failed} tests failed, {passed} tests " + f"passed, CSIT build: {alert[u'urls'][idx]}/{build}, " + f"{device} version: {version}\n\n" ) class MaxLens(): @@ -414,9 +424,9 @@ class Alerting: ) gression_hdr = ( - f"\n\n{test_set.split(u'-')[-2]}-{test_set.split(u'-')[-1]}, " + f"\n\n{test_set_short}, " f"CSIT build: {alert[u'urls'][idx]}/{build}, " - f"VPP version: {version}\n\n" + f"{device} version: {version}\n\n" ) # Add list of regressions: self._list_gressions(alert, idx, gression_hdr, u"regressions")