Skip to content
This repository was archived by the owner on Apr 17, 2019. It is now read-only.

Commit 03752d5

Browse files
authored
Merge pull request #1232 from freehan/autopfix
fix bug in auto prioritization
2 parents 295d33a + 0c1a2a5 commit 03752d5

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

mungegithub/mungers/flake-manager.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ import (
3333
"time"
3434
)
3535

36+
// failedStr is for comment matching during auto prioritization
37+
const failedStr = "Failed: "
38+
3639
// issueFinder finds an issue for a given key.
3740
type issueFinder interface {
3841
AllIssuesForKey(key string) []int
@@ -194,7 +197,7 @@ func (p *individualFlakeSource) ID() string {
194197

195198
// Body implements IssueSource
196199
func (p *individualFlakeSource) Body(newIssue bool) string {
197-
extraInfo := fmt.Sprintf("Failed: %v\n\n```\n%v\n```\n\n", p.Title(), p.flake.Reason)
200+
extraInfo := fmt.Sprintf(failedStr+"%v\n\n```\n%v\n```\n\n", p.Title(), p.flake.Reason)
198201
body := makeGubernatorLink(p.ID()) + "\n" + extraInfo
199202

200203
if !newIssue {
@@ -249,13 +252,13 @@ func (p *brokenJobSource) ID() string {
249252
func (p *brokenJobSource) Body(newIssue bool) string {
250253
url := makeGubernatorLink(p.ID())
251254
if p.result.Status == cache.ResultFailed {
252-
return fmt.Sprintf("%v\nRun so broken it didn't make JUnit output!", url)
255+
return fmt.Sprintf(failedStr+"%v\nRun so broken it didn't make JUnit output!", url)
253256
}
254257
body := fmt.Sprintf("%v\nMultiple broken tests:\n\n", url)
255258

256259
sections := []string{}
257260
for testName, reason := range p.result.Flakes {
258-
text := fmt.Sprintf("Failed: %v\n\n```\n%v\n```\n", testName, reason)
261+
text := fmt.Sprintf(failedStr+"%v\n\n```\n%v\n```\n", testName, reason)
259262
// Reference previous issues if we know of any.
260263
// (key must batch individualFlakeSource.Title()!)
261264
if previousIssues := p.fm.finder.AllIssuesForKey(string(testName)); len(previousIssues) > 0 {
@@ -308,9 +311,9 @@ func autoPrioritize(comments []libgithub.IssueComment, issueCreatedAt *time.Time
308311

309312
for _, c := range comments {
310313
// TODO: think of a better way to identify flake comments
311-
// "Failed:" is a special string contained in flake issue filed by flake-manager
314+
// "Failed: " is a special string contained in flake issue filed by flake-manager
312315
// Please make sure it matches the body generated by IssueSource.Body()
313-
if !sync.RobotUser.Has(*c.User.Login) || !strings.Contains(*c.Body, "Failed:") {
316+
if !sync.RobotUser.Has(*c.User.Login) || !strings.Contains(*c.Body, failedStr) {
314317
continue
315318
}
316319
occurence = append(occurence, c.CreatedAt)

mungegithub/mungers/flake-manager_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func TestBrokenJobSource(t *testing.T) {
8787
}
8888

8989
func flakecomment(id int, createdAt time.Time) github.IssueComment {
90-
return github_testing.Comment(id, "k8s-bot", createdAt, "Failed:")
90+
return github_testing.Comment(id, "k8s-bot", createdAt, "Failed: something failed")
9191
}
9292

9393
func TestAutoPrioritize(t *testing.T) {

0 commit comments

Comments
 (0)