+ groups = re.search(
+ re.compile(r'((vpp|dpdk)-\dn-(skx|clx|hsw|tsh|dnv)-.*)'),
+ 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 {test_set_short}. "
+ f"See CSIT build {alert[u'urls'][idx]}/{build_nr} for more "
+ f"information.\n"
+ )
+ continue
+ text += (
+ 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():
+ """Class to store the max lengths of strings displayed in
+ failed tests list.
+ """
+ def __init__(self, tst_name, nics, framesizes, cores):
+ """Initialisation.
+
+ :param tst_name: Name of the test.
+ :param nics: NICs used in the test.
+ :param framesizes: Frame sizes used in the tests
+ :param cores: Cores used in th test.
+ """
+ self.name = tst_name
+ self.nics = nics
+ self.frmsizes = framesizes
+ self.cores = cores
+
+ max_len = MaxLens(0, 0, 0, 0)
+
+ for name, params in failed_tests.items():
+ failed_tests[name][u"nics"] = u",".join(sorted(params[u"nics"]))
+ failed_tests[name][u"framesizes"] = \
+ u",".join(sorted(params[u"framesizes"]))
+ failed_tests[name][u"cores"] = \
+ u",".join(sorted(params[u"cores"]))
+ if len(name) > max_len.name:
+ max_len.name = len(name)
+ if len(failed_tests[name][u"nics"]) > max_len.nics:
+ max_len.nics = len(failed_tests[name][u"nics"])
+ if len(failed_tests[name][u"framesizes"]) > max_len.frmsizes:
+ max_len.frmsizes = len(failed_tests[name][u"framesizes"])
+ if len(failed_tests[name][u"cores"]) > max_len.cores:
+ max_len.cores = len(failed_tests[name][u"cores"])
+
+ for name, params in failed_tests.items():
+ text += (
+ f"{name + u' ' * (max_len.name - len(name))} "
+ f"{params[u'nics']}"
+ f"{u' ' * (max_len.nics - len(params[u'nics']))} "
+ f"{params[u'framesizes']}"
+ f"{u' ' * (max_len.frmsizes-len(params[u'framesizes']))} "
+ f"{params[u'cores']}"
+ f"{u' ' * (max_len.cores - len(params[u'cores']))}\n"
+ )
+
+ gression_hdr = (
+ f"\n\n{test_set_short}, "
+ f"CSIT build: {alert[u'urls'][idx]}/{build}, "
+ f"{device} version: {version}\n\n"
+ )
+ # Add list of regressions:
+ self._list_gressions(alert, idx, gression_hdr, u"regressions")
+
+ # Add list of progressions:
+ self._list_gressions(alert, idx, gression_hdr, u"progressions")
+
+ text += f"\nFor detailed information visit: {alert[u'url-details']}\n"
+ file_name = f"{self.configs[alert[u'way']][u'output-dir']}/" \
+ f"{self.configs[alert[u'way']][u'output-file']}"
+ logging.info(f"Writing the file {file_name}.txt ...")
+
+ try:
+ with open(f"{file_name}.txt", u'w') as txt_file:
+ txt_file.write(text)
+ except IOError:
+ logging.error(f"Not possible to write the file {file_name}.txt.")