Skip to content

Commit

Permalink
[Bug-fix] Fixes broken dependencies and some telco NPEs
Browse files Browse the repository at this point in the history
Signed-off-by: Vishnu Challa <[email protected]>
  • Loading branch information
Vishnu Challa committed Jan 15, 2025
1 parent 284c302 commit 489288a
Show file tree
Hide file tree
Showing 3 changed files with 473 additions and 484 deletions.
22 changes: 11 additions & 11 deletions backend/app/api/v1/endpoints/telco/telcoGraphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ async def process_json(json_data: dict, is_row: bool):

def process_ptp(json_data: str, is_row: bool):
nic = json_data["nic"]
ptp4l_max_offset = json_data.get("ptp4l_max_offset", 0)
ptp4l_max_offset = json_data.get("ptp4l_max_offset") or 0
if "mellanox" in nic.lower():
defined_offset_threshold = 200
else:
Expand Down Expand Up @@ -80,9 +80,9 @@ def process_reboot(json_data: str, is_row: bool):
defined_threshold = 20
reboot_type = json_data["reboot_type"]
for each_iteration in json_data["Iterations"]:
max_minutes = max(max_minutes, each_iteration.get("total_minutes", 0))
avg_minutes += each_iteration.get("total_minutes", 0)
avg_minutes /= len(json_data["Iterations"])
max_minutes = max(max_minutes, each_iteration.get("total_minutes") or 0)
avg_minutes += each_iteration.get("total_minutes") or 0
avg_minutes /= max(len(json_data["Iterations"]), 1)
if max_minutes > defined_threshold:
minus_max_minutes = max_minutes - defined_threshold
if avg_minutes > defined_threshold:
Expand Down Expand Up @@ -136,9 +136,9 @@ def process_cpu_util(json_data: str, is_row: bool):
if each_scenario["scenario_name"] == "steadyworkload":
for each_type in each_scenario["types"]:
if each_type["type_name"] == "total":
total_max_cpu = each_type.get("max_cpu", 0)
total_max_cpu = each_type.get("max_cpu") or 0
break
total_avg_cpu = each_scenario.get("avg_cpu_total", 0)
total_avg_cpu = each_scenario.get("avg_cpu_total") or 0
break
if total_max_cpu > defined_threshold:
minus_max_cpu = total_max_cpu - defined_threshold
Expand Down Expand Up @@ -184,7 +184,7 @@ def process_cpu_util(json_data: str, is_row: bool):
}

def process_rfc_2544(json_data: str, is_row: bool):
max_delay = json_data.get("max_delay", 0)
max_delay = json_data.get("max_delay") or 0
defined_delay_threshold = 30.0
minus_max_delay = 0.0
if max_delay > defined_delay_threshold:
Expand Down Expand Up @@ -237,8 +237,8 @@ def process_cyclictest(json_data: str, is_row: bool):
return result if is_row else { "cyclictest": result }

def process_deployment(json_data: str, is_row: bool):
total_minutes = json_data.get("total_minutes", 0)
reboot_count = json_data.get("reboot_count", 0)
total_minutes = json_data.get("total_minutes") or 0
reboot_count = json_data.get("reboot_count") or 0
defined_total_minutes_threshold = 180
defined_total_reboot_count = 3
minus_total_minutes = 0.0
Expand Down Expand Up @@ -327,8 +327,8 @@ def get_oslat_or_cyclictest(json_data: str, is_row: bool):
defined_latency_threshold = 20
defined_number_of_nines_threshold = 100
for each_test_unit in json_data["test_units"]:
max_latency = max(max_latency, each_test_unit.get("max_latency", 0))
min_number_of_nines = min(min_number_of_nines, each_test_unit.get("number_of_nines", 0))
max_latency = max(max_latency, each_test_unit.get("max_latency") or 0)
min_number_of_nines = min(min_number_of_nines, each_test_unit.get("number_of_nines") or 0)
if max_latency > defined_latency_threshold:
minus_max_latency = max_latency - defined_latency_threshold

Expand Down
Loading

0 comments on commit 489288a

Please sign in to comment.