Skip to content

TRT-2821: Fall back to aggregate tables for base stats in test_details - #3847

Open
mstaeble wants to merge 1 commit into
openshift:mainfrom
mstaeble:worktree-test-details-base-stats-fallback
Open

TRT-2821: Fall back to aggregate tables for base stats in test_details#3847
mstaeble wants to merge 1 commit into
openshift:mainfrom
mstaeble:worktree-test-details-base-stats-fallback

Conversation

@mstaeble

@mstaeble mstaeble commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Introduces TestDetailsSummary as the provider return type for test details queries, replacing raw per-run rows with pre-computed per-job stats and optional individual run details.
  • Adds SummarizeTestJobRuns to group raw rows by (job, test key) into summaries, applied consistently in both BigQuery and Postgres providers.
  • Adds a fallback in QueryBaseJobRunTestStatus (Postgres provider) to populate base statistics from aggregate tables (test_cumulative_summaries for prefix-sum releases, prow_ga_raw_test_data for GA releases) when per-run data is unavailable for older base releases. Aggregate summaries have no individual JobRuns, so the UI shows stats without broken run links.
  • Refactors test_details.go report generation to work with pre-summarized data, simplifying stats aggregation and fixing a bug where per-run counts were double-aggregated.
  • Bumps BigQuery cache key prefix from V2 to V3 to avoid stale deserialization after the type change.
  • Fixes TestDetailsSummary.TestKeyStr serialization (json:"-" removed) so test key grouping survives the BQ Redis cache round-trip.

Test plan

  • Unit test for SummarizeTestJobRuns lifecycle promotion logic
  • Integration tests for aggregate fallback (prefix-sum, GA, precedence over per-run, variant filtering, multi-job, zero-delta exclusion, no-suite ownership, HAVING filter)
  • Integration tests for test details report generation (aggregate base stats, last failure tracking, flake-as-failure mode)
  • Existing integration tests updated for summarized return type
  • make test passes
  • make lint passes

Staging verification

Ran local server against staging Postgres DB and BigQuery with the branch code. Tested with explicit query parameters (5.0 sample, 4.22 base, Build and Networking components).

Postgres path: per-run base data (4.22 base)

test_details component=Build testId=openshift-tests:c19899c904fc1be7fadc2812f438dc3a
  Base: success=471, fail=0, flake=0, rate=1.0
  Sample: success=125, fail=0, flake=0, rate=1.0
  Jobs: 18, base runs: 471, sample runs: 125
  Explanations: []

Postgres path: aggregate fallback (4.17 base)

test_details component=Build testId=openshift-tests:c19899c904fc1be7fadc2812f438dc3a baseRelease=4.17
  Jobs: 16, base runs: 0 (aggregate, no individual runs)
  Server log: "no per-run base test details found, falling back to aggregate tables" release=4.17

BigQuery path (4.22 base)

test_details component=Build testId=openshift-tests:c19899c904fc1be7fadc2812f438dc3a
  Base: success (non-zero), fail, flake present
  Jobs: 25, base+sample runs present
  Explanations: []

Networking test cross-path comparison

BQ:       Base success=613, Jobs: 25
Postgres: Base success=471, Jobs: 18
(Count differences expected due to BQ having broader job coverage)

CR grid (Postgres)

60 component rows returned, regressions detected correctly.

No errors in server logs across all requests.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Component readiness reports now provide aggregated per-test and per-job summaries with detailed run information.
    • Added fallback reporting from aggregate historical data when detailed base-release results are unavailable.
    • Improved support for variant filtering, metadata, failure tracking, and flake-as-failure reporting.
  • Bug Fixes

    • Improved lifecycle aggregation and status handling across base, override, and sample results.
    • Preserved job ordering and enhanced report consistency across data sources.
  • Tests

    • Expanded integration coverage for aggregate fallbacks, Jira component propagation, failures, flakes, variants, suites, and metadata.

