Skip to content

TRT-2737: Rewrite test analysis queries to use test_daily_totals and test_cumulative_summaries#3747

Open
mstaeble wants to merge 1 commit into
openshift:mainfrom
mstaeble:trt-2737-phase1-consumer-rewrite
Open

TRT-2737: Rewrite test analysis queries to use test_daily_totals and test_cumulative_summaries#3747
mstaeble wants to merge 1 commit into
openshift:mainfrom
mstaeble:trt-2737-phase1-consumer-rewrite

Conversation

@mstaeble

@mstaeble mstaeble commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Rewrites all 4 test analysis consumers to query the new partitioned tables instead of the legacy test_analysis_by_job_by_dates table:
    • test_daily_totals for per-day breakdowns (overall, by-job, by-variant endpoints)
    • test_cumulative_summaries for range aggregation (QueryTestAnalysis pass rate)
  • Variant filtering joins through prow_jobs.variant_combination_id to the variant_combinations table
  • Removes the prow_test_analysis_by_variant_14d_view (a regular view with a single consumer, inlined into Go code) and the unused testAnalysisByJobMatView constant
  • The test_analysis_by_job_by_dates table 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 production

Benchmark results (staging, warm cache)

Consumer Old table New query Table used
Overall (C1) 119ms 34ms test_daily_totals
By Job (C2) 23ms 110ms test_daily_totals
By Variant (C3) 40+ seconds 147ms test_daily_totals
Pass Rate (C4) 19ms 41ms test_cumulative_summaries

The variant endpoint (/api/tests/analysis/variants) improves from 40+ seconds to 147ms because it now queries the partitioned test_daily_totals table joined to the small variant_combinations table via integer FK, instead of scanning the prow_test_analysis_by_variant_14d_view which joined test_analysis_by_job_by_dates to prow_jobs via a text-based job_name match.

Correctness verification (staging)

  • Cumulative query (C4): Exact match with equivalent test_daily_totals SUM query (332 successes, 365 runs, 90.96% pass rate)
  • Overall/ByJob: Results match the old table on shared dates. Where differences exist, they are due to different job coverage between the BQ-fed old table and the PG-native 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.
  • ByVariant: 894 rows across 93 distinct variant names, all data validated (positive counts, percentages 0-100)
  • Variant filtering: Both EXISTS (allowed) and NOT EXISTS (blocked) patterns verified. Allowed filter correctly restricts to matching variants; blocked filter correctly excludes.

Behavioral changes

  1. Date boundary filtering shifts from a sliding timestamp window (NOW() - '14 days'::interval against a TIMESTAMP WITH TIME ZONE column) to calendar-day boundaries (date >= ? against a DATE column). 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.

  2. Overall analysis now respects reportEnd. Previously, GetTestAnalysisOverallFromDB ignored the reportEnd parameter and always used time.Now(), causing the overall series to drift from the job/variant series on historical (pinned-date) reports. It now uses reportEnd consistently with the other two endpoints.

  3. 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 lint passes
  • make test passes (Go + JS)
  • make e2e passes
  • go vet ./pkg/... clean
  • Benchmarked all 4 consumer queries on staging with and without variant filters
  • Verified correctness: cumulative query exact match, daily query parity with old table on shared data
  • Deployed to sippy-staging, verified all API response times under 5 seconds
  • Independent isolated code review found no bugs

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Test analysis now consistently applies allow/block variant filtering across overall, job-level, and variant-level reports.
    • Analyses enforce a clearer 14-day reporting window with stricter date bounds.
    • Overall and job-level reports use a unified calculation approach for more consistent aggregation.
  • Bug Fixes
    • Corrected SQL parameter binding to ensure report accuracy.
    • Updated pass-rate calculations to derive current runs/successes from cumulative daily data.
    • Adjusted variant-level aggregation to use a direct query path (instead of a dedicated view).
  • Tests
    • Added unit tests covering allowed, blocked, mixed, and irrelevant variant filter extraction.
    • Updated date handling in test analysis results to use a calendar date type.

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Pipeline controller notification
This repo is configured to use the pipeline controller. Second-stage tests will be triggered either automatically or after lgtm label is added, depending on the repository configuration. The pipeline controller will automatically detect which contexts are required and will utilize /test Prow commands to trigger the second stage.

