Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ func (l *LinkInjector) PostAnalysis(testKey crtest.Identification, testStats *te
testDetailsURL, err := utils.GenerateTestDetailsURL(
testKey.TestID,
l.baseURL,
l.reqOptions.ViewName, // Pass the view name if present
l.reqOptions.BaseRelease,
l.reqOptions.SampleRelease,
l.reqOptions.AdvancedOption,
Expand Down
277 changes: 142 additions & 135 deletions pkg/api/componentreadiness/query/querygenerators.go

Large diffs are not rendered by default.

20 changes: 14 additions & 6 deletions pkg/api/componentreadiness/query/querygenerators_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,14 @@ func TestBuildComponentReportQuery_ExclusiveTestFiltering(t *testing.T) {
"Query should contain jobs_with_highest_priority_test CTE")
assert.Contains(t, commonQuery, "key_test_priorities",
"Query should contain exclusive_test_priorities CTE for priority calculation")
assert.Contains(t, commonQuery, "AND success_val = 0",
"CTE should only identify jobs where key tests FAILED (success_val = 0)")
assert.Contains(t, commonQuery, "AND adjusted_success_val = 0",
"CTE should only identify jobs where key tests FAILED (adjusted_success_val = 0 from deduped data)")
assert.Contains(t, commonQuery, "test_name IN UNNEST(@KeyTestNames)",
"CTE should filter by key test names")
assert.Contains(t, commonQuery, "test_priority",
"CTE should calculate test priority based on list order")
assert.Contains(t, commonQuery, "FROM deduped_testcases",
"CTE should query from deduped_testcases, not raw junit table")
} else {
assert.NotContains(t, commonQuery, "jobs_with_highest_priority_test",
"Query should not contain jobs_with_highest_priority_test CTE when no key tests")
Expand Down Expand Up @@ -201,18 +203,24 @@ func TestBuildComponentReportQuery_ExclusiveTestLogic(t *testing.T) {

// The query should:
// 1. Create CTEs that identify the highest priority test in each job
assert.Contains(t, commonQuery, "WITH key_test_priorities AS",
assert.Contains(t, commonQuery, "WITH deduped_testcases_with_rownum AS",
"Should create deduped_testcases_with_rownum CTE first")
assert.Contains(t, commonQuery, "deduped_testcases AS",
"Should create deduped_testcases CTE that filters to row_num = 1")
assert.Contains(t, commonQuery, "key_test_priorities AS",
"Should create CTE for calculating test priorities")
assert.Contains(t, commonQuery, "jobs_with_highest_priority_test AS",
"Should create CTE for identifying highest priority test per job")

// 2. The CTE should check success_val = 0 (failure)
// 2. The CTE should check adjusted_success_val = 0 (failure) from deduped data
cteEnd := strings.Index(commonQuery, "latest_component_mapping")
require.Greater(t, cteEnd, 0, "Should contain latest_component_mapping CTE")

cteSection := commonQuery[:cteEnd]
assert.Contains(t, cteSection, "success_val = 0",
"CTE should only match FAILED key tests (success_val = 0), not all instances")
assert.Contains(t, cteSection, "adjusted_success_val = 0",
"CTE should only match FAILED key tests (adjusted_success_val = 0 from deduped data), not all instances")
assert.Contains(t, cteSection, "FROM deduped_testcases",
"CTE should query from deduped_testcases, not raw junit table")

// 3. Priority-based filtering: only include highest priority test from jobs with key test failures
assert.Contains(t, commonQuery, "test_priority",
Expand Down
3 changes: 3 additions & 0 deletions pkg/api/componentreadiness/test_details.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,12 @@ func (c *ComponentReportGenerator) GenerateDetailsReportForTest(
}

// Generate test details URL with the newer sample date range
// For the "latest" link, we should not use the view (as the view's date range may be stale)
// Instead, we generate a full URL with updated sample dates
latestURL, err := utils.GenerateTestDetailsURL(
testIDOption.TestID,
c.baseURL,
"", // Don't use view for "latest" link - we want fresh dates, not view's dates
c.ReqOptions.BaseRelease,
newSampleRelease,
c.ReqOptions.AdvancedOption,
Expand Down
1 change: 1 addition & 0 deletions pkg/api/componentreadiness/triage.go
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,7 @@ func generateTestDetailsURLFromRegression(regression *models.TestRegression, vie
return utils.GenerateTestDetailsURL(
regression.TestID,
baseURL,
view.Name, // Pass the view name
baseReleaseOpts,
sampleReleaseOpts,
view.AdvancedOptions,
Expand Down
5 changes: 5 additions & 0 deletions pkg/api/componentreadiness/utils/queryparamparser.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ func ParseComponentReportRequest(

if view != nil {
// set params from view
opts.ViewName = view.Name
opts.VariantOption = view.VariantOptions
opts.AdvancedOption = view.AdvancedOptions
opts.TestFilters = view.TestFilters
Expand Down Expand Up @@ -367,6 +368,10 @@ func parseAdvancedOptions(req *http.Request) (advancedOption reqopts.Advanced, e
return advancedOption, err
}

// Parse key test names - these are tests that when they fail in a job,
// all other test failures in that job are excluded from regression analysis
advancedOption.KeyTestNames = req.URL.Query()["keyTestName"]

return
}

Expand Down
Loading