From e97b06d3cef9296e9d0e827c42bccdd36b555986 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Fri, 8 May 2020 15:40:27 +0200 Subject: dashboard/app: show patch testing requests on bug page Fixes #1547 --- dashboard/app/admin.html | 58 +--------------------------------------- dashboard/app/bug.html | 1 + dashboard/app/main.go | 44 +++++++++++++++++++++++++------ dashboard/app/templates.html | 63 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 101 insertions(+), 65 deletions(-) diff --git a/dashboard/app/admin.html b/dashboard/app/admin.html index edbdc9f7e..172070821 100644 --- a/dashboard/app/admin.html +++ b/dashboard/app/admin.html @@ -23,62 +23,6 @@ Main page.

{{template "manager_list" $.Managers}} - - - - - - - - - - - - - - - - - {{range $job := $.Jobs}} - - - - - - - - - - - {{end}} - -
Recent jobs:
BugCreatedDurationUserPatchRepoManagerResult
{{$job.BugTitle}}{{link $job.ExternalLink (formatTime $job.Created)}} - {{formatDuration $job.Duration}}{{if gt $job.Attempts 1}} ({{$job.Attempts}}){{end}} - - {{if eq $job.Type 0}} - {{$job.User}} - {{else if eq $job.Type 1}} - bisect - {{else if eq $job.Type 2}} - bisect fix - {{end}} - {{optlink $job.PatchLink "patch"}}{{$job.KernelAlias}}{{$job.Manager}} - {{if $job.ErrorLink}} - {{link $job.ErrorLink "error"}} - {{else if $job.LogLink}} - {{link $job.LogLink "log"}} - ({{if $job.Commit}}1{{else}}{{len $job.Commits}}{{end}}) - {{else if $job.CrashTitle}} - {{optlink $job.CrashReportLink "report"}} - {{optlink $job.CrashLogLink "log"}} - {{else if formatTime $job.Finished}} - OK - {{else if formatTime $job.Started}} - running - {{else}} - pending - {{end}} -
-