For optional jobs, comment /test ? to see a list of all defined jobs. To trigger manually all jobs from second stage use /pipeline required command.

This repository is configured in: automatic mode

@openshift-ci-robot

openshift-ci-robot commented Jul 8, 2026

Copy link
Copy Markdown

@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.

Details

In response to this:

Summary

  • Rewrites 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 through variant_combinations
  • Removes the prow_test_analysis_by_variant_14d_view (a regular view with a single consumer, inlined into Go code)
  • The test_analysis_by_job_by_dates table 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 production

Benchmark results (staging, warmed, release 4.19)

Consumer Before After
Overall (C1) 32ms 15ms
By Job (C2) 23ms 22ms
By Variant (C3) 41.5s 33ms
Pass Rate (C4) 20ms 11ms

The variant endpoint (/api/tests/analysis/variants) improves from 41.5s to 33ms because it now joins the small variant_combinations table via integer FK instead of scanning prow_jobs via a text-based join on job_name.

Behavioral changes

  1. Date boundary filtering shifts from a sliding timestamp window (NOW() - '14 days'::interval against a TIMESTAMP WITH TIME ZONE column) to calendar-day boundaries (summary_date >= ? against a DATE column). 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.

  2. Overall analysis now respects reportEnd. Previously, GetTestAnalysisOverallFromDB ignored the reportEnd parameter and always used time.Now(), causing the overall series to drift from the job/variant series on historical (pinned-date) reports. It now uses reportEnd consistently with the other two endpoints.

  3. 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 lint passes (0 issues)
  • make test passes (Go + JS)
  • make e2e passes (108 tests, 0 failures)
  • go vet ./pkg/... clean
  • Benchmarked all 4 consumer queries on staging with and without variant filters
  • Deployed to sippy-staging, verified all API response times under 5 seconds
  • Independent isolated code review found no bugs

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.

@openshift-ci openshift-ci Bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 8, 2026
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jul 8, 2026
@openshift-ci

openshift-ci Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@mstaeble, you've reached your PR review limit, so we couldn't start this review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 857455cf-0871-424c-9f58-9ed9b3d605f9

📥 Commits

Reviewing files that changed from the base of the PR and between ee5ecff and 6c8910f.

📒 Files selected for processing (6)
  • pkg/api/job_runs.go
  • pkg/api/test_analysis.go
  • pkg/api/test_analysis_test.go
  • pkg/db/query/test_queries.go
  • pkg/db/views.go
  • pkg/flags/postgres_benchmarking_test.go

Walkthrough

Test 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.

Changes

Test analysis reporting

Layer / File(s) Summary
Shared analysis queries and variant filtering
pkg/api/test_analysis.go, pkg/api/test_analysis_test.go
Adds shared aggregation and base-query helpers, rewrites overall, job, and variant analysis queries, changes CountByDate.Date to civil.Date, and tests variant filter extraction.
Cumulative analysis SQL and callers
pkg/db/query/test_queries.go, pkg/api/job_runs.go, pkg/flags/postgres_benchmarking_test.go
Calculates current metrics from cumulative summaries and updates production and benchmark callers for the revised parameter order.
Retire obsolete analysis views
pkg/db/views.go
Removes registration and SQL definitions for the obsolete variant analysis views.

Estimated code review effort: 4 (Complex) | ~45 minutes

Suggested labels: approved, lgtm, ok-to-test

Suggested reviewers: dgoodwin, petr-muller, deads2k, sosiouxme, neisw

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
Loading
🚥 Pre-merge checks | ✅ 18 | ❌ 3

