dashboard/app: show patch testing requests on bug page

Fixes #1547
This commit is contained in:
Dmitry Vyukov 2020-05-08 15:40:27 +02:00
parent a788005625
commit e97b06d3ce
4 changed files with 101 additions and 65 deletions

View File

@ -23,62 +23,6 @@ Main page.
<br><br>
{{template "manager_list" $.Managers}}
<table class="list_table">
<caption id="jobs"><a class="plain" href="#jobs">Recent jobs:</a></caption>
<thead>
<tr>
<th>Bug</th>
<th>Created</th>
<th>Duration</th>
<th>User</th>
<th>Patch</th>
<th>Repo</th>
<th>Manager</th>
<th>Result</th>
</tr>
</thead>
<tbody>
{{range $job := $.Jobs}}
<tr>
<td class="title"><a href="{{$job.BugLink}}">{{$job.BugTitle}}</a></td>
<td class="time">{{link $job.ExternalLink (formatTime $job.Created)}}</td>
<td class="time" title="started: {{formatTime $job.Started}}&#013;finished: {{formatTime $job.Finished}}">
{{formatDuration $job.Duration}}{{if gt $job.Attempts 1}} ({{$job.Attempts}}){{end}}
</td>
<td>
{{if eq $job.Type 0}}
{{$job.User}}
{{else if eq $job.Type 1}}
bisect
{{else if eq $job.Type 2}}
bisect fix
{{end}}
</td>
<td>{{optlink $job.PatchLink "patch"}}</td>
<td class="kernel" title="{{$job.KernelAlias}}">{{$job.KernelAlias}}</td>
<td title="{{$job.Namespace}}/{{$job.Reporting}}">{{$job.Manager}}</td>
<td class="result">
{{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}}
</td>
</tr>
{{end}}
</tbody>
</table>
<br><br>
{{template "job_list" $.Jobs}}
</body>
</html>

View File

@ -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}}
<br><b>Sample crash report:</b><br>

View File

@ -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,

View File

@ -333,3 +333,66 @@ Use of this source code is governed by Apache 2 LICENSE that can be found in the
</table>
{{end}}
{{end}}
{{/* List of jobs, invoked with *uiJobList */}}
{{define "job_list"}}
{{if $.Jobs}}
<table class="list_table">
<caption id="jobs"><a class="plain" href="#jobs">{{if $.PerBug}}Patch testing requests:{{else}}Recent jobs:{{end}}</a></caption>
<thead>
<tr>
{{if not $.PerBug}}<th>Bug</th>{{end}}
<th>Created</th>
<th>Duration</th>
<th>User</th>
<th>Patch</th>
<th>Repo</th>
{{if not $.PerBug}}<th>Manager</th>{{end}}
<th>Result</th>
</tr>
</thead>
<tbody>
{{range $job := $.Jobs}}
<tr>
{{if not $.PerBug}}<td class="title"><a href="{{$job.BugLink}}">{{$job.BugTitle}}</a></td>{{end}}
<td class="time">{{link $job.ExternalLink (formatTime $job.Created)}}</td>
<td class="time" title="started: {{formatTime $job.Started}}&#013;finished: {{formatTime $job.Finished}}">
{{formatDuration $job.Duration}}{{if gt $job.Attempts 1}} ({{$job.Attempts}}){{end}}
</td>
<td>
{{if eq $job.Type 0}}
{{$job.User}}
{{else if eq $job.Type 1}}
bisect
{{else if eq $job.Type 2}}
bisect fix
{{end}}
</td>
<td>{{optlink $job.PatchLink "patch"}}</td>
<td class="kernel" title="{{$job.KernelAlias}}">{{$job.KernelAlias}}</td>
{{if not $.PerBug}}<td title="{{$job.Namespace}}/{{$job.Reporting}}">{{$job.Manager}}</td>{{end}}
<td class="result">
{{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}}
</td>
</tr>
{{end}}
</tbody>
</table>
{{end}}
{{end}}