TRT-2737: Rewrite test analysis queries to use test_daily_totals and test_cumulative_summaries#3747
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: 54 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 (6)
WalkthroughTest analysis endpoints now query daily totals and variant combinations directly, with shared date, aggregation, and variant-filter helpers. The raw analysis query uses cumulative summaries, callers use revised parameters, and obsolete analysis view definitions are removed. ChangesTest analysis reporting
Estimated code review effort: 4 (Complex) | ~45 minutes Suggested labels: Suggested reviewers: Sequence Diagram(s)sequenceDiagram
participant AnalysisAPI
participant DailyTotals
participant ProwJobs
participant VariantCombinations
AnalysisAPI->>DailyTotals: Query date-bounded test totals
DailyTotals->>ProwJobs: Join job and variant-combination identifiers
ProwJobs->>VariantCombinations: Apply allowed and blocked variant filters
VariantCombinations-->>AnalysisAPI: Return grouped analysis aggregates
🚥 Pre-merge checks | ✅ 18 | ❌ 3❌ Failed checks (3 warnings)
✅ Passed checks (18 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
66d90ba to
6db2dee
Compare
|
Scheduling required tests: |
44439e7 to
a8cb571
Compare
|
Scheduling required tests: |
a8cb571 to
0956882
Compare
|
@coderabbitai full review |
✅ Action performedFull review finished. |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 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 44-52: Update the variant-filter flow centered on
extractVariantFilters and applyVariantCombinationFilters to preserve and honor
each Filter.LinkOperator when combining multiple allowed or blocked variants.
Ensure OR semantics, such as Platform:aws plus Platform:gcp, are supported
consistently with the generic filter path, while retaining the existing
conjunction behavior where requested.
- Around line 70-81: Normalize the report window to calendar days before
constructing the test-analysis queries: truncate the value returned by
s.GetReportEnd() to the start of its day, or cast the SQL comparison bound to
::date. Apply this consistently to the reportEnd-based query paths, including
testAnalysisBaseQuery, so the 14-day range does not exclude the first calendar
day.
In `@pkg/db/query/test_queries.go`:
- Around line 62-82: Add inline SQL comments within QueryTestAnalysis explaining
that the LEFT JOIN aliases s to the prior-day cumulative snapshot for delta
calculation, and that the WHERE e.date subquery selects the latest cumulative
snapshot for the requested release. Keep the query logic unchanged.
In `@pkg/db/views.go`:
- Line 89: Update the migration logic around syncPostgresViews to explicitly
drop retired regular views with a DROP VIEW IF EXISTS statement when they are
removed from PostgresViews. Ensure the migration targets the retired view by its
escaped identifier and preserves reconciliation for views still present in the
slice.
🪄 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: 9a48cf12-457b-4a76-983a-acd8b2d41027
📒 Files selected for processing (6)
pkg/api/job_runs.gopkg/api/test_analysis.gopkg/api/test_analysis_test.gopkg/db/query/test_queries.gopkg/db/views.gopkg/flags/postgres_benchmarking_test.go
e950d77 to
0bf1161
Compare
|
Scheduling required tests: |
0bf1161 to
ee5ecff
Compare
Replace the legacy test_analysis_by_job_by_dates table and prow_test_analysis_by_variant_14d_view with direct queries against the new partitioned tables: - test_daily_totals for per-day test analysis (overall, by-job, by-variant views) - test_cumulative_summaries for range aggregation (QueryTestAnalysis) Variant filtering joins through prow_jobs.variant_combination_id instead of the dropped test_daily_summaries.variant_combination_id column. The old table and its BQ loader remain in place for safe rollback; removal is planned for a follow-up PR. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> TRT-2737: Use civil.Date for date boundaries and add SQL comments Normalize report windows to calendar-day boundaries using civil.Date instead of time.Time, eliminating time-component ambiguity when comparing against DATE columns. Add inline comments to the cumulative prefix-sum query explaining the self-join pattern. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
ee5ecff to
6c8910f
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_analysis_by_job_by_datestable:test_daily_totalsfor per-day breakdowns (overall, by-job, by-variant endpoints)test_cumulative_summariesfor range aggregation (QueryTestAnalysispass rate)prow_jobs.variant_combination_idto thevariant_combinationstableprow_test_analysis_by_variant_14d_view(a regular view with a single consumer, inlined into Go code) and the unusedtestAnalysisByJobMatViewconstanttest_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, warm cache)
The variant endpoint (
/api/tests/analysis/variants) improves from 40+ seconds to 147ms because it now queries the partitionedtest_daily_totalstable joined to the smallvariant_combinationstable via integer FK, instead of scanning theprow_test_analysis_by_variant_14d_viewwhich joinedtest_analysis_by_job_by_datestoprow_jobsvia a text-basedjob_namematch.Correctness verification (staging)
test_daily_totalsSUM query (332 successes, 365 runs, 90.96% pass rate)test_daily_totals(e.g., 264 vs 273 jobs on 2026-07-12). On the single shared job with a count difference (...upgrade-from-stable-4.19...: old=1 run, new=2 runs), the difference is a BQ/PG loader timing cutoff, not a logic bug.EXISTS(allowed) andNOT EXISTS(blocked) patterns verified. Allowed filter correctly restricts to matching variants; blocked filter correctly excludes.Behavioral changes
Date boundary filtering shifts from a sliding timestamp window (
NOW() - '14 days'::intervalagainst aTIMESTAMP WITH TIME ZONEcolumn) to calendar-day boundaries (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 lintpassesmake testpasses (Go + JS)make e2epassesgo vet ./pkg/...clean🤖 Generated with Claude Code
Summary by CodeRabbit