Skip to content

Commit

Permalink
feat(tree-details): add filters field
Browse files Browse the repository at this point in the history
- Added `process_filter` function to helpers/treeDetails.py, the
  function responsible to get the value of all possible filters in the
  tree details response
- Added 'common' and 'filters' fields to tree details summary response
- Added 'common' and 'filters' fields to tree details response

Part of #792
  • Loading branch information
murilx committed Jan 22, 2025
1 parent 61e92d7 commit 22eeefc
Show file tree
Hide file tree
Showing 8 changed files with 228 additions and 28 deletions.
41 changes: 41 additions & 0 deletions backend/kernelCI_app/helpers/treeDetails.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
)
from kernelCI_app.cache import getQueryCache, setQueryCache
from kernelCI_app.utils import is_boot
from kernelCI_app.constants.hardwareDetails import STATUS_FAILED_VALUE
from django.db import connection


Expand Down Expand Up @@ -478,3 +479,43 @@ def process_boots_summary(instance, row_data):
] += 1
else:
instance.bootEnvironmentMisc[test_platform][test_status] += 1


def process_filters(instance, row_data: dict) -> None:
if row_data["build_id"] is not None:
instance.global_configs.add(row_data["build_config_name"])
instance.global_architectures.add(row_data["build_architecture"])
instance.global_compilers.add(row_data["build_config_name"])

issue_id = row_data["issue_id"]
issue_version = row_data["issue_version"]
incident_test_id = row_data["incident_test_id"]
build_valid = row_data["build_valid"]

if row_data["build_id"] is not None:
build_issue_id, is_build_issue = should_increment_build_issue(
issue_id=issue_id,
incident_test_id=incident_test_id,
build_valid=build_valid,
)

if build_issue_id is not None and issue_version is not None and is_build_issue:
instance.unfiltered_build_issues.add(build_issue_id)
elif build_valid is False:
instance.unfiltered_build_issues.add(UNKNOWN_STRING)

if row_data["test_id"] is not None:
test_issue_id, is_test_issue = should_increment_test_issue(
issue_id=issue_id,
incident_test_id=incident_test_id,
)

if is_boot(row_data["test_path"]):
issue_set = instance.unfiltered_boot_issues
else:
issue_set = instance.unfiltered_test_issues

if test_issue_id is not None and issue_version is not None and is_test_issue:
issue_set.add(test_issue_id)
elif row_data["test_status"] == STATUS_FAILED_VALUE:
issue_set.add(UNKNOWN_STRING)
23 changes: 21 additions & 2 deletions backend/kernelCI_app/typeModels/treeDetails.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,33 @@ class TestSummary(BaseModel):
failed_platforms: List[str]


class TreeSummary(Summary):
class TreeCommon(BaseModel):
hardware: Optional[List[str]]
tree_url: Optional[str]
git_commit_tags: Optional[List[str]]


class TreeGlobalFilters(BaseModel):
configs: List[str]
architectures: List[str]
compilers: List[str]


class TreeLocalFilters(BaseModel):
issues: List[str]


class TreeFilters(BaseModel):
all: TreeGlobalFilters
builds: TreeLocalFilters
boots: TreeLocalFilters
tests: TreeLocalFilters


class SummaryResponse(BaseModel):
summary: TreeSummary
common: TreeCommon
summary: Summary
filters: TreeFilters


class BootResponse(BaseModel):
Expand Down
35 changes: 31 additions & 4 deletions backend/kernelCI_app/views/treeDetailsSummaryView.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
process_builds_issue,
process_test_summary,
process_tests_issue,
process_filters,
)
from kernelCI_app.typeModels.treeDetails import SummaryResponse
from kernelCI_app.utils import (
Expand Down Expand Up @@ -65,6 +66,13 @@ def __init__(self):
self.tree_url = ""
self.git_commit_tags = []

self.global_configs = set()
self.global_architectures = set()
self.global_compilers = set()
self.unfiltered_test_issues = set()
self.unfiltered_boot_issues = set()
self.unfiltered_build_issues = set()

def _process_boots_test(self, row_data):
test_id = row_data["test_id"]

Expand Down Expand Up @@ -118,6 +126,7 @@ def _sanitize_rows(self, rows):
call_based_on_compatible_and_misc_platform(row_data, self.hardwareUsed.add)

process_tree_url(self, row_data)
process_filters(self, row_data)

is_record_filter_out = decide_if_is_full_row_filtered_out(self, row_data)

Expand Down Expand Up @@ -151,6 +160,11 @@ def get(self, request, commit_hash: str | None):
self._sanitize_rows(rows)

response = {
"common": {
"tree_url": self.tree_url,
"hardware": list(self.hardwareUsed),
"git_commit_tags": self.git_commit_tags,
},
"summary": {
"builds": {
"status": self.build_summary["builds"],
Expand Down Expand Up @@ -181,10 +195,23 @@ def get(self, request, commit_hash: str | None):
"fail_reasons": self.testFailReasons,
"failed_platforms": list(self.testPlatformsWithErrors),
},
"hardware": list(self.hardwareUsed),
"tree_url": self.tree_url,
"git_commit_tags": self.git_commit_tags,
}
},
"filters": {
"all": {
"configs": list(self.global_configs),
"architectures": list(self.global_architectures),
"compilers": list(self.global_compilers),
},
"builds": {
"issues": list(self.unfiltered_build_issues),
},
"boots": {
"issues": list(self.unfiltered_boot_issues),
},
"tests": {
"issues": list(self.unfiltered_test_issues),
},
},
}