❌ Failed checks (3 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Go Error Handling ⚠️ Warning Rewritten test-analysis/query paths return raw db errors (return nil, err) without fmt.Errorf(...%w) context. Wrap DB/query failures with function context via fmt.Errorf("...: %w", err) before returning.
Test Coverage For New Features ⚠️ Warning buildCollapsedMatViewSQL is new pure logic in pkg/db/views.go and has no unit test; existing views tests only cover matview ordering. Add a unit test for the collapsed-matview SQL builder, and add assertion-based tests for the rewritten query logic if needed.
✅ Passed checks (18 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: rewriting test analysis queries to use the new daily and cumulative tables.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Sql Injection Prevention ✅ Passed PASS: New SQL paths use bind placeholders; the only string-built SQL uses fixed constants (view names/exclusions), not user input.
Excessive Css In React Should Use Styles ✅ Passed PR only changes Go backend files; no React components or inline CSS are touched, so this style check is not applicable.
Single Responsibility And Clear Naming ✅ Passed The refactor keeps test-analysis code cohesive, and the new helpers/types are narrowly named and single-purpose.
Feature Documentation ✅ Passed No docs/features page covers test analysis; the only feature doc present is unrelated, so there was nothing relevant to update.
Stable And Deterministic Test Names ✅ Passed No Ginkgo titles were added; the new tests use static table-driven subtest names and benchmark case labels, with no dynamic values in titles.
Test Structure And Quality ✅ Passed No Ginkgo/cluster-style tests were added; the only new test is a small table-driven unit test with no cleanup or timeout concerns, and it matches repo patterns.
Microshift Test Compatibility ✅ Passed Diff adds only a unit test and benchmarks; no new Ginkgo e2e tests or MicroShift-unsupported APIs/features were introduced.
Single Node Openshift (Sno) Test Compatibility ✅ Passed No new Ginkgo e2e tests were added; the only new test is a unit test and the modified _test.go file is a benchmark suite.
Topology-Aware Scheduling Compatibility ✅ Passed Only query/view/test Go files changed; no deployment manifests, controllers, or scheduling constraints were added.
Ote Binary Stdout Contract ✅ Passed No changed file adds main/init/TestMain/BeforeSuite/RunSpecs stdout writes; the only fmt.Print* calls are inside benchmark/test helpers, which are allowed.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed No new Ginkgo e2e tests were added; changed tests are unit/benchmark only, and the diff has no It/Describe/Context/When additions.
No-Weak-Crypto ✅ Passed No MD5/SHA1/DES/RC4/3DES/Blowfish/ECB, custom crypto, or secret/token comparisons were added; the diff is DB query/view logic only.
Container-Privileges ✅ Passed PR changes only Go/test files; no container/K8s manifests or privilege settings like privileged, hostNetwork, or allowPrivilegeEscalation were added.
No-Sensitive-Data-In-Logs ✅ Passed No new logging of secrets/PII/internal hosts was added; the only changed log line is generic, and benchmark output prints counts only.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@openshift-ci

openshift-ci Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: mstaeble
Once this PR has been reviewed and has the lgtm label, please assign deads2k for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@mstaeble

mstaeble commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@mstaeble

mstaeble commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Full review finished.


Your plan includes PR reviews subject to rate limits. More reviews will be available in 54 minutes.

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1

🧹 Nitpick comments (4)
pkg/api/test_analysis.go (3)

26-40: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add a unit test for extractVariantFilters.

It's pure, branch-heavy logic (nil guard, Not vs 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 value

Extract the repeated 14-day window into a named constant.

reportEnd.Add(-24*14*time.Hour) is duplicated in three call sites; a const testAnalysisWindow = 14 * 24 * time.Hour (or reportEnd.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 value

Rename selectColumns and add a godoc; the name is ambiguous in package api.

selectColumns in 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 win

Orphaned view will persist on existing databases.

With PostgresViews now empty, syncPostgresViews no longer issues DROP 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 of test_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

📥 Commits

Reviewing files that changed from the base of the PR and between 26fa798 and 66d90ba.

📒 Files selected for processing (3)
  • pkg/api/test_analysis.go
  • pkg/db/query/test_queries.go
  • pkg/db/views.go

Comment thread pkg/api/test_analysis.go Outdated
@mstaeble
mstaeble force-pushed the trt-2737-phase1-consumer-rewrite branch from 66d90ba to 6db2dee Compare July 8, 2026 03:17
@openshift-ci openshift-ci Bot added the ready-for-human-review Indicates a PR has been reviewed by automated tools and is ready for human review label Jul 8, 2026
@mstaeble
mstaeble marked this pull request as ready for review July 8, 2026 03:24
@openshift-ci openshift-ci Bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 8, 2026
@openshift-ci
openshift-ci Bot requested review from deads2k and sosiouxme July 8, 2026 03:25
@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Scheduling required tests:
/test e2e

@mstaeble
mstaeble force-pushed the trt-2737-phase1-consumer-rewrite branch 3 times, most recently from 44439e7 to a8cb571 Compare July 13, 2026 12:38
@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Scheduling required tests:
/test e2e

@mstaeble mstaeble changed the title TRT-2737: Rewrite test analysis queries to use test_daily_summaries [WIP] TRT-2737: Rewrite test analysis queries to use test_daily_summaries Jul 14, 2026
@openshift-ci openshift-ci Bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 14, 2026
@mstaeble
mstaeble marked this pull request as draft July 14, 2026 13:45
@mstaeble
mstaeble force-pushed the trt-2737-phase1-consumer-rewrite branch from a8cb571 to 0956882 Compare July 14, 2026 14:19
@mstaeble

Copy link
Copy Markdown
Contributor Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Full review finished.

@coderabbitai coderabbitai Bot left a comment

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.

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

📥 Commits

Reviewing files that changed from the base of the PR and between f54254b and 0956882.

📒 Files selected for processing (6)
  • pkg/api/job_runs.go
  • pkg/api/test_analysis.go
  • pkg/api/test_analysis_test.go
  • pkg/db/query/test_queries.go
  • pkg/db/views.go
  • pkg/flags/postgres_benchmarking_test.go

Comment thread pkg/api/test_analysis.go
Comment thread pkg/api/test_analysis.go Outdated
Comment thread pkg/db/query/test_queries.go
Comment thread pkg/db/views.go
@mstaeble mstaeble changed the title [WIP] TRT-2737: Rewrite test analysis queries to use test_daily_summaries [WIP] TRT-2737: Rewrite test analysis queries to use test_daily_totals and test_cumulative_summaries Jul 14, 2026
@mstaeble
mstaeble force-pushed the trt-2737-phase1-consumer-rewrite branch from e950d77 to 0bf1161 Compare July 15, 2026 01:37
@mstaeble mstaeble changed the title [WIP] TRT-2737: Rewrite test analysis queries to use test_daily_totals and test_cumulative_summaries TRT-2737: Rewrite test analysis queries to use test_daily_totals and test_cumulative_summaries Jul 15, 2026
@mstaeble
mstaeble marked this pull request as ready for review July 15, 2026 01:39
@openshift-ci openshift-ci Bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 15, 2026
@openshift-ci
openshift-ci Bot requested review from dgoodwin and petr-muller July 15, 2026 01:39
@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Scheduling required tests:
/test e2e

@mstaeble
mstaeble force-pushed the trt-2737-phase1-consumer-rewrite branch from 0bf1161 to ee5ecff Compare July 20, 2026 15:01
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>
@mstaeble
mstaeble force-pushed the trt-2737-phase1-consumer-rewrite branch from ee5ecff to 6c8910f Compare July 20, 2026 15:08
@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Scheduling required tests:
/test e2e

@openshift-ci

openshift-ci Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

@mstaeble: all tests passed!

Full PR test history. Your PR dashboard.

Details

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 kubernetes-sigs/prow repository. I understand the commands that are listed here.

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

Labels

jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. ready-for-human-review Indicates a PR has been reviewed by automated tools and is ready for human review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants