-
Notifications
You must be signed in to change notification settings - Fork 325
Trt 2389 test summaries #4868
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trt 2389 test summaries #4868
Changes from all commits
993b0b0
cee2982
d87305e
6533fee
80a9e2b
a9f241e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| package jobrunaggregatorapi | ||
|
|
||
| import ( | ||
| "cloud.google.com/go/civil" | ||
| ) | ||
|
|
||
| // TestSummaryByPeriodRow represents aggregated test results for a specific suite and release over a time period. | ||
| // This data structure corresponds to the suite_summary_by_period.sql query results. | ||
| type TestSummaryByPeriodRow struct { | ||
| Release string `bigquery:"release"` | ||
| TestName string `bigquery:"test_name"` | ||
| TotalTestCount int64 `bigquery:"total_test_count"` | ||
| TotalFailureCount int64 `bigquery:"total_failure_count"` | ||
| TotalFlakeCount int64 `bigquery:"total_flake_count"` | ||
| FailureRate float64 `bigquery:"failure_rate"` | ||
| AvgDurationMs float64 `bigquery:"avg_duration_ms"` | ||
| PeriodStart civil.Date `bigquery:"period_start"` | ||
| PeriodEnd civil.Date `bigquery:"period_end"` | ||
| DaysWithData int64 `bigquery:"days_with_data"` | ||
| FirstSampleDate civil.Date `bigquery:"first_sample_date"` // First date this test_name was seen within the sample period across all releases for this suite | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -66,6 +66,14 @@ type CIDataClient interface { | |
|
|
||
| // ListReleases lists all releases from the new release table | ||
| ListReleases(ctx context.Context) ([]jobrunaggregatorapi.ReleaseRow, error) | ||
|
|
||
| // ListTestSummaryByPeriod retrieves aggregated test results for a specific suite and release over a time period. | ||
| // Parameters: | ||
| // - suiteName: The test suite to query (e.g., 'conformance') | ||
| // - releaseName: The release version (e.g., '4.15') | ||
| // - daysBack: Number of days to look back from current date | ||
| // - minTestCount: Minimum number of test executions required to include a test in results | ||
| ListTestSummaryByPeriod(ctx context.Context, suiteName, releaseName string, daysBack, minTestCount int) ([]jobrunaggregatorapi.TestSummaryByPeriodRow, error) | ||
| } | ||
|
|
||
| type ciDataClient struct { | ||
|
|
@@ -1095,3 +1103,93 @@ func (c *ciDataClient) ListAllKnownAlerts(ctx context.Context) ([]*jobrunaggrega | |
|
|
||
| return allKnownAlerts, nil | ||
| } | ||
|
|
||
| func (c *ciDataClient) ListTestSummaryByPeriod(ctx context.Context, suiteName, releaseName string, daysBack, minTestCount int) ([]jobrunaggregatorapi.TestSummaryByPeriodRow, error) { | ||
| // Query to summarize test results for a specific suite and release over a time period | ||
| // Groups by release and test_name only (no infrastructure dimensions) | ||
| // Calculates total test_count, failure_count, flake_count, failure_rate, and avg_duration_ms | ||
| // Filters results to only include tests with sufficient test runs | ||
| // Also includes first_seen_date: the earliest date each test_name appeared across all releases for this suite | ||
| queryString := c.dataCoordinates.SubstituteDataSetLocation(` | ||
| WITH earliest_test_dates AS ( | ||
| -- Pre-compute the earliest date each test was seen across all releases for this suite | ||
| -- Look back max(100, @days_back) days to ensure we capture historical context | ||
| SELECT | ||
| test_name, | ||
| MIN(date) AS first_sample_date | ||
| FROM | ||
| DATA_SET_LOCATION.TestsSummaryByDate | ||
| WHERE | ||
| suite = @suite_name | ||
| AND date >= DATE_SUB(CURRENT_DATE(), INTERVAL GREATEST(100, @days_back) DAY) | ||
| AND date <= CURRENT_DATE() | ||
| GROUP BY | ||
| test_name | ||
| ) | ||
| SELECT | ||
| main.release, | ||
| main.test_name, | ||
| SUM(main.test_count) AS total_test_count, | ||
| SUM(main.failure_count) AS total_failure_count, | ||
| SUM(main.flake_count) AS total_flake_count, | ||
| SAFE_DIVIDE(SUM(main.failure_count), SUM(main.test_count)) AS failure_rate, | ||
| AVG(main.avg_duration_ms) AS avg_duration_ms, | ||
| MIN(main.date) AS period_start, | ||
| MAX(main.date) AS period_end, | ||
| COUNT(DISTINCT main.date) AS days_with_data, | ||
| earliest.first_sample_date | ||
| FROM | ||
| DATA_SET_LOCATION.TestsSummaryByDate AS main | ||
| LEFT JOIN | ||
| earliest_test_dates AS earliest | ||
| ON | ||
| main.test_name = earliest.test_name | ||
| WHERE | ||
| main.suite = @suite_name | ||
| AND main.release = @release_name | ||
| AND main.date >= DATE_SUB(CURRENT_DATE(), INTERVAL @days_back DAY) | ||
| AND main.date <= CURRENT_DATE() | ||
| GROUP BY | ||
| main.release, | ||
| main.test_name, | ||
| earliest.first_sample_date | ||
| HAVING | ||
| SUM(main.test_count) > @min_test_count | ||
| ORDER BY | ||
| main.release, | ||
| total_failure_count DESC, | ||
| main.test_name | ||
| `) | ||
|
|
||
| query := c.client.Query(queryString) | ||
| query.Labels = map[string]string{ | ||
| bigQueryLabelKeyApp: bigQueryLabelValueApp, | ||
| bigQueryLabelKeyQuery: bigQueryLabelValueTestSummaryByPeriod, | ||
| } | ||
| query.QueryConfig.Parameters = []bigquery.QueryParameter{ | ||
| {Name: "suite_name", Value: suiteName}, | ||
| {Name: "release_name", Value: releaseName}, | ||
| {Name: "days_back", Value: daysBack}, | ||
| {Name: "min_test_count", Value: minTestCount}, | ||
| } | ||
|
|
||
| rows, err := query.Read(ctx) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("failed to query generic test summary by period with %q: %w", queryString, err) | ||
| } | ||
|
|
||
| results := []jobrunaggregatorapi.TestSummaryByPeriodRow{} | ||
| for { | ||
| row := &jobrunaggregatorapi.TestSummaryByPeriodRow{} | ||
| err = rows.Next(row) | ||
| if err == iterator.Done { | ||
| break | ||
| } | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| results = append(results, *row) | ||
| } | ||
|
|
||
| return results, nil | ||
| } | ||
|
Comment on lines
+1107
to
+1195
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: cat -n pkg/jobrunaggregator/jobrunaggregatorlib/ci_data_client.go | sed -n '1107,1195p'Repository: openshift/ci-tools Length of output: 3664 🏁 Script executed: # Search for test cases or usage of ListTestSummaryByPeriod
rg "ListTestSummaryByPeriod" -A 5 -B 5Repository: openshift/ci-tools Length of output: 8755 🏁 Script executed: # Look for any documentation about minTestCount parameter
rg "minTestCount|min_test_count" -B 3 -A 3 -iRepository: openshift/ci-tools Length of output: 8276 🏁 Script executed: # Check if there are similar patterns with comparison operators in other queries
rg "HAVING.*COUNT|HAVING.*SUM" -A 2 -B 2Repository: openshift/ci-tools Length of output: 44 Change HAVING clause to use >= instead of >. Line 1157: The HAVING clause uses 🤖 Prompt for AI Agents |
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.