Skip to content

feat: use tree_tests_rollup for tree details summary#1842

Open
gustavobtflores wants to merge 3 commits intokernelci:mainfrom
gustavobtflores:feat/tree-details-denormalization-view
Open

feat: use tree_tests_rollup for tree details summary#1842
gustavobtflores wants to merge 3 commits intokernelci:mainfrom
gustavobtflores:feat/tree-details-denormalization-view

Conversation

@gustavobtflores
Copy link
Copy Markdown
Contributor

@gustavobtflores gustavobtflores commented Apr 6, 2026

Description

Tree details summary now reads pre-aggregated test and boot data from tree_tests_rollup instead of scanning per-test rows from a single large query. Builds still come from a dedicated builds query. This matches the denormalized rollup model and should reduce work for the summary endpoint.

Changes

  • Add treeDetailsRollup.py helpers to normalize build rows and to apply filters, issues, and status summaries from rollup rows.
  • Refactor treeDetailsSummaryView to call both queries and process builds and rollup rows in separate sanitization paths.
  • Extend seed_test_data to build tree_tests_rollup rows from seeded tests/incidents.
  • Add TestsRollupFactory and export it from test factories.

How to test

  1. Ensure migrations/schema include tree_tests_rollup and run seed_test_data or populate database with ingester data.
  2. Call the tree details summary API for a commit that has builds and rollup data; confirm summaries and filters behave as before for representative trees.
  3. Run the backend test suite covering tree details / summary if present.

Closes #1801

@gustavobtflores gustavobtflores changed the title Feat/tree details denormalization view feat: use tree_tests_rollup for tree details summary Apr 6, 2026
@gustavobtflores gustavobtflores force-pushed the feat/tree-details-denormalization-view branch from 3f95714 to c003c95 Compare April 6, 2026 17:10
@gustavobtflores gustavobtflores force-pushed the feat/tree-details-denormalization-view branch from c003c95 to 3a35e46 Compare April 6, 2026 18:12
@gustavobtflores gustavobtflores self-assigned this Apr 6, 2026
@gustavobtflores gustavobtflores added the Backend Most or all of the changes for this issue will be in the backend code. label Apr 6, 2026
ROLLUP_TEST_ID = "rollup_test"


def normalize_build_dict(row_dict: dict) -> dict:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice touch

):
return True

if len(platform_filters) > 0 and test_platform not in platform_filters:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prefer to check if platform_filters instead of using len

if len(platform_filters) > 0 and test_platform not in platform_filters:
return True

if len(origin_filters) > 0 and test_origin not in origin_filters:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

origin_summary = instance.test_summary["origins"]
typed_summary = instance.test_summary_typed

arch_key = "%s-%s" % (build_arch, build_compiler)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we use a tuple as a key here?

lab_entry = typed_summary.labs.setdefault(test_lab, StatusCount())
setattr(lab_entry, status_name, getattr(lab_entry, status_name) + count)

if is_status_failure(status_name):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: we can avoid this conditional, and just use the value:
has_status_failure |= is_status_failure(status_name)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or even simpler, just add current test_platform to platforms_failing here

issue_comment: Optional[str],
issue_report_url: Optional[str],
starting_count_status: Optional[DatabaseStatusValues],
autoincrement: bool = True,
Copy link
Copy Markdown
Contributor

@alanpeixinho alanpeixinho Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to add this flag? Cant it be the default behaviour?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it still behaves as before because the flag defaults to True. however, I needed to reuse this function for rollup aggregations in the view, and in that context it's not appropriate to increment the status after creating the IssueTyped.

this also highlights some technical debt: a function named create_issue_typed having a hidden side effect (incrementing status values) is confusing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Backend Most or all of the changes for this issue will be in the backend code.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: denormalize tree details with rollup table to improve summary performance

2 participants