From 6c547f68cc0d15e9069e91482fff80e728642ed9 Mon Sep 17 00:00:00 2001 From: Luke Meyer Date: Thu, 11 Jul 2024 17:36:29 -0400 Subject: [PATCH] Risk Analysis: ensure Test ID is populated --- pkg/api/job_runs.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pkg/api/job_runs.go b/pkg/api/job_runs.go index 77cd2eb72c..686ad46618 100644 --- a/pkg/api/job_runs.go +++ b/pkg/api/job_runs.go @@ -528,9 +528,17 @@ func runTestRunAnalysis(failedTest models.ProwJobRunTest, jobRun *models.ProwJob return apitype.ProwJobRunTestRiskAnalysis{}, errJobNames } + // one of our data sources should have the test ID + testID := failedTest.Test.ID + if testID == 0 && testResultsJobNames != nil { + testID = uint(testResultsJobNames.ID) + } + if testID == 0 && testResultsVariants != nil { + testID = uint(testResultsVariants.ID) + } analysis := apitype.ProwJobRunTestRiskAnalysis{ Name: failedTest.Test.Name, - TestID: failedTest.Test.ID, + TestID: testID, OpenBugs: failedTest.Test.Bugs, } // Watch out for tests that ran in previous period, but not current, no sense comparing to 0 runs: