C-Dash: Add search in tests
[csit.git] / csit.infra.dash / app / cdash / comparisons / tables.py
index b2bee7f..ab99f18 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (c) 2023 Cisco and/or its affiliates.
+# Copyright (c) 2024 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:
@@ -18,6 +18,7 @@ import pandas as pd
 
 from numpy import mean, std
 from copy import deepcopy
+
 from ..utils.constants import Constants as C
 from ..utils.utils import relative_change_stdev
 
@@ -70,8 +71,12 @@ def select_comparison_data(
         for itm in data_in["test_id"].unique().tolist():
             itm_lst = itm.split(".")
             test = itm_lst[-1].rsplit("-", 1)[0]
+            if "hoststack" in itm:
+                test_type = f"hoststack-{ttype}"
+            else:
+                test_type = ttype
             df = data_in.loc[(data_in["test_id"] == itm)]
-            l_df = df[C.VALUE_ITER[ttype]].to_list()
+            l_df = df[C.VALUE_ITER[test_type]].to_list()
             if len(l_df) and isinstance(l_df[0], list):
                 tmp_df = list()
                 for l_itm in l_df:
@@ -85,7 +90,7 @@ def select_comparison_data(
             d_data["name"].append(f"{test.replace(f'{drv}-', '')}-{ttype}")
             d_data["mean"].append(int(mean_val * norm_factor))
             d_data["stdev"].append(int(std_val * norm_factor))
-            d_data["unit"].append(df[C.UNIT[ttype]].to_list()[0])
+            d_data["unit"].append(df[C.UNIT[test_type]].to_list()[0])
         return pd.DataFrame(d_data)
 
     lst_df = list()
@@ -108,11 +113,17 @@ def select_comparison_data(
 
         drv = "" if itm["driver"] == "dpdk" else itm["driver"].replace("_", "-")
         core = str() if itm["dut"] == "trex" else itm["core"].lower()
-        reg_id = \
-            f"^.*[.|-]{itm['nic']}.*{itm['frmsize'].lower()}-{core}-{drv}.*$"
+        ttype = "ndrpdr" if itm["ttype"] in ("NDR", "PDR", "Latency") \
+            else itm["ttype"].lower()
         tmp_df = tmp_df[
             (tmp_df.job.str.endswith(itm["tbed"])) &
-            (tmp_df.test_id.str.contains(reg_id, regex=True))
+            (tmp_df.test_id.str.contains(
+                (
+                    f"^.*[.|-]{itm['nic']}.*{itm['frmsize'].lower()}-"
+                    f"{core}-{drv}.*-{ttype}$"
+                ),
+                regex=True
+            ))
         ]
         if itm["driver"] == "dpdk":
             for drv in C.DRIVERS: