UTI: Simplify the News
[csit.git] / resources / tools / dash / app / pal / utils / constants.py
1 # Copyright (c) 2022 Cisco and/or its affiliates.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
5 #
6 #     http://www.apache.org/licenses/LICENSE-2.0
7 #
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
13
14 """Constants used in Dash PAL.
15
16 "Constant" means a value that keeps its value since initialization. The value
17 does not need to be hard coded here, but can be read from environment variables.
18 """
19
20 import logging
21 import dash_bootstrap_components as dbc
22
23 from dash import html
24
25
26 class Constants:
27     """Constants used in Dash PAL.
28     """
29
30     ############################################################################
31     # General, application wide constants.
32
33     # Logging settings.
34     LOG_LEVEL = logging.INFO
35     LOG_FORMAT = "%(asctime)s: %(levelname)s: %(message)s"
36     LOG_DATE_FORMAT = "%Y/%m/%d %H:%M:%S"
37
38     # The application title.
39     TITLE = "FD.io CSIT"
40
41     # The application description.
42     DESCRIPTION = "Performance Dashboard"
43
44     # External stylesheets.
45     EXTERNAL_STYLESHEETS = [dbc.themes.LUX, ]
46
47     # Top level template for all pages.
48     TEMPLATE = "d-flex h-100 text-center text-white bg-dark"
49
50     # Path and name of the file specifying the HTML layout of the dash
51     # application.
52     MAIN_HTML_LAYOUT_FILE = "index_layout.jinja2"
53
54     # Application root.
55     APPLICATIN_ROOT = "/"
56
57     # Data to be downloaded from the parquets specification file.
58     DATA_SPEC_FILE = "pal/data/data.yaml"
59
60     # The file with tooltips.
61     TOOLTIP_FILE = "pal/utils/tooltips.yaml"
62
63     # Maximal value of TIME_PERIOD for data read from the parquets in days.
64     # Do not change without a good reason.
65     MAX_TIME_PERIOD = 180
66
67     # It defines the time period for data read from the parquets in days from
68     # now back to the past.
69     # TIME_PERIOD = None - means all data (max MAX_TIME_PERIOD days) is read.
70     # TIME_PERIOD = MAX_TIME_PERIOD - is the default value
71     TIME_PERIOD = MAX_TIME_PERIOD  # [days]
72
73     # List of releases used for iterative data processing.
74     # The releases MUST be in the order from the current (newest) to the last
75     # (oldest).
76     RELEASES = ["csit2206", "csit2202", ]
77
78     ############################################################################
79     # General, application wide, layout affecting constants.
80
81     # If True, clear all inputs in control panel when button "ADD SELECTED" is
82     # pressed.
83     CLEAR_ALL_INPUTS = False
84
85     # The element is disabled.
86     STYLE_DISABLED = {"display": "none"}
87
88     # The element is enabled and visible.
89     STYLE_ENABLED = {"display": "inherit"}
90
91     # Checklist "All" is disabled.
92     CL_ALL_DISABLED = [
93         {
94             "label": "All",
95             "value": "all",
96             "disabled": True
97         }
98     ]
99
100     # Checklist "All" is enable, visible and unchecked.
101     CL_ALL_ENABLED = [
102         {
103             "label": "All",
104             "value": "all",
105             "disabled": False
106         }
107     ]
108
109     # Placeholder for any element in the layout.
110     PLACEHOLDER = html.Nobr("")
111
112     # List of drivers used in CSIT.
113     DRIVERS = ("avf", "af-xdp", "rdma", "dpdk")
114
115     # Labels for input elements (dropdowns, ...).
116     LABELS = {
117         "dpdk": "DPDK",
118         "container_memif": "LXC/DRC Container Memif",
119         "crypto": "IPSec IPv4 Routing",
120         "ip4": "IPv4 Routing",
121         "ip6": "IPv6 Routing",
122         "ip4_tunnels": "IPv4 Tunnels",
123         "l2": "L2 Ethernet Switching",
124         "srv6": "SRv6 Routing",
125         "vm_vhost": "VMs vhost-user",
126         "nfv_density-dcr_memif-chain_ipsec": "CNF Service Chains Routing IPSec",
127         "nfv_density-vm_vhost-chain_dot1qip4vxlan":"VNF Service Chains Tunnels",
128         "nfv_density-vm_vhost-chain": "VNF Service Chains Routing",
129         "nfv_density-dcr_memif-pipeline": "CNF Service Pipelines Routing",
130         "nfv_density-dcr_memif-chain": "CNF Service Chains Routing",
131     }
132
133     # URL style.
134     URL_STYLE = {
135         "background-color": "#d2ebf5",
136         "border-color": "#bce1f1",
137         "color": "#135d7c"
138     }
139
140     ############################################################################
141     # General, normalization constants.
142
143     NORM_FREQUENCY = 2.0  # [GHz]
144     FREQUENCY = {  # [GHz]
145         "2n-aws": 1.000,
146         "2n-dnv": 2.000,
147         "2n-clx": 2.300,
148         "2n-icx": 2.600,
149         "2n-skx": 2.500,
150         "2n-tx2": 2.500,
151         "2n-zn2": 2.900,
152         "3n-alt": 3.000,
153         "3n-aws": 1.000,
154         "3n-dnv": 2.000,
155         "3n-icx": 2.600,
156         "3n-skx": 2.500,
157         "3n-tsh": 2.200
158     }
159
160     ############################################################################
161     # General, plots constants.
162
163     PLOT_COLORS = (
164         "#1A1110", "#DA2647", "#214FC6", "#01786F", "#BD8260", "#FFD12A",
165         "#A6E7FF", "#738276", "#C95A49", "#FC5A8D", "#CEC8EF", "#391285",
166         "#6F2DA8", "#FF878D", "#45A27D", "#FFD0B9", "#FD5240", "#DB91EF",
167         "#44D7A8", "#4F86F7", "#84DE02", "#FFCFF1", "#614051"
168     )
169
170     # Trending, anomalies.
171     ANOMALY_COLOR = {
172         "regression": 0.0,
173         "normal": 0.5,
174         "progression": 1.0
175     }
176
177     COLORSCALE_TPUT = [
178         [0.00, "red"],
179         [0.33, "red"],
180         [0.33, "white"],
181         [0.66, "white"],
182         [0.66, "green"],
183         [1.00, "green"]
184     ]
185
186     TICK_TEXT_TPUT = ["Regression", "Normal", "Progression"]
187
188     COLORSCALE_LAT = [
189         [0.00, "green"],
190         [0.33, "green"],
191         [0.33, "white"],
192         [0.66, "white"],
193         [0.66, "red"],
194         [1.00, "red"]
195     ]
196
197     TICK_TEXT_LAT = ["Progression", "Normal", "Regression"]
198
199     # Access to the results.
200     VALUE = {
201         "mrr": "result_receive_rate_rate_avg",
202         "ndr": "result_ndr_lower_rate_value",
203         "pdr": "result_pdr_lower_rate_value",
204         "pdr-lat": "result_latency_forward_pdr_50_avg"
205     }
206
207     VALUE_ITER = {
208         "mrr": "result_receive_rate_rate_values",
209         "ndr": "result_ndr_lower_rate_value",
210         "pdr": "result_pdr_lower_rate_value",
211         "pdr-lat": "result_latency_forward_pdr_50_avg"
212     }
213
214     UNIT = {
215         "mrr": "result_receive_rate_rate_unit",
216         "ndr": "result_ndr_lower_rate_unit",
217         "pdr": "result_pdr_lower_rate_unit",
218         "pdr-lat": "result_latency_forward_pdr_50_unit"
219     }
220
221     # Latencies.
222     LAT_HDRH = (  # Do not change the order
223         "result_latency_forward_pdr_0_hdrh",
224         "result_latency_reverse_pdr_0_hdrh",
225         "result_latency_forward_pdr_10_hdrh",
226         "result_latency_reverse_pdr_10_hdrh",
227         "result_latency_forward_pdr_50_hdrh",
228         "result_latency_reverse_pdr_50_hdrh",
229         "result_latency_forward_pdr_90_hdrh",
230         "result_latency_reverse_pdr_90_hdrh",
231     )
232
233     # This value depends on latency stream rate (9001 pps) and duration (5s).
234     # Keep it slightly higher to ensure rounding errors to not remove tick mark.
235     PERCENTILE_MAX = 99.999501
236
237     GRAPH_LAT_HDRH_DESC = {
238         "result_latency_forward_pdr_0_hdrh": "No-load.",
239         "result_latency_reverse_pdr_0_hdrh": "No-load.",
240         "result_latency_forward_pdr_10_hdrh": "Low-load, 10% PDR.",
241         "result_latency_reverse_pdr_10_hdrh": "Low-load, 10% PDR.",
242         "result_latency_forward_pdr_50_hdrh": "Mid-load, 50% PDR.",
243         "result_latency_reverse_pdr_50_hdrh": "Mid-load, 50% PDR.",
244         "result_latency_forward_pdr_90_hdrh": "High-load, 90% PDR.",
245         "result_latency_reverse_pdr_90_hdrh": "High-load, 90% PDR."
246     }
247
248     ############################################################################
249     # News.
250
251     # The pathname prefix for the application.
252     NEWS_ROUTES_PATHNAME_PREFIX = "/news/"
253
254     # Path and name of the file specifying the HTML layout of the dash
255     # application.
256     NEWS_HTML_LAYOUT_FILE = "pal/templates/news_layout.jinja2"
257
258     # Time period for regressions and progressions.
259     NEWS_TIME_PERIOD = TIME_PERIOD  # [days]
260
261     # Time periods for summary tables.
262     NEWS_LAST = 1  # [days]
263     NEWS_SHORT = 7  # [days]
264     NEWS_LONG = NEWS_TIME_PERIOD  # [days]
265
266     ############################################################################
267     # Report.
268
269     # The pathname prefix for the application.
270     REPORT_ROUTES_PATHNAME_PREFIX = "/report/"
271
272     # Path and name of the file specifying the HTML layout of the dash
273     # application.
274     REPORT_HTML_LAYOUT_FILE = "pal/templates/report_layout.jinja2"
275
276     # Layout of plot.ly graphs.
277     REPORT_GRAPH_LAYOUT_FILE = "pal/report/layout.yaml"
278
279     # Default name of downloaded file with selected data.
280     REPORT_DOWNLOAD_FILE_NAME = "iterative_data.csv"
281
282     ############################################################################
283     # Statistics.
284
285     # The pathname prefix for the application.
286     STATS_ROUTES_PATHNAME_PREFIX = "/stats/"
287
288     # Path and name of the file specifying the HTML layout of the dash
289     # application.
290     STATS_HTML_LAYOUT_FILE = "pal/templates/stats_layout.jinja2"
291
292     # Layout of plot.ly graphs.
293     STATS_GRAPH_LAYOUT_FILE = "pal/stats/layout.yaml"
294
295     # The default job displayed when the page is loaded first time.
296     STATS_DEFAULT_JOB = "csit-vpp-perf-mrr-daily-master-2n-icx"
297
298     # Default name of downloaded file with selected data.
299     STATS_DOWNLOAD_FILE_NAME = "stats.csv"
300
301     ############################################################################
302     # Trending.
303
304     # The pathname prefix for the application.
305     TREND_ROUTES_PATHNAME_PREFIX = "/trending/"
306
307     # Path and name of the file specifying the HTML layout of the dash
308     # application.
309     TREND_HTML_LAYOUT_FILE = "pal/templates/trending_layout.jinja2"
310
311     # Layout of plot.ly graphs.
312     TREND_GRAPH_LAYOUT_FILE = "pal/trending/layout.yaml"
313
314     # Default name of downloaded file with selected data.
315     TREND_DOWNLOAD_FILE_NAME = "trending_data.csv"