X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=resources%2Ftools%2Fpresentation%2Fgenerator_tables.py;h=6aa57db796dfa57743871ca036c359df2eb32aec;hb=refs%2Fchanges%2F28%2F13028%2F20;hp=1b0eb36d34c04403b164f22b5bf540e2a17006b5;hpb=0fa26546261134cbf3589443b99ff34c1be0289a;p=csit.git diff --git a/resources/tools/presentation/generator_tables.py b/resources/tools/presentation/generator_tables.py index 1b0eb36d34..6aa57db796 100644 --- a/resources/tools/presentation/generator_tables.py +++ b/resources/tools/presentation/generator_tables.py @@ -17,7 +17,6 @@ import logging import csv -import prettytable import pandas as pd from string import replace @@ -27,7 +26,7 @@ from xml.etree import ElementTree as ET from errors import PresentationError from utils import mean, stdev, relative_change, remove_outliers,\ - split_outliers, classify_anomalies + split_outliers, classify_anomalies, convert_csv_to_pretty_txt def generate_tables(spec, data): @@ -522,18 +521,8 @@ def table_performance_comparison(table, input_data): ] for i, txt_name in enumerate(tbl_names_txt): - txt_table = None logging.info(" Writing file: '{0}'".format(txt_name)) - with open(tbl_names[i], 'rb') as csv_file: - csv_content = csv.reader(csv_file, delimiter=',', quotechar='"') - for row in csv_content: - if txt_table is None: - txt_table = prettytable.PrettyTable(row) - else: - txt_table.add_row(row) - txt_table.align["Test case"] = "l" - with open(txt_name, "w") as txt_file: - txt_file.write(str(txt_table)) + convert_csv_to_pretty_txt(tbl_names[i], txt_name) # Selected tests in csv: input_file = "{0}-ndr-1t1c-full{1}".format(table["output-file"], @@ -711,18 +700,8 @@ def table_performance_comparison_mrr(table, input_data): ] for i, txt_name in enumerate(tbl_names_txt): - txt_table = None logging.info(" Writing file: '{0}'".format(txt_name)) - with open(tbl_names[i], 'rb') as csv_file: - csv_content = csv.reader(csv_file, delimiter=',', quotechar='"') - for row in csv_content: - if txt_table is None: - txt_table = prettytable.PrettyTable(row) - else: - txt_table.add_row(row) - txt_table.align["Test case"] = "l" - with open(txt_name, "w") as txt_file: - txt_file.write(str(txt_table)) + convert_csv_to_pretty_txt(tbl_names[i], txt_name) def table_performance_trending_dashboard(table, input_data): @@ -845,25 +824,99 @@ def table_performance_trending_dashboard(table, input_data): file_name = "{0}{1}".format(table["output-file"], table["output-file-ext"]) - logging.info(" Writing file: '{0}'".format(file_name)) + logging.info(" Writing file: '{0}'".format(file_name)) with open(file_name, "w") as file_handler: file_handler.write(header_str) for test in tbl_sorted: file_handler.write(",".join([str(item) for item in test]) + '\n') txt_file_name = "{0}.txt".format(table["output-file"]) - txt_table = None - logging.info(" Writing file: '{0}'".format(txt_file_name)) - with open(file_name, 'rb') as csv_file: - csv_content = csv.reader(csv_file, delimiter=',', quotechar='"') - for row in csv_content: - if txt_table is None: - txt_table = prettytable.PrettyTable(row) - else: - txt_table.add_row(row) - txt_table.align["Test case"] = "l" - with open(txt_file_name, "w") as txt_file: - txt_file.write(str(txt_table)) + logging.info(" Writing file: '{0}'".format(txt_file_name)) + convert_csv_to_pretty_txt(file_name, txt_file_name) + + +def _generate_url(base, test_name): + """Generate URL to a trending plot from the name of the test case. + + :param base: The base part of URL common to all test cases. + :param test_name: The name of the test case. + :type base: str + :type test_name: str + :returns: The URL to the plot with the trending data for the given test + case. + :rtype str + """ + + url = base + file_name = "" + anchor = "#" + feature = "" + + if "lbdpdk" in test_name or "lbvpp" in test_name: + file_name = "link_bonding.html" + + elif "testpmd" in test_name or "l3fwd" in test_name: + file_name = "dpdk.html" + + elif "memif" in test_name: + file_name = "container_memif.html" + + elif "srv6" in test_name: + file_name = "srv6.html" + + elif "vhost" in test_name: + if "l2xcbase" in test_name or "l2bdbasemaclrn" in test_name: + file_name = "vm_vhost_l2.html" + elif "ip4base" in test_name: + file_name = "vm_vhost_ip4.html" + + elif "ipsec" in test_name: + file_name = "ipsec.html" + + elif "ethip4lispip" in test_name or "ethip4vxlan" in test_name: + file_name = "ip4_tunnels.html" + + elif "ip4base" in test_name or "ip4scale" in test_name: + file_name = "ip4.html" + if "iacl" in test_name or "snat" in test_name or "cop" in test_name: + feature = "-features" + + elif "ip6base" in test_name or "ip6scale" in test_name: + file_name = "ip6.html" + + elif "l2xcbase" in test_name or "l2xcscale" in test_name \ + or "l2bdbasemaclrn" in test_name or "l2bdscale" in test_name \ + or "l2dbbasemaclrn" in test_name or "l2dbscale" in test_name: + file_name = "l2.html" + if "iacl" in test_name: + feature = "-features" + + if "x520" in test_name: + anchor += "x520-" + elif "x710" in test_name: + anchor += "x710-" + elif "xl710" in test_name: + anchor += "xl710-" + + if "64b" in test_name: + anchor += "64b-" + elif "78b" in test_name: + anchor += "78b-" + elif "imix" in test_name: + anchor += "imix-" + elif "9000b" in test_name: + anchor += "9000b-" + elif "1518" in test_name: + anchor += "1518b-" + + if "1t1c" in test_name: + anchor += "1t1c" + elif "2t2c" in test_name: + anchor += "2t2c" + elif "4t4c" in test_name: + anchor += "4t4c" + + return url + file_name + anchor + feature def table_performance_trending_dashboard_html(table, input_data): @@ -924,84 +977,170 @@ def table_performance_trending_dashboard_html(table, input_data): alignment = "left" if c_idx == 0 else "center" td = ET.SubElement(tr, "td", attrib=dict(align=alignment)) # Name: - url = "../trending/" - file_name = "" - anchor = "#" - feature = "" if c_idx == 0: - if "memif" in item: - file_name = "container_memif.html" - - elif "srv6" in item: - file_name = "srv6.html" - - elif "vhost" in item: - if "l2xcbase" in item or "l2bdbasemaclrn" in item: - file_name = "vm_vhost_l2.html" - elif "ip4base" in item: - file_name = "vm_vhost_ip4.html" - - elif "ipsec" in item: - file_name = "ipsec.html" - - elif "ethip4lispip" in item or "ethip4vxlan" in item: - file_name = "ip4_tunnels.html" - - elif "ip4base" in item or "ip4scale" in item: - file_name = "ip4.html" - if "iacl" in item or "snat" in item or "cop" in item: - feature = "-features" - - elif "ip6base" in item or "ip6scale" in item: - file_name = "ip6.html" - - elif "l2xcbase" in item or "l2xcscale" in item \ - or "l2bdbasemaclrn" in item or "l2bdscale" in item \ - or "l2dbbasemaclrn" in item or "l2dbscale" in item: - file_name = "l2.html" - if "iacl" in item: - feature = "-features" - - if "x520" in item: - anchor += "x520-" - elif "x710" in item: - anchor += "x710-" - elif "xl710" in item: - anchor += "xl710-" - - if "64b" in item: - anchor += "64b-" - elif "78b" in item: - anchor += "78b-" - elif "imix" in item: - anchor += "imix-" - elif "9000b" in item: - anchor += "9000b-" - elif "1518" in item: - anchor += "1518b-" - - if "1t1c" in item: - anchor += "1t1c" - elif "2t2c" in item: - anchor += "2t2c" - elif "4t4c" in item: - anchor += "4t4c" - - url = url + file_name + anchor + feature - + url = _generate_url("../trending/", item) ref = ET.SubElement(td, "a", attrib=dict(href=url)) ref.text = item - - if c_idx > 0: + else: td.text = item - try: with open(table["output-file"], 'w') as html_file: - logging.info(" Writing file: '{0}'". - format(table["output-file"])) + logging.info(" Writing file: '{0}'".format(table["output-file"])) html_file.write(".. raw:: html\n\n\t") html_file.write(ET.tostring(dashboard)) html_file.write("\n\t