@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 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 29, 2026
@openshift-ci

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

@openshift-ci

openshift-ci Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mstaeble

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

The pull request process is described 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

@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 29, 2026
@mstaeble
mstaeble force-pushed the worktree-test-details-base-stats-fallback branch 3 times, most recently from 232123b to ba1a34e Compare August 1, 2026 13:08
@mstaeble mstaeble changed the title [WIP] Populate base statistics in test_details from aggregate tables TRT-2821: Fall back to aggregate tables for base stats in test_details Aug 1, 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 Aug 1, 2026
@openshift-ci-robot

openshift-ci-robot commented Aug 1, 2026

Copy link
Copy Markdown

@mstaeble: This pull request references TRT-2821 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

  • Introduces TestDetailsSummary as the provider return type for test details queries, replacing raw per-run rows with pre-computed per-job stats and optional individual run details.
  • Adds SummarizeTestJobRuns to group raw rows by (job, test key) into summaries, applied consistently in both BigQuery and Postgres providers.
  • Adds a fallback in QueryBaseJobRunTestStatus (Postgres provider) to populate base statistics from aggregate tables (test_cumulative_summaries for prefix-sum releases, prow_ga_raw_test_data for GA releases) when per-run data is unavailable for older base releases. Aggregate summaries have no individual JobRuns, so the UI shows stats without broken run links.
  • Refactors test_details.go report generation to work with pre-summarized data, simplifying stats aggregation and fixing a bug where per-run counts were double-aggregated.
  • Bumps BigQuery cache key prefix from V2 to V3 to avoid stale deserialization after the type change.

Test plan

  • Unit test for SummarizeTestJobRuns lifecycle promotion logic
  • Integration tests for aggregate fallback (prefix-sum, GA, precedence over per-run, variant filtering, multi-job, zero-delta exclusion, no-suite ownership, HAVING filter)
  • Integration tests for test details report generation (aggregate base stats, last failure tracking, flake-as-failure mode)
  • Existing integration tests updated for summarized return type
  • make test passes
  • make lint passes

@coderabbitai ignore

🤖 Generated with Claude Code

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.

@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

@openshift-ci-robot Acknowledged. The owner of TRT-2821 must set its target version to 5.0.0.

You are interacting with an AI system.

@mstaeble

mstaeble commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Full review finished.

@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

Changes

Component readiness test-detail flow

Layer / File(s) Summary
Summary data contract and aggregation
pkg/apis/api/componentreport/crstatus/types.go, pkg/apis/api/componentreport/crstatus/summarize.go, pkg/apis/api/componentreport/crstatus/summarize_test.go, pkg/api/componentreadiness/test_details.go
Introduces summarized test details and nested run records. Raw rows are grouped by job and test key with aggregated statistics and lifecycle values.
Provider summary propagation and fallback
pkg/api/componentreadiness/dataprovider/...
BigQuery and PostgreSQL providers return summaries. PostgreSQL adds GA and prefix-sum aggregate fallback with variant filtering.
Fallback wiring and report aggregation
pkg/api/componentreadiness/middleware/releasefallback/releasefallback.go, pkg/api/componentreadiness/test_details.go
Fallback storage and report generation consume summaries, nested run details, metadata, failure data, and aggregate statistics.
Fixture and integration validation
pkg/api/componentreadiness/component_report_test.go, test/integration/component_readiness_test.go
Tests validate the summary shape, lifecycle promotion, fallback precedence, filtering, metadata, and report statistics.

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

Sequence Diagram(s)

