TRT-2737: Rewrite test analysis queries to use test_daily_summaries#3747
TRT-2737: Rewrite test analysis queries to use test_daily_summaries#3747mstaeble wants to merge 1 commit into
Conversation
|
Pipeline controller notification For optional jobs, comment This repository is configured in: automatic mode |
|
@mstaeble: This pull request references TRT-2737 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "5.0.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
Skipping CI for Draft Pull Request. |
|
Warning Review limit reached
Next review available in: 29 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Repository YAML (base), Central YAML (inherited) Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (4)
WalkthroughTest analysis queries are refactored to source data from ChangesTest analysis query source refactor
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 19 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (19 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: mstaeble The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@coderabbitai full review |
✅ Action performedFull review finished. Your plan includes PR reviews subject to rate limits. More reviews will be available in 54 minutes. |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (4)
pkg/api/test_analysis.go (3)
26-40: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd a unit test for
extractVariantFilters.It's pure, branch-heavy logic (nil guard,
Notvs allowed/blocked partitioning) that's trivially testable without touching storage. As per coding guidelines, new Go functions should include unit tests.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pkg/api/test_analysis.go` around lines 26 - 40, Add unit tests for extractVariantFilters to cover its pure branching behavior: nil input should return nil slices, variants items with Not=false should populate allowed, and variants items with Not=true should populate blocked while ignoring non-variants fields. Place the tests alongside test_analysis.go and reference extractVariantFilters and filter.Filter so the cases remain easy to locate if the implementation changes.Source: Coding guidelines
80-80: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueExtract the repeated 14-day window into a named constant.
reportEnd.Add(-24*14*time.Hour)is duplicated in three call sites; aconst testAnalysisWindow = 14 * 24 * time.Hour(orreportEnd.AddDate(0, 0, -14)) is clearer and avoids drift if the window changes.Also applies to: 113-113, 164-164
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pkg/api/test_analysis.go` at line 80, The repeated 14-day lookback in the test analysis query calls should be extracted into a shared named constant or helper. Update the call sites in testAnalysisBaseQuery usage to reference a single testAnalysisWindow definition (or use reportEnd.AddDate for the same intent) so the window value is defined once and reused consistently across the three locations.
62-64: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueRename
selectColumnsand add a godoc; the name is ambiguous in packageapi.
selectColumnsin a large package reads like a generic accessor, but it actually appends the shared aggregate columns to the supplied ones. A more specific name (e.g.withAggColumns) plus a one-line godoc would make the intent clear and reduce collision risk.As per path instructions: "Name each function succinctly but accurately indicating its purpose relative to its package or receiver... include a brief godoc if the name alone would not make the purpose obvious."
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pkg/api/test_analysis.go` around lines 62 - 64, Rename selectColumns to a more specific helper name that reflects its behavior of appending the shared aggregate columns to caller-supplied columns, and add a one-line godoc for the new name so its purpose is clear in package api; update any call sites in testAnalysis helpers to use the new symbol.Source: Path instructions
pkg/db/views.go (1)
89-89: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick winOrphaned view will persist on existing databases.
With
PostgresViewsnow empty,syncPostgresViewsno longer issuesDROP VIEW IF EXISTS prow_test_analysis_by_variant_14d_view. Existing databases will retain the stale view, which could confuse direct queries or block future drops oftest_analysis_by_job_by_dates. Consider adding a one-time migration to drop it before the follow-up PR removes the underlying table.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pkg/db/views.go` at line 89, The empty PostgresViews slice means syncPostgresViews will no longer drop the stale prow_test_analysis_by_variant_14d_view, so existing databases can retain an orphaned view. Add a one-time migration or startup cleanup that explicitly drops this view before the underlying table removal, and keep the change localized around PostgresViews and syncPostgresViews so the old object is removed safely.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pkg/api/test_analysis.go`:
- Around line 152-167: The query built in test_analysis.go’s inner DB chain is
grouping on unnest(vc.variants), which PostgreSQL rejects. Move the variant
expansion into a LATERAL join in the same query builder path, then reference the
unnested alias in Select and Group instead of calling unnest() directly in
Group. Keep the change localized to the inner :=
dbc.DB.Table("test_daily_summaries tds") query and its Join/Group clauses so the
per-variant rows are produced correctly.
---
Nitpick comments:
In `@pkg/api/test_analysis.go`:
- Around line 26-40: Add unit tests for extractVariantFilters to cover its pure
branching behavior: nil input should return nil slices, variants items with
Not=false should populate allowed, and variants items with Not=true should
populate blocked while ignoring non-variants fields. Place the tests alongside
test_analysis.go and reference extractVariantFilters and filter.Filter so the
cases remain easy to locate if the implementation changes.
- Line 80: The repeated 14-day lookback in the test analysis query calls should
be extracted into a shared named constant or helper. Update the call sites in
testAnalysisBaseQuery usage to reference a single testAnalysisWindow definition
(or use reportEnd.AddDate for the same intent) so the window value is defined
once and reused consistently across the three locations.
- Around line 62-64: Rename selectColumns to a more specific helper name that
reflects its behavior of appending the shared aggregate columns to
caller-supplied columns, and add a one-line godoc for the new name so its
purpose is clear in package api; update any call sites in testAnalysis helpers
to use the new symbol.
In `@pkg/db/views.go`:
- Line 89: The empty PostgresViews slice means syncPostgresViews will no longer
drop the stale prow_test_analysis_by_variant_14d_view, so existing databases can
retain an orphaned view. Add a one-time migration or startup cleanup that
explicitly drops this view before the underlying table removal, and keep the
change localized around PostgresViews and syncPostgresViews so the old object is
removed safely.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository YAML (base), Central YAML (inherited)
Review profile: CHILL
Plan: Enterprise
Run ID: 6bb75d8f-f170-4449-afb6-40fdec1ca2d3
📒 Files selected for processing (3)
pkg/api/test_analysis.gopkg/db/query/test_queries.gopkg/db/views.go
Rewrite all 4 test analysis consumers to query test_daily_summaries directly instead of test_analysis_by_job_by_dates, using variant_combination_id for efficient variant filtering. The variant endpoint (/api/tests/analysis/variants) improves from 41.5s to 33ms by joining the small variant_combinations table via integer FK instead of scanning prow_jobs via text join. The prow_test_analysis_by_variant_14d_view (a regular view with one consumer) is removed in favor of an inline query. Behavioral changes: - Date filtering uses calendar-day boundaries (DATE column) instead of a sliding timestamp window, which may include one additional day at the boundary. - GetTestAnalysisOverallFromDB now respects the reportEnd parameter instead of always using time.Now(). - Variant analysis window aligned from 15 days to 14 days, consistent with the other two endpoints. The test_analysis_by_job_by_dates table and its BQ loader are kept running for now. They will be removed in a follow-up PR once the new queries are verified in production. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
66d90ba to
6db2dee
Compare
|
Scheduling required tests: |
|
@mstaeble: all tests passed! Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
Summary
test_daily_summariesdirectly instead oftest_analysis_by_job_by_dates, usingvariant_combination_idfor efficient variant filtering throughvariant_combinationsprow_test_analysis_by_variant_14d_view(a regular view with a single consumer, inlined into Go code)test_analysis_by_job_by_datestable and its BQ loader are kept running for now and will be removed in a follow-up PR once the new queries are verified in productionBenchmark results (staging, warmed, release 4.19)
The variant endpoint (
/api/tests/analysis/variants) improves from 41.5s to 33ms because it now joins the smallvariant_combinationstable via integer FK instead of scanningprow_jobsvia a text-based join onjob_name.Behavioral changes
Date boundary filtering shifts from a sliding timestamp window (
NOW() - '14 days'::intervalagainst aTIMESTAMP WITH TIME ZONEcolumn) to calendar-day boundaries (summary_date >= ?against aDATEcolumn). This means the 14-day lookback always includes full calendar days rather than depending on time-of-day. In practice, this may include one additional day of data at the boundary.Overall analysis now respects
reportEnd. Previously,GetTestAnalysisOverallFromDBignored thereportEndparameter and always usedtime.Now(), causing the overall series to drift from the job/variant series on historical (pinned-date) reports. It now usesreportEndconsistently with the other two endpoints.Variant analysis window aligned to 14 days. The old variant view used a 15-day lookback while the other endpoints used 14 days. All three now use 14 days consistently.
Test plan
make lintpasses (0 issues)make testpasses (Go + JS)make e2epasses (108 tests, 0 failures)go vet ./pkg/...cleanSummary by CodeRabbit
New Features
Bug Fixes