+ {{template "job_list" $.Jobs}} diff --git a/dashboard/app/bug.html b/dashboard/app/bug.html index e09ed7e98..96a75389e 100644 --- a/dashboard/app/bug.html +++ b/dashboard/app/bug.html @@ -31,6 +31,7 @@ Page with details about a single bug. {{template "bug_list" .DupOf}} {{template "bug_list" .Dups}} {{template "bug_list" .Similar}} + {{template "job_list" .TestPatchJobs}} {{if .SampleReport}}
Sample crash report:
diff --git a/dashboard/app/main.go b/dashboard/app/main.go index 151afe91f..5bdceec24 100644 --- a/dashboard/app/main.go +++ b/dashboard/app/main.go @@ -63,7 +63,7 @@ type uiAdminPage struct { Header *uiHeader Log []byte Managers []*uiManager - Jobs []*uiJob + Jobs *uiJobList } type uiManager struct { @@ -120,6 +120,7 @@ type uiBugPage struct { SampleReport []byte Crashes *uiCrashTable FixBisections *uiCrashTable + TestPatchJobs *uiJobList } type uiBugGroup struct { @@ -135,6 +136,11 @@ type uiBugGroup struct { Bugs []*uiBug } +type uiJobList struct { + PerBug bool + Jobs []*uiJob +} + type uiBug struct { Namespace string Title string @@ -306,7 +312,7 @@ func handleAdmin(c context.Context, w http.ResponseWriter, r *http.Request) erro Header: hdr, Log: errorLog, Managers: managers, - Jobs: jobs, + Jobs: &uiJobList{Jobs: jobs}, } return serveTemplate(w, "admin.html", data) } @@ -384,6 +390,10 @@ func handleBug(c context.Context, w http.ResponseWriter, r *http.Request) error return err } } + testPatchJobs, err := loadTestPatchJobs(c, bug) + if err != nil { + return err + } data := &uiBugPage{ Header: hdr, Now: timeNow(c), @@ -395,6 +405,10 @@ func handleBug(c context.Context, w http.ResponseWriter, r *http.Request) error Similar: similar, SampleReport: sampleReport, Crashes: crashesTable, + TestPatchJobs: &uiJobList{ + PerBug: true, + Jobs: testPatchJobs, + }, } // bug.BisectFix is set to BisectNot in two cases : // - no fix bisections have been performed on the bug @@ -429,15 +443,10 @@ func findBugByID(c context.Context, r *http.Request) (*Bug, error) { } func getUIJob(c context.Context, bug *Bug, jobType JobType) (*uiJob, error) { - job, _, jobKey, _, err := loadBisectJob(c, bug, jobType) + job, crash, jobKey, _, err := loadBisectJob(c, bug, jobType) if err != nil { return nil, err } - crash := new(Crash) - crashKey := db.NewKey(c, "Crash", "", job.CrashID, bug.key(c)) - if err := db.Get(c, crashKey, crash); err != nil { - return nil, fmt.Errorf("failed to get crash: %v", err) - } build, err := loadBuild(c, bug.Namespace, crash.BuildID) if err != nil { return nil, err @@ -1061,6 +1070,25 @@ func loadRecentJobs(c context.Context) ([]*uiJob, error) { return results, nil } +func loadTestPatchJobs(c context.Context, bug *Bug) ([]*uiJob, error) { + bugKey := bug.key(c) + var jobs []*Job + keys, err := db.NewQuery("Job"). + Ancestor(bugKey). + Filter("Type=", JobTestPatch). + Filter("Finished>=", time.Time{}). + Order("-Finished"). + GetAll(c, &jobs) + if err != nil { + return nil, err + } + var results []*uiJob + for i, job := range jobs { + results = append(results, makeUIJob(job, keys[i], nil, nil, nil)) + } + return results, nil +} + func makeUIJob(job *Job, jobKey *db.Key, bug *Bug, crash *Crash, build *Build) *uiJob { ui := &uiJob{ Type: job.Type, diff --git a/dashboard/app/templates.html b/dashboard/app/templates.html index 441b07dfe..163df1d2f 100644 --- a/dashboard/app/templates.html +++ b/dashboard/app/templates.html @@ -333,3 +333,66 @@ Use of this source code is governed by Apache 2 LICENSE that can be found in the {{end}} {{end}} + + + +{{/* List of jobs, invoked with *uiJobList */}} +{{define "job_list"}} +{{if $.Jobs}} + + + + + {{if not $.PerBug}}{{end}} + + + + + + {{if not $.PerBug}}{{end}} + + + + + {{range $job := $.Jobs}} + + {{if not $.PerBug}}{{end}} + + + + + + {{if not $.PerBug}}{{end}} + + + {{end}} + +
{{if $.PerBug}}Patch testing requests:{{else}}Recent jobs:{{end}}
BugCreatedDurationUserPatchRepoManagerResult
{{$job.BugTitle}}{{link $job.ExternalLink (formatTime $job.Created)}} + {{formatDuration $job.Duration}}{{if gt $job.Attempts 1}} ({{$job.Attempts}}){{end}} + + {{if eq $job.Type 0}} + {{$job.User}} + {{else if eq $job.Type 1}} + bisect + {{else if eq $job.Type 2}} + bisect fix + {{end}} + {{optlink $job.PatchLink "patch"}}{{$job.KernelAlias}}{{$job.Manager}} + {{if $job.ErrorLink}} + {{link $job.ErrorLink "error"}} + {{else if $job.LogLink}} + {{link $job.LogLink "log"}} + ({{if $job.Commit}}1{{else}}{{len $job.Commits}}{{end}}) + {{else if $job.CrashTitle}} + {{optlink $job.CrashReportLink "report"}} + {{optlink $job.CrashLogLink "log"}} + {{else if formatTime $job.Finished}} + OK + {{else if formatTime $job.Started}} + running + {{else}} + pending + {{end}} +
+{{end}} +{{end}} -- cgit mrf-deployment