Skip to content

Commit 4878f74

Browse files
committed
dashboard: add a manuallyUpstreamed helper
This helper function can be used in the reporting filtering rules to skip certain reporting stages depending on whether the previous stage(s) have been manually upstreamed. Add tests that it does have the intended effect. Cc #6554.
1 parent 41cfbc0 commit 4878f74

File tree

3 files changed

+98
-0
lines changed

3 files changed

+98
-0
lines changed

dashboard/app/app_test.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,44 @@ var testConfig = &GlobalConfig{
631631
},
632632
},
633633
},
634+
"skip-stage": {
635+
AccessLevel: AccessPublic,
636+
Key: "publickeypublickeypublickey",
637+
Clients: map[string]string{
638+
clientSkipStage: keySkipStage,
639+
},
640+
Repos: []KernelRepo{
641+
{
642+
URL: "git://syzkaller.org/access-public.git",
643+
Branch: "access-public",
644+
Alias: "access-public",
645+
},
646+
},
647+
Reporting: []Reporting{
648+
{
649+
Name: "reporting1",
650+
DailyLimit: 1000,
651+
Config: &TestConfig{Index: 1},
652+
Embargo: 4 * 24 * time.Hour,
653+
},
654+
{
655+
Name: "reporting2",
656+
DailyLimit: 1000,
657+
Config: &TestConfig{Index: 2},
658+
Filter: func(bug *Bug) FilterResult {
659+
if bug.manuallyUpstreamed("reporting1") {
660+
return FilterSkip
661+
}
662+
return FilterReport
663+
},
664+
},
665+
{
666+
Name: "reporting3",
667+
DailyLimit: 1000,
668+
Config: &TestConfig{Index: 3},
669+
},
670+
},
671+
},
634672
},
635673
}
636674

@@ -683,6 +721,8 @@ const (
683721
keyTreeTests = "keyTreeTestskeyTreeTestskeyTreeTests"
684722
clientAI = "client-ai"
685723
keyAI = "clientaikeyclientaikeyclientaikey"
724+
clientSkipStage = "client-skip-stage"
725+
keySkipStage = "skipstagekeyskipstagekeyskipstagekey"
686726

687727
restrictedManager = "restricted-manager"
688728
noFixBisectionManager = "no-fix-bisection-manager"

dashboard/app/reporting.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,14 @@ func (bug *Bug) managerConfig(c context.Context) *ConfigManager {
387387
return &mgr
388388
}
389389

390+
func (bug *Bug) manuallyUpstreamed(name string) bool {
391+
reporting := bugReportingByName(bug, name)
392+
if reporting == nil {
393+
return false
394+
}
395+
return !reporting.Closed.IsZero() && !reporting.Auto
396+
}
397+
390398
func createNotification(c context.Context, typ dashapi.BugNotif, public bool, text string, bug *Bug,
391399
reporting *Reporting, bugReporting *BugReporting) (*dashapi.BugNotification, error) {
392400
reportingConfig, err := json.Marshal(reporting.Config)

dashboard/app/reporting_test.go

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1417,3 +1417,53 @@ Blocks diff, Path
14171417
14181418
`, msg.Body)
14191419
}
1420+
1421+
func TestSkipStage(t *testing.T) {
1422+
// The test ensures that manuallyUpstreamed works as intended in reporting filters.
1423+
c := NewCtx(t)
1424+
defer c.Close()
1425+
client := c.makeClient(clientSkipStage, keySkipStage, true)
1426+
1427+
build := testBuild(1)
1428+
client.UploadBuild(build)
1429+
1430+
{
1431+
// Normal scenario - manual upstreaming.
1432+
client.ReportCrash(testCrash(build, 1))
1433+
rep := client.pollBug()
1434+
c.expectEQ(string(rep.Config), `{"Index":1}`)
1435+
c.client.updateBug(rep.ID, dashapi.BugStatusUpstream, "")
1436+
client.pollNotifs(0)
1437+
rep = client.pollBug()
1438+
c.expectEQ(string(rep.Config), `{"Index":3}`)
1439+
c.client.updateBug(rep.ID, dashapi.BugStatusInvalid, "")
1440+
}
1441+
1442+
{
1443+
// Auto-upstreamed.
1444+
client.ReportCrash(testCrash(build, 2))
1445+
rep := client.pollBug()
1446+
c.expectEQ(string(rep.Config), `{"Index":1}`)
1447+
c.advanceTime(5 * 24 * time.Hour)
1448+
notifs := client.pollNotifs(1)
1449+
reply, _ := client.ReportingUpdate(&dashapi.BugUpdate{
1450+
ID: notifs[0].ID,
1451+
Status: dashapi.BugStatusUpstream,
1452+
Notification: true,
1453+
})
1454+
c.expectEQ(reply.OK, true)
1455+
rep = client.pollBug()
1456+
c.expectEQ(string(rep.Config), `{"Index":2}`)
1457+
c.client.updateBug(rep.ID, dashapi.BugStatusInvalid, "")
1458+
}
1459+
1460+
{
1461+
// Manually invalidated.
1462+
client.ReportCrash(testCrash(build, 3))
1463+
rep := client.pollBug()
1464+
c.expectEQ(string(rep.Config), `{"Index":1}`)
1465+
c.client.updateBug(rep.ID, dashapi.BugStatusInvalid, "")
1466+
client.pollNotifs(0)
1467+
client.pollBugs(0)
1468+
}
1469+
}

0 commit comments

Comments
 (0)