@@ -51,6 +51,7 @@ type BuildResult struct {
5151 Err error // Error encountered during the build.
5252 LogFile string // Path to the log file from the build.
5353 Node * pkggraph.PkgNode // The main node being analyzed for the build.
54+ CheckFailed bool // Indicator if the package test failed but the build itself was correct.
5455 Ignored bool // Indicator if the build was ignored by user request.
5556 UsedCache bool // Indicator if we used the cached artifacts (external or earlier local build) instead of building the node.
5657 WasDelta bool // Indicator if we used a pre-built component from an external repository instead of building the node.
@@ -120,7 +121,7 @@ func BuildNodeWorker(channels *BuildChannels, agent buildagents.BuildAgent, grap
120121 }
121122
122123 case pkggraph .TypeTest :
123- res .Ignored , res .LogFile , res .Err = testNode (req , graphMutex , agent , checkAttempts , ignoredTests )
124+ res .CheckFailed , res . Ignored , res .LogFile , res .Err = testNode (req , graphMutex , agent , checkAttempts , ignoredTests )
124125 if res .Err == nil {
125126 setAncillaryBuildNodesStatus (req , graphMutex , pkggraph .StateUpToDate )
126127 } else {
@@ -175,7 +176,7 @@ func buildNode(request *BuildRequest, graphMutex *sync.RWMutex, agent buildagent
175176}
176177
177178// testNode tests a TypeTest node.
178- func testNode (request * BuildRequest , graphMutex * sync.RWMutex , agent buildagents.BuildAgent , checkAttempts int , ignoredTests []* pkgjson.PackageVer ) (ignored bool , logFile string , err error ) {
179+ func testNode (request * BuildRequest , graphMutex * sync.RWMutex , agent buildagents.BuildAgent , checkAttempts int , ignoredTests []* pkgjson.PackageVer ) (checkFailed , ignored bool , logFile string , err error ) {
179180 node := request .Node
180181 baseSrpmName := node .SRPMFileName ()
181182
@@ -200,7 +201,7 @@ func testNode(request *BuildRequest, graphMutex *sync.RWMutex, agent buildagents
200201 dependencies := getBuildDependencies (node , request .PkgGraph , graphMutex )
201202
202203 logger .Log .Infof ("Testing: %s" , baseSrpmName )
203- logFile , err = testSRPMFile (agent , checkAttempts , basePackageName , node .SrpmPath , node .Architecture , dependencies )
204+ logFile , checkFailed , err = testSRPMFile (agent , checkAttempts , basePackageName , node .SrpmPath , node .Architecture , dependencies )
204205 return
205206}
206207
@@ -239,7 +240,7 @@ func getBuildDependencies(node *pkggraph.PkgNode, pkgGraph *pkggraph.PkgGraph, g
239240}
240241
241242// parseCheckSection reads the package build log file to determine if the %check section passed or not
242- func parseCheckSection (logFile string ) (err error ) {
243+ func parseCheckSection (logFile string ) (checkFailed bool , err error ) {
243244 logFileObject , err := os .Open (logFile )
244245 // If we can't open the log file, that's a build error.
245246 if err != nil {
@@ -261,7 +262,7 @@ func parseCheckSection(logFile string) (err error) {
261262 logger .Log .Errorf ("Log file copy failed. Error: %v" , err )
262263 return
263264 }
264- err = fmt . Errorf ( "package test failed. Test status line: %s" , currLine )
265+ checkFailed = true
265266 return
266267 }
267268 }
@@ -285,14 +286,14 @@ func buildSRPMFile(agent buildagents.BuildAgent, buildAttempts int, basePackageN
285286}
286287
287288// testSRPMFile sends an SRPM to a build agent to test.
288- func testSRPMFile (agent buildagents.BuildAgent , checkAttempts int , basePackageName string , srpmFile string , outArch string , dependencies []string ) (logFile string , err error ) {
289+ // The 'checkFailed' flag says if the package test failed as opposed
290+ // to the build failing for another reason, which is reflected by a non-nil 'err'.
291+ func testSRPMFile (agent buildagents.BuildAgent , checkAttempts int , basePackageName string , srpmFile string , outArch string , dependencies []string ) (logFile string , checkFailed bool , err error ) {
289292 const (
290293 retryDuration = time .Second
291294 runCheck = true
292295 )
293296
294- // checkFailed is a flag to see if a non-null buildErr is from the %check section
295- checkFailed := false
296297 logBaseName := filepath .Base (srpmFile ) + ".test.log"
297298 err = retry .Run (func () (buildErr error ) {
298299 checkFailed = false
@@ -303,13 +304,16 @@ func testSRPMFile(agent buildagents.BuildAgent, checkAttempts int, basePackageNa
303304 return
304305 }
305306
306- buildErr = parseCheckSection (logFile )
307- checkFailed = (buildErr != nil )
307+ checkFailed , buildErr = parseCheckSection (logFile )
308+ // If the build succeeded but tests failed, we still want to retry.
309+ if buildErr == nil && checkFailed {
310+ buildErr = fmt .Errorf ("package test for '%s' failed" , basePackageName )
311+ }
308312 return
309313 }, checkAttempts , retryDuration )
310314
311- if err != nil && checkFailed {
312- logger .Log .Warnf ("Tests failed for '%s'. Error: %s " , srpmFile , err )
315+ if checkFailed {
316+ logger .Log .Debugf ("Tests failed for '%s' after %d retries. " , basePackageName , checkAttempts )
313317 err = nil
314318 }
315319 return
0 commit comments