Trending: Reduce input data
[csit.git] / resources / tools / presentation / generator_tables.py
index 41dfb94..6f9925f 100644 (file)
@@ -96,7 +96,7 @@ def table_details(table, input_data):
                     try:
                         col_data = str(data[job][build][test][column["data"].
                                        split(" ")[1]]).replace('"', '""')
-                        if column["data"].split(" ")[1] in ("vat-history",
+                        if column["data"].split(" ")[1] in ("conf-history",
                                                             "show-run"):
                             col_data = replace(col_data, " |br| ", "",
                                                maxreplace=1)
@@ -161,7 +161,7 @@ def table_merged_details(table, input_data):
                     try:
                         col_data = str(data[test][column["data"].
                                        split(" ")[1]]).replace('"', '""')
-                        if column["data"].split(" ")[1] in ("vat-history",
+                        if column["data"].split(" ")[1] in ("conf-history",
                                                             "show-run"):
                             col_data = replace(col_data, " |br| ", "",
                                                maxreplace=1)
@@ -486,8 +486,8 @@ def table_nics_comparison(table, input_data):
                         elif table["compare"]["nic"] in tst_data["tags"]:
                             tbl_dict[tst_name_mod]["cmp-data"].append(result)
                 except (TypeError, KeyError) as err:
-                    logging.warning("No data for {0}".format(tst_name))
-                    logging.warning(repr(err))
+                    logging.debug("No data for {0}".format(tst_name))
+                    logging.debug(repr(err))
                     # No data in output.xml for this test
 
     tbl_lst = list()
@@ -683,9 +683,9 @@ def _generate_url(base, testbed, test_name):
             file_name = "vm_vhost_l2"
             if "114b" in test_name:
                 feature = ""
-            elif "l2xcbase" in test_name:
+            elif "l2xcbase" in test_name and "x520" in test_name:
                 feature = "-base-l2xc"
-            elif "l2bdbasemaclrn" in test_name:
+            elif "l2bdbasemaclrn" in test_name and "x520" in test_name:
                 feature = "-base-l2bd"
             else:
                 feature = "-base"
@@ -858,6 +858,57 @@ def table_performance_trending_dashboard_html(table, input_data):
         return
 
 
+def table_last_failed_tests(table, input_data):
+    """Generate the table(s) with algorithm: table_last_failed_tests
+    specified in the specification file.
+
+    :param table: Table to generate.
+    :param input_data: Data to process.
+    :type table: pandas.Series
+    :type input_data: InputData
+    """
+
+    logging.info("  Generating the table {0} ...".
+                 format(table.get("title", "")))
+
+    # Transform the data
+    logging.info("    Creating the data set for the {0} '{1}'.".
+                 format(table.get("type", ""), table.get("title", "")))
+    data = input_data.filter_data(table, continue_on_error=True)
+
+    if data is None or data.empty:
+        logging.warn("    No data for the {0} '{1}'.".
+                     format(table.get("type", ""), table.get("title", "")))
+        return
+
+    tbl_list = list()
+    for job, builds in table["data"].items():
+        for build in builds:
+            build = str(build)
+            try:
+                version = input_data.metadata(job, build).get("version", "")
+            except KeyError:
+                logging.error("Data for {job}: {build} is not present.".
+                              format(job=job, build=build))
+                return
+            tbl_list.append(build)
+            tbl_list.append(version)
+            for tst_name, tst_data in data[job][build].iteritems():
+                if tst_data["status"] != "FAIL":
+                    continue
+                groups = re.search(REGEX_NIC, tst_data["parent"])
+                if not groups:
+                    continue
+                nic = groups.group(0)
+                tbl_list.append("{0}-{1}".format(nic, tst_data["name"]))
+
+    file_name = "{0}{1}".format(table["output-file"], table["output-file-ext"])
+    logging.info("    Writing file: '{0}'".format(file_name))
+    with open(file_name, "w") as file_handler:
+        for test in tbl_list:
+            file_handler.write(test + '\n')
+
+
 def table_failed_tests(table, input_data):
     """Generate the table(s) with algorithm: table_failed_tests
     specified in the specification file.