X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=resources%2Ftools%2Fpresentation%2Fgenerator_cpta.py;h=1a2dbaa124b7b177551c378b3a6f245bbac1368d;hb=9720a9893945c67112de0dae7ad9f2931d7b37c8;hp=0320b9eec13259c2e81e8ed92b2d94f1f53eda89;hpb=a505b3d02cb3dcba44096859287ee2df4ce878ab;p=csit.git diff --git a/resources/tools/presentation/generator_cpta.py b/resources/tools/presentation/generator_cpta.py index 0320b9eec1..1a2dbaa124 100644 --- a/resources/tools/presentation/generator_cpta.py +++ b/resources/tools/presentation/generator_cpta.py @@ -13,7 +13,6 @@ """Generation of Continuous Performance Trending and Analysis. """ - import re import logging import csv @@ -21,6 +20,7 @@ import csv from collections import OrderedDict from datetime import datetime from copy import deepcopy +from os import listdir import prettytable import plotly.offline as ploff @@ -840,12 +840,39 @@ def _generate_all_charts(spec, input_data): if anomaly_classifications: result = u"PASS" for job_name, job_data in anomaly_classifications.items(): + data = [] + tb = u"-".join(job_name.split(u"-")[-2:]) + for file in listdir(f"{spec.cpta[u'output-file']}"): + if tb in file and u"performance-trending-dashboard" in \ + file and u"txt" in file: + file_to_read = f"{spec.cpta[u'output-file']}/{file}" + with open(f"{file_to_read}", u"rt") as input: + data = data + input.readlines() file_name = \ f"{spec.cpta[u'output-file']}/regressions-{job_name}.txt" with open(file_name, u'w') as txt_file: for test_name, classification in job_data.items(): if classification == u"regression": - txt_file.write(test_name + u'\n') + if u"2n" in test_name: + test_name = test_name.split("-", 2) + tst = test_name[2].split(".")[-1] + nic = test_name[1] + tst_name = f"{nic}-{tst}" + else: + test_name = test_name.split("-", 1) + tst = test_name[1].split(".")[-1] + nic = test_name[0].split(".")[-1] + tst_name = f"{nic}-{tst}" + + for line in data: + if tst_name in line: + line = line.replace(" ", "") + trend = line.split("|")[2] + number = line.split("|")[3] + ltc = line.split("|")[4] + txt_file.write(f"{tst_name} [ {trend}M | " + f"#{number} | {ltc}% ]\n") + if classification in (u"regression", u"outlier"): result = u"FAIL" file_name = \ @@ -853,7 +880,25 @@ def _generate_all_charts(spec, input_data): with open(file_name, u'w') as txt_file: for test_name, classification in job_data.items(): if classification == u"progression": - txt_file.write(test_name + u'\n') + if u"2n" in test_name: + test_name = test_name.split("-", 2) + tst = test_name[2].split(".")[-1] + nic = test_name[1] + tst_name = f"{nic}-{tst}" + else: + test_name = test_name.split("-", 1) + tst = test_name[1].split(".")[-1] + nic = test_name[0].split(".")[-1] + tst_name = f"{nic}-{tst}" + + for line in data: + if tst_name in line: + line = line.replace(" ", "") + trend = line.split("|")[2] + number = line.split("|")[3] + ltc = line.split("|")[4] + txt_file.write(f"{tst_name} [ {trend}M | " + f"#{number} | {ltc}% ]\n") else: result = u"FAIL"