try:
Expand Down
27 changes: 27 additions & 0 deletions backend/kernelCI_app/views/treeDetailsView.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
process_builds_issue,
process_test_summary,
process_tests_issue,
process_filters,
)
from kernelCI_app.utils import (
Issue,
Expand Down Expand Up @@ -72,6 +73,13 @@ def __init__(self):
self.tree_url = ""
self.git_commit_tags = []

self.global_configs = set()
self.global_architectures = set()
self.global_compilers = set()
self.unfiltered_test_issues = set()
self.unfiltered_boot_issues = set()
self.unfiltered_build_issues = set()

def _process_boots_test(self, row_data):
test_id = row_data["test_id"]
history_item = row_data["history_item"]
Expand Down Expand Up @@ -129,6 +137,7 @@ def _sanitize_rows(self, rows):
call_based_on_compatible_and_misc_platform(row_data, self.hardwareUsed.add)

process_tree_url(self, row_data)
process_filters(self, row_data)

is_record_filter_out = decide_if_is_full_row_filtered_out(self, row_data)

Expand Down Expand Up @@ -198,10 +207,28 @@ def get(self, request, commit_hash: str | None):
"fail_reasons": self.testFailReasons,
"failed_platforms": list(self.testPlatformsWithErrors),
},
},
"common": {
"hardware": list(self.hardwareUsed),
"tree_url": self.tree_url,
"git_commit_tags": self.git_commit_tags,
},
"filters": {
"all": {
"configs": list(self.global_configs),
"architectures": list(self.global_architectures),
"compilers": list(self.global_compilers),
},
"builds": {
"issues": list(self.unfiltered_build_issues),
},
"boots": {
"issues": list(self.unfiltered_boot_issues),
},
"tests": {
"issues": list(self.unfiltered_test_issues),
},
},
},
safe=False,
)
98 changes: 80 additions & 18 deletions backend/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -663,12 +663,32 @@ components:
- platform
title: Misc
type: object
Summary:
properties:
builds:
$ref: '#/components/schemas/BuildSummary'
boots:
$ref: '#/components/schemas/TestSummary'
tests:
$ref: '#/components/schemas/TestSummary'
required:
- builds
- boots
- tests
title: Summary
type: object
SummaryResponse:
properties:
common:
$ref: '#/components/schemas/TreeCommon'
summary:
$ref: '#/components/schemas/TreeSummary'
$ref: '#/components/schemas/Summary'
filters:
$ref: '#/components/schemas/TreeFilters'
required:
- common
- summary
- filters
title: SummaryResponse
type: object
TestArchSummaryItem:
Expand Down Expand Up @@ -722,43 +742,43 @@ components:
type: string
type: array
- type: 'null'
default: null
title: Environment Compatible
config:
anyOf:
- type: string
- type: 'null'
default: null
title: Config
log_url:
anyOf:
- type: string
- type: 'null'
default: null
title: Log Url
architecture:
anyOf:
- type: string
- type: 'null'
default: null
title: Architecture
compiler:
anyOf:
- type: string
- type: 'null'
default: null
title: Compiler
misc:
anyOf:
- $ref: '#/components/schemas/Misc'
- type: 'null'
default: null
required:
- id
- status
- duration
- path
- start_time
- environment_compatible
- config
- log_url
- architecture
- compiler
- misc
title: TestHistoryItem
type: object
TestIssuesItem:
Expand Down Expand Up @@ -945,14 +965,8 @@ components:
- selected_commit_status
title: Tree
type: object
TreeSummary:
TreeCommon:
properties:
builds:
$ref: '#/components/schemas/BuildSummary'
boots:
$ref: '#/components/schemas/TestSummary'
tests:
$ref: '#/components/schemas/TestSummary'
hardware:
anyOf:
- items:
Expand All @@ -973,13 +987,61 @@ components:
- type: 'null'
title: Git Commit Tags
required:
- builds
- boots
- tests
- hardware
- tree_url
- git_commit_tags
title: TreeSummary
title: TreeCommon
type: object
TreeFilters:
properties:
all:
$ref: '#/components/schemas/TreeGlobalFilters'
builds:
$ref: '#/components/schemas/TreeLocalFilters'
boots:
$ref: '#/components/schemas/TreeLocalFilters'
tests:
$ref: '#/components/schemas/TreeLocalFilters'
required:
- all
- builds
- boots
- tests
title: TreeFilters
type: object
TreeGlobalFilters:
properties:
configs:
items:
type: string
title: Configs
type: array
architectures:
items:
type: string
title: Architectures
type: array
compilers:
items:
type: string
title: Compilers
type: array
required:
- configs
- architectures
- compilers
title: TreeGlobalFilters
type: object
TreeLocalFilters:
properties:
issues:
items:
type: string
title: Issues
type: array
required:
- issues
title: TreeLocalFilters
type: object
securitySchemes:
basicAuth:
Expand Down
Loading

0 comments on commit 22eeefc

Please sign in to comment.