From 3f1c29d938900aa03cb6233aa857049a9841b7c2 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Tue, 19 Mar 2019 16:37:21 +0100 Subject: dashboard/app: report bisection results to external reporting Update #501 --- dashboard/app/bisect_test.go | 42 +++++++++++++++++++++++++++++++++++++ dashboard/app/reporting_external.go | 17 +++++++++++++++ dashboard/app/util_test.go | 1 + dashboard/dashapi/dashapi.go | 3 ++- 4 files changed, 62 insertions(+), 1 deletion(-) diff --git a/dashboard/app/bisect_test.go b/dashboard/app/bisect_test.go index f944cd57b..0f1002acd 100644 --- a/dashboard/app/bisect_test.go +++ b/dashboard/app/bisect_test.go @@ -500,3 +500,45 @@ https://goo.gl/tpsmEJ#testing-patches`, bisectLogLink, bisectCrashReportLink, bisectCrashLogLink)) } } + +func TestBisectCauseExternal(t *testing.T) { + c := NewCtx(t) + defer c.Close() + + build := testBuild(1) + c.client.UploadBuild(build) + crash := testCrashWithRepro(build, 1) + c.client.ReportCrash(crash) + rep := c.client.pollBug() + + pollResp, err := c.client.JobPoll([]string{build.Manager}) + c.expectOK(err) + jobID := pollResp.ID + done := &dashapi.JobDoneReq{ + ID: jobID, + Build: *build, + Log: []byte("bisect log"), + Commits: []dashapi.Commit{ + { + Hash: "111111111111111111111111", + Title: "kernel: break build", + Author: "hacker@kernel.org", + AuthorName: "Hacker Kernelov", + CC: []string{"reviewer1@kernel.org", "reviewer2@kernel.org"}, + Date: time.Date(2000, 2, 9, 4, 5, 6, 7, time.UTC), + }, + }, + } + done.Build.ID = jobID + c.expectOK(c.client2.JobDone(done)) + + resp, _ := c.client.ReportingPollBugs("test") + c.expectEQ(len(resp.Reports), 1) + // Still reported because we did not ack. + bisect := c.client.pollBug() + // pollBug acks, must not be reported after that. + c.client.pollBugs(0) + + c.expectEQ(bisect.Type, dashapi.ReportBisectCause) + c.expectEQ(bisect.Title, rep.Title) +} diff --git a/dashboard/app/reporting_external.go b/dashboard/app/reporting_external.go index 4dd85e87f..846f1f3c9 100644 --- a/dashboard/app/reporting_external.go +++ b/dashboard/app/reporting_external.go @@ -34,6 +34,11 @@ func apiReportingPollBugs(c context.Context, r *http.Request, payload []byte) (i resp := &dashapi.PollBugsResponse{ Reports: reports, } + jobs, err := pollCompletedJobs(c, req.Type) + if err != nil { + log.Errorf(c, "failed to poll jobs: %v", err) + } + resp.Reports = append(resp.Reports, jobs...) return resp, nil } @@ -70,6 +75,18 @@ func apiReportingUpdate(c context.Context, r *http.Request, payload []byte) (int if err := json.Unmarshal(payload, req); err != nil { return nil, fmt.Errorf("failed to unmarshal request: %v", err) } + if req.JobID != "" { + resp := &dashapi.BugUpdateReply{ + OK: true, + Error: false, + } + if err := jobReported(c, req.JobID); err != nil { + log.Errorf(c, "failed to mark job reported: %v", err) + resp.Text = err.Error() + resp.Error = true + } + return resp, nil + } ok, reason, err := incomingCommand(c, req) return &dashapi.BugUpdateReply{ OK: ok, diff --git a/dashboard/app/util_test.go b/dashboard/app/util_test.go index d61fa0caf..40ab3f1e1 100644 --- a/dashboard/app/util_test.go +++ b/dashboard/app/util_test.go @@ -302,6 +302,7 @@ func (client *apiClient) pollBugs(expect int) []*dashapi.BugReport { } reply, _ := client.ReportingUpdate(&dashapi.BugUpdate{ ID: rep.ID, + JobID: rep.JobID, Status: dashapi.BugStatusOpen, ReproLevel: reproLevel, CrashID: rep.CrashID, diff --git a/dashboard/dashapi/dashapi.go b/dashboard/dashapi/dashapi.go index 006ed1ce7..24f2a87a1 100644 --- a/dashboard/dashapi/dashapi.go +++ b/dashboard/dashapi/dashapi.go @@ -332,7 +332,8 @@ type BisectResult struct { } type BugUpdate struct { - ID string + ID string // copied from BugReport + JobID string // copied from BugReport ExtID string Link string Status BugStatus -- cgit mrf-deployment