Skip to content

Commit

Permalink
fix: tests_or_boots out of scope (#620)
Browse files Browse the repository at this point in the history
The way the unknown issues counting was implemented, it could update
tests_or_boots when it was out of scope, causing the backend to throw
an exception. This implementation solves this issue.
  • Loading branch information
murilx authored Nov 28, 2024
1 parent ec0a9d4 commit 2c39e86
Showing 1 changed file with 13 additions and 18 deletions.
31 changes: 13 additions & 18 deletions backend/kernelCI_app/views/hardwareDetailsView.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

DEFAULT_DAYS_INTERVAL = 3
SELECTED_HEAD_TREE_VALUE = 'head'
STATUS_FAILED_VALUE = "FAIL"


def properties2List(d, keys):
Expand Down Expand Up @@ -82,7 +83,7 @@ def get_history(record):
}


def update_issues(issues, issue):
def update_known_issues(issues, issue):
existing_issue = issues.get(issue["id"])
if existing_issue:
existing_issue["incidents_info"]["incidentsCount"] += 1
Expand Down Expand Up @@ -131,11 +132,13 @@ def is_record_selected(record, tree):
return record["build__checkout__git_commit_hash"] == tree["git_commit_hash"]


def update_unknown_issues(tests_or_boots, status, builds, is_build_processed, build_is_valid):
if status == "FAIL":
tests_or_boots["failedWithUnknownIssues"] += 1
if not is_build_processed and build_is_valid is False:
builds["failedWithUnknownIssues"] += 1
def update_issues(record, task, is_failed_task):
has_issue = bool(record["build__incidents__issue__id"])
if has_issue:
currentIssue = get_details_issue(record)
update_known_issues(task["issues"], currentIssue)
elif is_failed_task:
task["failedWithUnknownIssues"] += 1


# disable django csrf protection https://docs.djangoproject.com/en/5.0/ref/csrf/
Expand Down Expand Up @@ -202,7 +205,6 @@ def sanitize_records(self, records, selected_trees, filters):
continue

build_id = r["build_id"]
issue_id = r["build__incidents__issue__id"]
status = r["status"]
table_test = "boot" if is_boot(r) else "test"

Expand Down Expand Up @@ -231,23 +233,16 @@ def sanitize_records(self, records, selected_trees, filters):
tests_or_boots["archSummary"][archKey] = archSummary
archSummary["status"][status] += 1

is_build_processed = build_id in processed_builds
if not is_build_processed:
update_issues(r, tests_or_boots, status == STATUS_FAILED_VALUE)

if build_id not in processed_builds:
processed_builds.add(build_id)
build = get_build(r, current_tree["index"])

if len(filters_map['build']) == 0 or self.pass_in_filters(build, filters_map['build']):
builds["items"].append(build)

if issue_id:
currentIssue = get_details_issue(r)
update_issues(builds["issues"], currentIssue)
if not jump_test:
update_issues(tests_or_boots["issues"], currentIssue)
else:
update_unknown_issues(
tests_or_boots, r["status"], builds, is_build_processed, r["build__valid"]
)
update_issues(r, builds, r["build__valid"] is False)

builds["summary"] = create_details_build_summary(builds["items"])
properties2List(builds, ["issues"])
Expand Down

0 comments on commit 2c39e86

Please sign in to comment.