dashboard/app: make email tests more interesting

1. Mail bugs for second and third reportings to different emails
   so that it's possible to distinguish where they are actually mailed.
2. Add bisection test where we skip bug in the second reporting.
   Bisection results should go straigth to third as well.
This commit is contained in:
Dmitry Vyukov 2019-03-18 09:51:33 +01:00
parent 4656becafb
commit 08db11409e
5 changed files with 27 additions and 9 deletions

View File

@ -103,6 +103,7 @@ var testConfig = &GlobalConfig{
{
Name: "reporting2",
DailyLimit: 3,
Filter: skipWithRepro2,
Config: &EmailConfig{
Email: "bugs@syzkaller.com",
DefaultMaintainers: []string{"default@maintainers.com"},
@ -113,8 +114,8 @@ var testConfig = &GlobalConfig{
Name: "reporting3",
DailyLimit: 3,
Config: &EmailConfig{
Email: "bugs@syzkaller.com",
DefaultMaintainers: []string{"default@maintainers.com"},
Email: "bugs2@syzkaller.com",
DefaultMaintainers: []string{"default2@maintainers.com"},
MailMaintainers: true,
},
},
@ -219,6 +220,14 @@ func skipWithRepro(bug *Bug) FilterResult {
return FilterReport
}
func skipWithRepro2(bug *Bug) FilterResult {
if strings.HasPrefix(bug.Title, "skip reporting2 with repro") &&
bug.ReproLevel != dashapi.ReproLevelNone {
return FilterSkip
}
return FilterReport
}
type TestConfig struct {
Index int
}

View File

@ -42,6 +42,7 @@ func TestBisectCause(t *testing.T) {
// This does not have C repro, so will be bisected after the previous ones.
c.advanceTime(time.Hour)
crash4 := testCrashWithRepro(build, 4)
crash4.Title = "skip reporting2 with repro"
crash4.ReproC = nil
c.client2.ReportCrash(crash4)
msg4 := c.client2.pollEmailBug()
@ -220,8 +221,13 @@ https://goo.gl/tpsmEJ#testing-patches`,
}
// Crash 4 is bisected in reporting with MailMaintainers.
// It also skipped second reporting beacuse of the title.
c.incomingEmail(msg4.Sender, "#syz upstream")
msg4 = c.pollEmailBug()
c.expectEQ(msg4.To, []string{
"bugs2@syzkaller.com",
"default2@maintainers.com",
})
pollResp, _ = c.client2.JobPoll([]string{build.Manager})
// Bisection succeeded.
@ -258,8 +264,8 @@ https://goo.gl/tpsmEJ#testing-patches`,
c.expectEQ(msg.Subject, crash4.Title)
c.expectEQ(msg.To, []string{
"author@kernel.org",
"bugs@syzkaller.com",
"default@maintainers.com",
"bugs2@syzkaller.com",
"default2@maintainers.com",
"reviewer1@kernel.org",
"reviewer2@kernel.org",
})

View File

@ -133,7 +133,8 @@ For more options, visit https://groups.google.com/d/optout.
kernelConfigLink := externalLink(c.ctx, textKernelConfig, dbBuild.KernelConfig)
c.expectEQ(sender, fromAddr(c.ctx))
to := []string{
"bugs@syzkaller.com",
"bugs2@syzkaller.com",
"bugs@syzkaller.com", // This is from incomingEmail.
"default@sender.com", // This is from incomingEmail.
"foo@bar.com",
config.Namespaces["test2"].Reporting[0].Config.(*EmailConfig).Email,
@ -446,7 +447,6 @@ func TestEmailUndup(t *testing.T) {
}
func TestEmailCrossReportingDup(t *testing.T) {
// TODO:
c := NewCtx(t)
defer c.Close()
@ -491,7 +491,10 @@ func TestEmailCrossReportingDup(t *testing.T) {
c.incomingEmail(bugSender, "#syz dup: "+crash2.Title)
if test.result {
c.expectEQ(len(c.emailSink), 0)
if len(c.emailSink) != 0 {
msg := <-c.emailSink
t.Fatalf("unexpected reply: %s\n%s\n", msg.Subject, msg.Body)
}
} else {
c.expectEQ(len(c.emailSink), 1)
msg := <-c.emailSink

View File

@ -158,7 +158,7 @@ func TestEmailNotifObsoleted(t *testing.T) {
if !strings.Contains(notif.Body, "Auto-closing this bug as obsolete") {
t.Fatalf("bad notification text: %q", notif.Body)
}
c.expectEQ(notif.To, []string{"bugs@syzkaller.com"})
c.expectEQ(notif.To, []string{"bugs2@syzkaller.com"})
}
func TestEmailNotifNotObsoleted(t *testing.T) {

View File

@ -358,7 +358,7 @@ type (
func (c *Ctx) incomingEmail(to, body string, opts ...interface{}) {
id := 0
from := "default@sender.com"
cc := []string{"test@syzkaller.com", "bugs@syzkaller.com"}
cc := []string{"test@syzkaller.com", "bugs@syzkaller.com", "bugs2@syzkaller.com"}
for _, o := range opts {
switch opt := o.(type) {
case EmailOptMessageID: