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 enforces allow/block variant filtering across overall, job-level, and variant-level reports.
    • Reporting window tightened with clearer 14-day date bounds.
    • Overall and job-level summaries now use a more unified aggregation approach.
  • Bug Fixes
    • Pass-rate calculations now derive current runs/successes from cumulative daily snapshots (with prior-day baseline).
    • Corrected SQL parameter binding to ensure accurate results.
    • Variant-level reporting no longer relies on the previously registered view.
  • Tests
    • Added unit coverage for allowed/blocked/mixed variant filter extraction.
    • Updated result date handling to 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

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Enterprise

Run ID: 4fda3416-92d8-4b3d-8f40-871eed6f6f6c

📥 Commits

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

📒 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
🚧 Files skipped from review as they are similar to previous changes (5)
  • pkg/api/job_runs.go
  • pkg/api/test_analysis_test.go
  • pkg/db/query/test_queries.go
  • pkg/flags/postgres_benchmarking_test.go
  • pkg/api/test_analysis.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 views 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

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

Sequence Diagram(s)

sequenceDiagram
  participant AnalysisAPI
  participant TestDailyTotals
  participant ProwJobs
  participant VariantCombinations
  AnalysisAPI->>TestDailyTotals: Query date-bounded test totals
  TestDailyTotals->>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 | ✅ 19 | ❌ 2

❌ Failed checks (2 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.
Test Coverage For New Features ⚠️ Warning Only extractVariantFilters has a unit test; the new pure helper withAggColumns and rewritten analysis/query paths lack focused tests, and benchmarks only log results. Add unit/regression tests for withAggColumns and the rewritten analysis/query functions (or refactor SQL assembly into testable pure helpers).
✅ Passed checks (19 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: rewriting test analysis queries to use the new 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.
Go Error Handling ✅ Passed Changed Go code checks nil filters, handles DB errors, and introduces no ignored errors or panic paths.
Sql Injection Prevention ✅ Passed The new SQL paths bind release, test, job, and variant values via placeholders; no user input is concatenated into SQL.
Excessive Css In React Should Use Styles ✅ Passed The only changed React inline style is style={getVariantStyle(variant)}, and that helper returns a single dynamic color prop—not an excessive inline CSS block.
Single Responsibility And Clear Naming ✅ Passed The new helpers and query functions are narrowly scoped, names are specific, and parameter counts stay modest; no generic manager/handler-style abstraction was introduced.
Feature Documentation ✅ Passed No docs/features test-analysis doc exists; the only feature doc there is unrelated job-analysis-symptoms.md, so no relevant update was needed.
Stable And Deterministic Test Names ✅ Passed No Ginkgo titles were added; the new/modified test names are static literals like "nil filter" and "APITestAnalysisOverall", with no dynamic data.
Test Structure And Quality ✅ Passed No Ginkgo tests were added or changed; the new test is plain table-driven testing code and the modified benchmark file is standard testing benchmarks, so this Ginkgo-specific check is N/A.
Microshift Test Compatibility ✅ Passed Only a plain Go unit test was added; no new Ginkgo e2e tests or MicroShift-unsupported OpenShift APIs/features appear in the diff.
Single Node Openshift (Sno) Test Compatibility ✅ Passed PASS: The patch adds only a plain Go unit test and query/code changes; no Ginkgo e2e tests or SNO-sensitive multi-node assumptions were introduced.
Topology-Aware Scheduling Compatibility ✅ Passed Only API/query helpers, DB views, and tests changed; no deployment manifests, controllers, or scheduling constraints were modified.
Ote Binary Stdout Contract ✅ Passed No stdout writes were added in main/init/TestMain/suite setup; the only fmt.Print* in the diff is inside benchmark helpers, which the contract allows.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed No new Ginkgo e2e tests were added; the new unit/benchmark tests show no IPv4 literals or external connectivity needs.
No-Weak-Crypto ✅ Passed No MD5/SHA1/DES/RC4/ECB/custom-crypto or non-constant-time secret comparisons found in the changed files.
Container-Privileges ✅ Passed PR only changes Go source/tests; no manifest files or privilege flags were added in the diff.
No-Sensitive-Data-In-Logs ✅ Passed No new sensitive-data logging found; added logs are generic errors/counts and query names, with no passwords/tokens/PII/session IDs exposed.
✨ 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 2 times, most recently from ee5ecff to 6c8910f Compare July 20, 2026 15:08
@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 6c8910f to 75b25f1 Compare July 21, 2026 17:47
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 75b25f1 to bcccb4c Compare July 21, 2026 19:35
@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Scheduling required tests:
/test e2e

@openshift-ci

openshift-ci Bot commented Jul 21, 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