diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2019-02-14 10:35:03 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2019-02-17 15:08:45 +0100 |
| commit | 3e98cc30803fb5e41504dd08b1325cb074a8a3f2 (patch) | |
| tree | 5f0a7a4702bedbb9706c158e09e4be1875894625 /dashboard/app/commit_poll_test.go | |
| parent | f42dee6d5e501a061cdbb807672361369bf28492 (diff) | |
dashboard/app: poll commits info
This implements 2 features:
- syz-ci polls a set of additional repos to discover fixing commits sooner
(e.g. it can now discover a fixing commit in netfilter tree before
it reaches any of the tested trees).
- syz-ci uploads info about commits to dashboard.
For example, a user marks a bug as fixed by commit "foo: bar".
syz-ci will find this commit in the main namespace repo
and upload commmit hash/date/author to dashboard. This in turn
allows to show links to fixing commits.
Fixes #691
Fixes #610
Diffstat (limited to 'dashboard/app/commit_poll_test.go')
| -rw-r--r-- | dashboard/app/commit_poll_test.go | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/dashboard/app/commit_poll_test.go b/dashboard/app/commit_poll_test.go new file mode 100644 index 000000000..48c86292f --- /dev/null +++ b/dashboard/app/commit_poll_test.go @@ -0,0 +1,94 @@ +// Copyright 2019 syzkaller project authors. All rights reserved. +// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. + +// +build aetest + +package dash + +import ( + "sort" + "testing" + + "github.com/google/syzkaller/dashboard/dashapi" +) + +func TestCommitPoll(t *testing.T) { + c := NewCtx(t) + defer c.Close() + + build1 := testBuild(1) + c.client.UploadBuild(build1) + + crash1 := testCrash(build1, 1) + c.client.ReportCrash(crash1) + rep1 := c.client.pollBug() + + crash2 := testCrash(build1, 2) + c.client.ReportCrash(crash2) + rep2 := c.client.pollBug() + + // No commits in commit poll. + commitPollResp, err := c.client.CommitPoll() + c.expectOK(err) + c.expectEQ(len(commitPollResp.Repos), 2) + c.expectEQ(commitPollResp.Repos[0].URL, testConfig.Namespaces["test1"].Repos[0].URL) + c.expectEQ(commitPollResp.Repos[0].Branch, testConfig.Namespaces["test1"].Repos[0].Branch) + c.expectEQ(commitPollResp.Repos[1].URL, testConfig.Namespaces["test1"].Repos[1].URL) + c.expectEQ(commitPollResp.Repos[1].Branch, testConfig.Namespaces["test1"].Repos[1].Branch) + c.expectEQ(len(commitPollResp.Commits), 0) + + // Specify fixing commit for the bug. + reply, _ := c.client.ReportingUpdate(&dashapi.BugUpdate{ + ID: rep1.ID, + Status: dashapi.BugStatusOpen, + FixCommits: []string{"foo: fix1", "foo: fix2"}, + }) + c.expectEQ(reply.OK, true) + + // The commit should appear in commit poll. + for i := 0; i < 2; i++ { + commitPollResp, err = c.client.CommitPoll() + c.expectOK(err) + c.expectEQ(len(commitPollResp.Commits), 2) + sort.Strings(commitPollResp.Commits) + c.expectEQ(commitPollResp.Commits[0], "foo: fix1") + c.expectEQ(commitPollResp.Commits[1], "foo: fix2") + } + + // Upload hash for the first commit and fixing commit for the second bug. + c.expectOK(c.client.UploadCommits([]dashapi.Commit{ + {Hash: "hash1", Title: "foo: fix1"}, + {Hash: "hash2", Title: "bar: fix3", BugIDs: []string{rep2.ID}}, + {Hash: "hash3", Title: "some unrelated commit", BugIDs: []string{"does not exist"}}, + {Hash: "hash4", Title: "another unrelated commit"}, + })) + + commitPollResp, err = c.client.CommitPoll() + c.expectOK(err) + c.expectEQ(len(commitPollResp.Commits), 2) + sort.Strings(commitPollResp.Commits) + c.expectEQ(commitPollResp.Commits[0], "foo: fix1") + c.expectEQ(commitPollResp.Commits[1], "foo: fix2") + + // Upload hash for the second commit and a new fixing commit for the second bug. + c.expectOK(c.client.UploadCommits([]dashapi.Commit{ + {Hash: "hash5", Title: "foo: fix2"}, + {Title: "bar: fix4", BugIDs: []string{rep2.ID}}, + })) + + commitPollResp, err = c.client.CommitPoll() + c.expectOK(err) + c.expectEQ(len(commitPollResp.Commits), 1) + c.expectEQ(commitPollResp.Commits[0], "bar: fix4") + + // Upload hash for the second commit and a new fixing commit for the second bug. + c.expectOK(c.client.UploadCommits([]dashapi.Commit{ + {Hash: "hash1", Title: "foo: fix1"}, + {Hash: "hash5", Title: "foo: fix2"}, + {Hash: "hash6", Title: "bar: fix4"}, + })) + + commitPollResp, err = c.client.CommitPoll() + c.expectOK(err) + c.expectEQ(len(commitPollResp.Commits), 0) +} |
