Skip to content

Commit

Permalink
Merge pull request #164 from xueqzhan/duplicate-priority
Browse files Browse the repository at this point in the history
TRT-1868: Detect components claiming test with the same highest priority
  • Loading branch information
openshift-merge-bot[bot] authored Nov 25, 2024
2 parents 3980996 + 3908437 commit bab95d9
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions pkg/components/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,21 @@ func testInfoLogFields(testInfo *v1.TestInfo) log.Fields {

func getHighestPriority(ownerships []*v1.TestOwnership) (*v1.TestOwnership, error) {
var highest *v1.TestOwnership
// First find the highest priority
for _, ownership := range ownerships {
if highest != nil && ownership.Priority == highest.Priority {
return nil, fmt.Errorf("suite=%q test=%q is claimed by %s, %s - unable to resolve conflict "+
"-- please use priority field", highest.Suite, highest.Name, highest.Component, ownership.Component)
}

if highest == nil || ownership.Priority > highest.Priority {
highest = ownership
}
}
// Now find duplicates with the same highest priority
if highest != nil {
for _, ownership := range ownerships {
if ownership.Priority == highest.Priority && ownership != highest {
return nil, fmt.Errorf("suite=%q test=%q is claimed by %s, %s - unable to resolve conflict "+
"-- please use priority field", highest.Suite, highest.Name, highest.Component, ownership.Component)
}
}
}

return highest, nil
}
Expand Down

0 comments on commit bab95d9

Please sign in to comment.