diff --git a/pkg/api/job_runs.go b/pkg/api/job_runs.go index 686ad4661..0aa61046a 100644 --- a/pkg/api/job_runs.go +++ b/pkg/api/job_runs.go @@ -529,12 +529,12 @@ func runTestRunAnalysis(failedTest models.ProwJobRunTest, jobRun *models.ProwJob } // one of our data sources should have the test ID - testID := failedTest.Test.ID + testID := failedTest.Test.TestID if testID == 0 && testResultsJobNames != nil { - testID = uint(testResultsJobNames.ID) + testID = testResultsJobNames.TestID } if testID == 0 && testResultsVariants != nil { - testID = uint(testResultsVariants.ID) + testID = testResultsVariants.TestID } analysis := apitype.ProwJobRunTestRiskAnalysis{ Name: failedTest.Test.Name, diff --git a/pkg/api/tests.go b/pkg/api/tests.go index 8f0d2c705..b17e40974 100644 --- a/pkg/api/tests.go +++ b/pkg/api/tests.go @@ -195,7 +195,7 @@ func BuildTestsResults(dbc *db.DB, release, period string, collapse, includeOver // Collapse groups the test results together -- otherwise we return the test results per-variant combo (NURP+) variantSelect := "" if collapse { - rawQuery = rawQuery.Select(`id,name,watchlist,jira_component,jira_component_id,` + query.QueryTestSummer).Group("id,name,watchlist,jira_component,jira_component_id") + rawQuery = rawQuery.Select(`test_id,name,watchlist,jira_component,jira_component_id,` + query.QueryTestSummer).Group("test_id,name,watchlist,jira_component,jira_component_id") } else { rawQuery = query.TestsByNURPAndStandardDeviation(dbc, release, table) variantSelect = "suite_name, variants," + @@ -211,7 +211,7 @@ func BuildTestsResults(dbc *db.DB, release, period string, collapse, includeOver testReports := make([]apitype.Test, 0) processedResults := dbc.DB.Table("(?) as results", rawQuery). - Select(`id, watchlist, name, jira_component, jira_component_id,` + variantSelect + query.QueryTestSummarizer). + Select(`ROW_NUMBER() OVER() as id, test_id, watchlist, name, jira_component, jira_component_id,` + variantSelect + query.QueryTestSummarizer). Where("current_runs > 0 or previous_runs > 0") finalResults := dbc.DB.Table("(?) as final_results", processedResults) diff --git a/pkg/apis/api/types.go b/pkg/apis/api/types.go index 429be3b87..6616a9a0c 100644 --- a/pkg/apis/api/types.go +++ b/pkg/apis/api/types.go @@ -452,6 +452,7 @@ func (run JobRun) GetArrayValue(param string) ([]string, error) { // of this struct is suitable for use in a data table. type Test struct { ID int `json:"id,omitempty"` + TestID string `json:"test_id,omitempty"` Name string `json:"name"` SuiteName string `json:"suite_name"` Variant string `json:"variant,omitempty"` @@ -757,7 +758,7 @@ type ProwJobRunRiskAnalysis struct { type ProwJobRunTestRiskAnalysis struct { Name string - TestID uint + TestID string Risk TestFailureRisk OpenBugs []models.Bug } diff --git a/pkg/db/query/test_queries.go b/pkg/db/query/test_queries.go index e6c9f25a0..1b96f67e5 100644 --- a/pkg/db/query/test_queries.go +++ b/pkg/db/query/test_queries.go @@ -55,7 +55,7 @@ const ( QueryTestSummarizer = QueryTestFields + "," + QueryTestPercentages - QueryTestAnalysis = "select test_id as id, current_successes, current_runs, current_successes * 100.0 / NULLIF(current_runs, 0) AS current_pass_percentage from ( select test_id, sum(runs) as current_runs, sum(passes) as current_successes from prow_test_analysis_by_job_14d_matview where test_name = '%s' AND job_name in (%s) GROUP BY test_id)t" + QueryTestAnalysis = "select test_id as id, current_successes, current_runs, current_successes * 100.0 / NULLIF(current_runs, 0) AS current_pass_percentage from ( select test_id, sum(runs) as current_runs, sum(passes) as current_successes from prow_test_analysis_by_job_14d_matview join where test_name = '%s' AND job_name in (%s) GROUP BY test_id)t" ) // TestReportsByVariant returns a test report for every test in the db matching the given substrings, separated by variant.