From 9c00fcc554d3667936e6e6ed2122203a839867c4 Mon Sep 17 00:00:00 2001 From: francisco Date: Wed, 15 Jan 2025 09:10:29 -0300 Subject: [PATCH 1/3] refactor: move is_boot function to utils file Part of #741 --- backend/kernelCI_app/utils.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/backend/kernelCI_app/utils.py b/backend/kernelCI_app/utils.py index 0f0b8400b..5c8dccbcd 100644 --- a/backend/kernelCI_app/utils.py +++ b/backend/kernelCI_app/utils.py @@ -72,3 +72,7 @@ def string_to_json(string: str) -> Optional[dict]: except json.JSONDecodeError as e: log_message(e.msg) return None + + +def is_boot(path: str | None) -> bool: + return path is not None and (path == "boot" or path.startswith("boot.")) From ad840959321c08ef5ad688633b0d982481d112ff Mon Sep 17 00:00:00 2001 From: francisco Date: Wed, 15 Jan 2025 09:14:03 -0300 Subject: [PATCH 2/3] feat: use is_boot function in api - tree details - tree commits history - hardware details Part of #741 --- backend/kernelCI_app/helpers/treeDetails.py | 5 ++--- backend/kernelCI_app/views/hardwareDetailsView.py | 15 ++++++++------- backend/kernelCI_app/views/treeCommitsHistory.py | 11 +++++------ 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/backend/kernelCI_app/helpers/treeDetails.py b/backend/kernelCI_app/helpers/treeDetails.py index 003d1ba17..ac033176e 100644 --- a/backend/kernelCI_app/helpers/treeDetails.py +++ b/backend/kernelCI_app/helpers/treeDetails.py @@ -16,6 +16,7 @@ env_misc_value_or_default, ) from kernelCI_app.cache import getQueryCache, setQueryCache +from kernelCI_app.utils import is_boot from django.db import connection @@ -231,9 +232,7 @@ def get_hardware_filter(row_data: dict) -> Any: def is_test_boots_test(row_data: dict) -> bool: test_path = row_data["test_path"] - if test_path.startswith("boot"): - return True - return False + return is_boot(test_path) def get_build(row_data: dict) -> dict: diff --git a/backend/kernelCI_app/views/hardwareDetailsView.py b/backend/kernelCI_app/views/hardwareDetailsView.py index 5bedb61c1..af6d1a67f 100644 --- a/backend/kernelCI_app/views/hardwareDetailsView.py +++ b/backend/kernelCI_app/views/hardwareDetailsView.py @@ -16,7 +16,11 @@ from kernelCI_app.cache import getQueryCache, setQueryCache from kernelCI_app.viewCommon import create_details_build_summary from kernelCI_app.models import Tests -from kernelCI_app.utils import create_issue, extract_error_message +from kernelCI_app.utils import ( + create_issue, + extract_error_message, + is_boot +) from django.views.decorators.csrf import csrf_exempt from kernelCI_app.helpers.trees import get_tree_heads from kernelCI_app.helpers.filters import UNKNOWN_STRING, FilterParams @@ -100,10 +104,6 @@ def get_history(record: Dict): } -def is_boot(record: Dict) -> bool: - return record["path"] == "boot" or record["path"].startswith("boot.") - - def get_record_tree(record: Dict, selected_trees: List) -> Optional[Dict]: for tree in selected_trees: if ( @@ -386,7 +386,7 @@ def sanitize_records(self, records, trees: List, is_all_selected: bool): compatibles.update(record["environment_compatible"]) tree_index = current_tree["index"] - is_record_boot = is_boot(record) + is_record_boot = is_boot(record['path']) # TODO -> Unify with tree_status_key, be careful with the pluralization test_filter_key = "boot" if is_record_boot else "test" @@ -411,7 +411,8 @@ def sanitize_records(self, records, trees: List, is_all_selected: bool): continue should_process_test = ( - self.test_in_filter(test_filter_key, record) + record['id'] is not None + and self.test_in_filter(test_filter_key, record) and record["id"] not in processed_tests ) diff --git a/backend/kernelCI_app/views/treeCommitsHistory.py b/backend/kernelCI_app/views/treeCommitsHistory.py index 2dc80e0a5..fb01da808 100644 --- a/backend/kernelCI_app/views/treeCommitsHistory.py +++ b/backend/kernelCI_app/views/treeCommitsHistory.py @@ -15,7 +15,7 @@ build_misc_value_or_default, env_misc_value_or_default, ) -from kernelCI_app.utils import getErrorResponseBody +from kernelCI_app.utils import getErrorResponseBody, is_boot from rest_framework.views import APIView from rest_framework.response import Response from rest_framework import status @@ -225,10 +225,6 @@ def _process_tests(self, row: Dict) -> None: incident_test_id = row["incidents_test_id"] build_valid = row["build_valid"] - is_boot = test_path is not None and test_path.startswith( - "boot" - ) - commit_hash = row["git_commit_hash"] if issue_id is None and ( @@ -237,7 +233,10 @@ def _process_tests(self, row: Dict) -> None: ): issue_id = UNKNOWN_STRING - if is_boot: + if test_id is None: + return + + if is_boot(test_path): self._process_boots_count( test_id=test_id, test_status=test_status, From d1313364f5a94d7ea2ba0d4c8d7d0d6815d5eef3 Mon Sep 17 00:00:00 2001 From: francisco Date: Wed, 15 Jan 2025 14:39:29 -0300 Subject: [PATCH 3/3] fix(dashboard): count tests null status --- dashboard/src/components/TestsTable/DefaultTestsColumns.tsx | 1 + dashboard/src/components/TestsTable/TestsTable.tsx | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/dashboard/src/components/TestsTable/DefaultTestsColumns.tsx b/dashboard/src/components/TestsTable/DefaultTestsColumns.tsx index 1188a7a1f..70da05d9b 100644 --- a/dashboard/src/components/TestsTable/DefaultTestsColumns.tsx +++ b/dashboard/src/components/TestsTable/DefaultTestsColumns.tsx @@ -44,6 +44,7 @@ export const defaultColumns: ColumnDef[] = [ fail={row.original.fail_tests} skip={row.original.skip_tests} error={row.original.error_tests} + nullStatus={row.original.null_tests} /> ); }, diff --git a/dashboard/src/components/TestsTable/TestsTable.tsx b/dashboard/src/components/TestsTable/TestsTable.tsx index 09a8dd605..3f98c2b7e 100644 --- a/dashboard/src/components/TestsTable/TestsTable.tsx +++ b/dashboard/src/components/TestsTable/TestsTable.tsx @@ -124,7 +124,7 @@ export function TestsTable({ groups[group].skip_tests++; break; default: - if (!e.status) groups[group].null_tests++; + groups[group].null_tests++; } }); return Object.values(groups);