Skip to content

Commit

Permalink
dashboard/app: make email tests more interesting
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dvyukov committed Mar 18, 2019
1 parent 4656bec commit 08db114
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 9 deletions.
13 changes: 11 additions & 2 deletions dashboard/app/app_test.go
Expand Up @@ -103,6 +103,7 @@ var testConfig = &GlobalConfig{
{
Name: "reporting2",
DailyLimit: 3,
Filter: skipWithRepro2,
Config: &EmailConfig{
Email: "bugs@syzkaller.com",
DefaultMaintainers: []string{"default@maintainers.com"},
Expand All @@ -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,
},
},
Expand Down Expand Up @@ -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
}
Expand Down
10 changes: 8 additions & 2 deletions dashboard/app/bisect_test.go
Expand Up @@ -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()
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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",
})
Expand Down
9 changes: 6 additions & 3 deletions dashboard/app/email_test.go
Expand Up @@ -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,
Expand Down Expand Up @@ -446,7 +447,6 @@ func TestEmailUndup(t *testing.T) {
}

func TestEmailCrossReportingDup(t *testing.T) {
// TODO:
c := NewCtx(t)
defer c.Close()

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion dashboard/app/notifications_test.go
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion dashboard/app/util_test.go
Expand Up @@ -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:
Expand Down

0 comments on commit 08db114

Please sign in to comment.