sequenceDiagram
  participant TestDetailsQuerier
  participant BigQueryProvider
  participant PostgresProvider
  participant SummarizeTestJobRuns
  participant TestDetailsReport
  TestDetailsQuerier->>BigQueryProvider: query base or sample status
  BigQueryProvider->>SummarizeTestJobRuns: pass raw job-run rows
  SummarizeTestJobRuns-->>BigQueryProvider: return TestDetailsSummary values
  TestDetailsQuerier->>PostgresProvider: query base status
  PostgresProvider->>PostgresProvider: use detailed data or aggregate fallback
  PostgresProvider-->>TestDetailsQuerier: return TestDetailsSummary values
  TestDetailsQuerier->>TestDetailsReport: provide summarized status data
  TestDetailsReport->>TestDetailsReport: combine aggregate statistics and nested run details
Loading

Suggested reviewers: stbenjam, smg247, sosiouxme

🚥 Pre-merge checks | ✅ 19 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Single Responsibility And Clear Naming ⚠️ Warning TestDetailsSummary has 11 top-level fields combining identity, statistics, metadata, lifecycle, and per-run details; this exceeds the check's focused-struct guideline. Split TestDetailsSummary into focused subtypes, such as test metadata and run details, and compose them in a smaller summary type.
✅ Passed checks (19 passed)
Check name Status Explanation
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 Review found no new panic calls or ignored error assignments; added Postgres query errors are checked and wrapped with %w, and pointer dereferences have guards or internal invariants.
Sql Injection Prevention ✅ Passed New PostgreSQL fallback binds releases, test IDs, dates, and variant values through placeholders and Raw arguments; dynamic SQL contains only fixed fragments and generated placeholders.
Excessive Css In React Should Use Styles ✅ Passed The PR changes only Go files. It adds no React components, JSX, or inline CSS objects, so this check is not applicable.
Test Coverage For New Features ✅ Passed Coverage includes a unit test for SummarizeTestJobRuns, updated report unit tests, and integration regressions for aggregate fallback, metadata, last failure, flake handling, filtering, and job-run...
Feature Documentation ✅ Passed The PR changes component-readiness data flow and APIs, but adds no docs; no relevant feature page exists, and updates are explicitly encouraged but not required.
Stable And Deterministic Test Names ✅ Passed Changed tests use static Go test names and literal t.Run titles; tc.name comes from fixed table labels, with no Ginkgo calls or dynamic formatting in titles.
Test Structure And Quality ✅ Passed The three changed test files use Go testing and testify, not Ginkgo; no Ginkgo lifecycle, cluster waits, or Eventually/Consistently calls require review.
Microshift Test Compatibility ✅ Passed The PR adds standard Go integration tests, not Ginkgo e2e tests; no Ginkgo imports or Describe/Context/When/It declarations were added.
Single Node Openshift (Sno) Test Compatibility ✅ Passed The PR adds standard Go tests with func Test... and t.Run, not Ginkgo e2e tests; no new multi-node or HA cluster assumptions are present.
Topology-Aware Scheduling Compatibility ✅ Passed The PR changes report aggregation, providers, data types, and tests only. It adds no deployment manifests, operators, controllers, or scheduling constraints.
Ote Binary Stdout Contract ✅ Passed Focused scans of all changed Go files found no active fmt/log/klog/stdout writes or suite hooks in process-level code; the only Printf match is commented out in a test.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed The PR adds only standard Go tests (Test...) and no Ginkgo declarations or imports; searches found no IPv4 literals or external URLs.
No-Weak-Crypto ✅ Passed Changed files contain no MD5, SHA-1, DES, RC4, Blowfish, ECB, crypto APIs, custom crypto, or secret/token comparisons; existing MD5 code is outside the PR diff.
Container-Privileges ✅ Passed The PR changes only Go source and tests. No container/Kubernetes manifest changes or added privileged, host namespace, SYS_ADMIN, root, or allowPrivilegeEscalation settings are present.
No-Sensitive-Data-In-Logs ✅ Passed The diff adds no sensitive-data logging. Existing logs report counts, test IDs, variants, releases, or generic errors; new summary fields are not logged.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: adding aggregate-table fallback for base statistics in test-details reporting.
✨ 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.

@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

🧹 Nitpick comments (8)
pkg/apis/api/componentreport/crstatus/summarize.go (1)

27-27: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Document that SuccessRate in the summary is provisional.

AddTestCount receives a hardcoded false for flakeAsFailure. The counts are independent of that flag, but Stats.SuccessRate is not. Consumers must recompute the rate with the request's FlakeAsFailure, as summarizeRecordedTestStats does in pkg/api/componentreadiness/test_details.go. A short comment prevents a future consumer from reading summary.Stats.SuccessRate as authoritative.

♻️ Proposed comment
+			// Counts are flake-policy independent; SuccessRate here is provisional and
+			// callers must recompute it with the request's FlakeAsFailure setting.
 			summary.Stats = summary.Stats.AddTestCount(row.Count, false)
🤖 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/apis/api/componentreport/crstatus/summarize.go` at line 27, Add a concise
comment at the summary.Stats assignment in summarizeRecordedTestStats
documenting that SuccessRate is provisional because AddTestCount uses
flakeAsFailure=false, and that consumers must recompute it using the request’s
FlakeAsFailure setting.
pkg/apis/api/componentreport/crstatus/summarize_test.go (1)

12-70: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Extend coverage beyond lifecycle promotion.

The table covers only Lifecycle. SummarizeTestJobRuns also implements behavior that a regression would hide:

  • Count aggregation across rows into Stats.
  • Skipping JobRuns entries when ProwJobRunID is empty (the aggregate fallback path depends on this).
  • First-non-empty selection for JiraComponent, JiraComponentID, and TestName.
  • Grouping of several test keys under one job, and stable first-seen ordering.

These are pure-logic checks and need no database. Do you want me to generate the additional table-driven cases?

As per path instructions: "Prefer table-driven Go tests with descriptive case names, and search the same package for existing test patterns before adding new 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/apis/api/componentreport/crstatus/summarize_test.go` around lines 12 -
70, Extend TestSummarizeTestJobRuns_LifecyclePromotion or add a companion
table-driven test to cover Stats count aggregation, skipping rows with empty
ProwJobRunID, first-non-empty JiraComponent/JiraComponentID/TestName selection,
and grouping multiple test keys under one job while preserving first-seen order.
Follow existing same-package test patterns and assert the complete summarized
output for each descriptive case.

Source: Path instructions

pkg/api/componentreadiness/dataprovider/postgres/provider.go (3)

483-486: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Log when the aggregate fallback is used.

The fallback is silent. Reports built from the aggregate path contain no JobRuns, so the UI shows no individual runs. A single structured log line makes that state diagnosable.

♻️ Proposed change
 	if len(result) > 0 {
 		return result, nil
 	}
+	log.WithField("release", reqOptions.BaseRelease.Name).
+		Info("no per-run base test details found, falling back to aggregate tables")
 	return p.queryBaseAggregateTestDetails(ctx, reqOptions)

As per coding guidelines: "Prefer structured logging, especially for names and IDs, and prefer log.WithField() over formatting values into log strings when appropriate."

🤖 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/componentreadiness/dataprovider/postgres/provider.go` around lines
483 - 486, In the result fallback within the provider method, add one structured
log entry immediately before calling queryBaseAggregateTestDetails, using the
existing logger and fields for relevant names or IDs rather than formatting
values into the message. Keep the successful result return unchanged and
preserve the existing aggregate fallback behavior.

Source: Coding guidelines


629-635: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Extract the repeated variant-filter append.

The same block now appears three times in this file: queryTestDetails (lines 378-384), buildAggregatePrefixSumQuery (lines 591-597), and here. A small helper that returns the clause and appends the args keeps the three call sites in sync.

♻️ Proposed helper
// appendVariantFilter appends the variant-combination subquery and its args when
// includeVariants produces a filter clause.
func appendVariantFilter(sqlQuery string, args []any, includeVariants map[string][]string) (string, []any) {
	if len(includeVariants) == 0 {
		return sqlQuery, args
	}
	filterClause, filterArgs := buildVariantFilterClause(includeVariants)
	if filterClause == "" {
		return sqlQuery, args
	}
	return sqlQuery + " AND pj.variant_combination_id IN (SELECT vc.id FROM variant_combinations vc WHERE " + filterClause + ")",
		append(args, filterArgs...)
}
🤖 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/componentreadiness/dataprovider/postgres/provider.go` around lines
629 - 635, Extract the duplicated variant-filter logic into an
appendVariantFilter helper that accepts the SQL string, args, and
includeVariants, then returns the updated values while preserving empty-input
and empty-clause behavior. Replace the repeated blocks in queryTestDetails,
buildAggregatePrefixSumQuery, and the shown query flow with calls to this helper
so all three sites remain consistent.

656-698: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Extract the shared requested-variant filtering and key construction.

Lines 656-698 duplicate queryTestDetails lines 406-465: the requestedVariantsByTestID map build, the variant match loop, the filterByDBGroupBy call, the KeyWithVariants construction, and the big.Rat conversion of JiraComponentID. The two paths must stay behaviorally identical, so a shared helper reduces the risk that only one path is updated later.

A helper such as matchAndBuildTestKey(row testID string, variants map[string]string, requested map[string]map[string]string, dbGroupBy sets.Set[string]) (crtest.KeyWithVariants, bool) covers both call sites.

🤖 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/componentreadiness/dataprovider/postgres/provider.go` around lines
656 - 698, Extract the duplicated requested-variant matching and test-key
construction from queryTestDetails and the shown result-building loop into a
shared helper, such as matchAndBuildTestKey. Have it apply the requested variant
filter, call filterByDBGroupBy, and build the crtest.KeyWithVariants
consistently; update both callers to use it and preserve the existing
JiraComponentID big.Rat conversion in the surrounding row-processing logic.
pkg/api/componentreadiness/test_details.go (2)

502-519: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Share the metadata-merge and lifecycle-promotion rule with crstatus.

Lines 503-518 repeat the exact logic in pkg/apis/api/componentreport/crstatus/summarize.go lines 41-56: first-non-empty selection for JiraComponent, JiraComponentID, and TestName, plus promotion of Lifecycle to "informing". Two copies of the promotion rule can diverge if a new lifecycle value is added.

Move the rule into an exported helper in crstatus and call it from both places. extractMetadata also does not use its receiver c, so it can become a package-level function.

🤖 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/componentreadiness/test_details.go` around lines 502 - 519, Move the
shared metadata merge and lifecycle-promotion logic from
ComponentReportGenerator.extractMetadata and crstatus summarization into an
exported helper in crstatus, then call that helper from both callers. Convert
extractMetadata to a package-level function because it does not use c, and
preserve the existing first-non-empty field selection and "informing" lifecycle
promotion behavior.

458-483: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Document the one-summary-per-job precondition.

Both inner loops assign jobStats.SampleJobName and jobStats.BaseJobName on every iteration. If a job maps to more than one summary, the last summary wins and the earlier job names are lost, while the counts still accumulate across all of them.

Callers satisfy the precondition today: GenerateDetailsReportForTest receives statuses already split by test key. A short comment records that assumption for future callers.

♻️ Proposed comment
 	jobNames := sets.New(slices.Collect(maps.Keys(baseStatus))...)
 	jobNames.Insert(slices.Collect(maps.Keys(sampleStatus))...)
+	// Callers pass statuses already split by test key, so each job maps to at most
+	// one summary here; the job-name assignments below rely on that.
 	for job := range jobNames {
🤖 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/componentreadiness/test_details.go` around lines 458 - 483, Add a
concise comment near the sampleStatus/baseStatus processing in the job loop
documenting that callers provide at most one summary per job, with
GenerateDetailsReportForTest supplying statuses split by test key. Do not alter
the existing aggregation or name-assignment logic.
test/integration/component_readiness_test.go (1)

2622-2635: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Positional indexing of JobRuns depends on the query ordering.

The assertions map JobRuns[0], [1], and [2] to the pass, fail, and flake runs. That holds only because queryTestDetails applies ORDER BY pjr.timestamp and the summarizer appends in row order. If the ordering clause changes, these assertions fail with a message that does not name the cause.

Selecting each run by ProwJobRunID makes the intent explicit and removes the ordering dependency.

🤖 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 `@test/integration/component_readiness_test.go` around lines 2622 - 2635,
Replace the positional JobRuns[0], JobRuns[1], and JobRuns[2] lookups in the
pass/fail/flake assertions with selections by each run’s ProwJobRunID. Preserve
the existing count and success/flake assertions while making each detail lookup
independent of queryTestDetails ordering.
🤖 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/componentreadiness/dataprovider/postgres/provider.go`:
- Around line 501-504: Update the doc comment for
PostgresProvider.queryBaseAggregateTestDetails to state that it returns
map[string][]crstatus.TestDetailsSummary values instead of TestJobRunRows
entries.

In `@pkg/api/componentreadiness/middleware/releasefallback/releasefallback.go`:
- Line 252: Update the logging call in the release fallback test-key handling to
use Debug-level structured logging with testKeyStr as a named field, rather than
concatenating it into the Infof format string. Preserve the existing message
context while ensuring arbitrary key contents, including percent signs, are
logged safely.

In `@pkg/api/componentreadiness/test_details.go`:
- Around line 410-411: Update summarizeRecordedTestStats to add an explanation
when aggregate base summaries contain counts but no JobRuns, so the report
explains why BaseJobRunStats has no individual runs. Populate
testStats.Explanations only for this missing-detail condition and preserve empty
explanations for cases where base runs are available.

In `@pkg/apis/api/componentreport/crstatus/types.go`:
- Around line 52-56: Update GetDataFromCacheOrGenerate to restore TestKeyStr for
cached TestDetailsSummary and TestJobRunRows values by deriving it from each
corresponding TestKey after json.Unmarshal. Ensure both cached result types
retain the same grouped test-key behavior as freshly generated data.

---

Nitpick comments:
In `@pkg/api/componentreadiness/dataprovider/postgres/provider.go`:
- Around line 483-486: In the result fallback within the provider method, add
one structured log entry immediately before calling
queryBaseAggregateTestDetails, using the existing logger and fields for relevant
names or IDs rather than formatting values into the message. Keep the successful
result return unchanged and preserve the existing aggregate fallback behavior.
- Around line 629-635: Extract the duplicated variant-filter logic into an
appendVariantFilter helper that accepts the SQL string, args, and
includeVariants, then returns the updated values while preserving empty-input
and empty-clause behavior. Replace the repeated blocks in queryTestDetails,
buildAggregatePrefixSumQuery, and the shown query flow with calls to this helper
so all three sites remain consistent.
- Around line 656-698: Extract the duplicated requested-variant matching and
test-key construction from queryTestDetails and the shown result-building loop
into a shared helper, such as matchAndBuildTestKey. Have it apply the requested
variant filter, call filterByDBGroupBy, and build the crtest.KeyWithVariants
consistently; update both callers to use it and preserve the existing
JiraComponentID big.Rat conversion in the surrounding row-processing logic.

In `@pkg/api/componentreadiness/test_details.go`:
- Around line 502-519: Move the shared metadata merge and lifecycle-promotion
logic from ComponentReportGenerator.extractMetadata and crstatus summarization
into an exported helper in crstatus, then call that helper from both callers.
Convert extractMetadata to a package-level function because it does not use c,
and preserve the existing first-non-empty field selection and "informing"
lifecycle promotion behavior.
- Around line 458-483: Add a concise comment near the sampleStatus/baseStatus
processing in the job loop documenting that callers provide at most one summary
per job, with GenerateDetailsReportForTest supplying statuses split by test key.
Do not alter the existing aggregation or name-assignment logic.

In `@pkg/apis/api/componentreport/crstatus/summarize_test.go`:
- Around line 12-70: Extend TestSummarizeTestJobRuns_LifecyclePromotion or add a
companion table-driven test to cover Stats count aggregation, skipping rows with
empty ProwJobRunID, first-non-empty JiraComponent/JiraComponentID/TestName
selection, and grouping multiple test keys under one job while preserving
first-seen order. Follow existing same-package test patterns and assert the
complete summarized output for each descriptive case.

In `@pkg/apis/api/componentreport/crstatus/summarize.go`:
- Line 27: Add a concise comment at the summary.Stats assignment in
summarizeRecordedTestStats documenting that SuccessRate is provisional because
AddTestCount uses flakeAsFailure=false, and that consumers must recompute it
using the request’s FlakeAsFailure setting.

In `@test/integration/component_readiness_test.go`:
- Around line 2622-2635: Replace the positional JobRuns[0], JobRuns[1], and
JobRuns[2] lookups in the pass/fail/flake assertions with selections by each
run’s ProwJobRunID. Preserve the existing count and success/flake assertions
while making each detail lookup independent of queryTestDetails ordering.
🪄 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: Pro Plus

Run ID: d67c79c2-a323-4559-9b9b-1895f58b479f

📥 Commits

Reviewing files that changed from the base of the PR and between f66444a and ba1a34e.

📒 Files selected for processing (12)
  • pkg/api/componentreadiness/component_report_test.go
  • pkg/api/componentreadiness/dataprovider/bigquery/provider.go
  • pkg/api/componentreadiness/dataprovider/bigquery/querygenerators.go
  • pkg/api/componentreadiness/dataprovider/interface.go
  • pkg/api/componentreadiness/dataprovider/mixed/provider.go
  • pkg/api/componentreadiness/dataprovider/postgres/provider.go
  • pkg/api/componentreadiness/middleware/releasefallback/releasefallback.go
  • pkg/api/componentreadiness/test_details.go
  • pkg/apis/api/componentreport/crstatus/summarize.go
  • pkg/apis/api/componentreport/crstatus/summarize_test.go
  • pkg/apis/api/componentreport/crstatus/types.go
  • test/integration/component_readiness_test.go

Comment thread pkg/api/componentreadiness/dataprovider/postgres/provider.go
Comment thread pkg/api/componentreadiness/middleware/releasefallback/releasefallback.go Outdated
Comment thread pkg/api/componentreadiness/test_details.go
Comment thread pkg/apis/api/componentreport/crstatus/types.go
Refactor test details to use TestDetailsSummary with pre-computed Stats
(crtest.Stats) instead of raw Count aggregation. This fixes a failure
count bug where aggregating Count values before computing failures lost
hard failures when flakes coexisted.

Move per-job summarization into SummarizeTestJobRuns in the crstatus
package, making it shared between providers. Add aggregate table
fallback for base stats in the Postgres provider when per-run data is
absent.

Add integration tests for end-to-end report generation covering
aggregate base stats fallback, last failure tracking, and
FlakeAsFailure mode. Add unit test for lifecycle "informing" promotion
in SummarizeTestJobRuns.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@mstaeble
mstaeble force-pushed the worktree-test-details-base-stats-fallback branch from ba1a34e to 9d2a7f8 Compare August 1, 2026 14:32
@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 Aug 1, 2026
@mstaeble
mstaeble marked this pull request as ready for review August 1, 2026 14:41
@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 Aug 1, 2026
@openshift-ci
openshift-ci Bot requested review from petr-muller and smg247 August 1, 2026 14:42
@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Scheduling required tests:
/test e2e

@openshift-ci

openshift-ci Bot commented Aug 1, 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

approved Indicates a PR has been approved by an approver from all required OWNERS files. 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