Skip to content

Commit fd2207e

Browse files
committed
syz-cluster: add link to download the whole series
This will simplify debugging of mistriaged patch series that ended up either not applying anywhere or ended up with a build error.
1 parent ba25b32 commit fd2207e

File tree

3 files changed

+54
-1
lines changed

3 files changed

+54
-1
lines changed

syz-cluster/dashboard/handler.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ func (h *dashboardHandler) Mux() *http.ServeMux {
6767
mux.HandleFunc("/sessions/{id}/triage_log", errToStatus(h.sessionTriageLog))
6868
mux.HandleFunc("/sessions/{id}/test_logs", errToStatus(h.sessionTestLog))
6969
mux.HandleFunc("/sessions/{id}/test_artifacts", errToStatus(h.sessionTestArtifacts))
70+
mux.HandleFunc("/series/{id}/all_patches", errToStatus(h.allPatches))
7071
mux.HandleFunc("/series/{id}", errToStatus(h.seriesInfo))
7172
mux.HandleFunc("/patches/{id}", errToStatus(h.patchContent))
7273
mux.HandleFunc("/findings/{id}/{key}", errToStatus(h.findingInfo))
@@ -301,6 +302,28 @@ func (h *dashboardHandler) patchContent(w http.ResponseWriter, r *http.Request)
301302
return h.streamBlob(w, patch.BodyURI)
302303
}
303304

305+
// nolint:dupl
306+
func (h *dashboardHandler) allPatches(w http.ResponseWriter, r *http.Request) error {
307+
ctx := r.Context()
308+
series, err := h.seriesRepo.GetByID(ctx, r.PathValue("id"))
309+
if err != nil {
310+
return fmt.Errorf("failed to query series: %w", err)
311+
} else if series == nil {
312+
return fmt.Errorf("%w: series", errNotFound)
313+
}
314+
patches, err := h.seriesRepo.ListPatches(ctx, series)
315+
if err != nil {
316+
return fmt.Errorf("failed to query patches: %w", err)
317+
}
318+
for _, patch := range patches {
319+
err = h.streamBlob(w, patch.BodyURI)
320+
if err != nil {
321+
return err
322+
}
323+
}
324+
return nil
325+
}
326+
304327
func (h *dashboardHandler) findingInfo(w http.ResponseWriter, r *http.Request) error {
305328
finding, err := h.findingRepo.GetByID(r.Context(), r.PathValue("id"))
306329
if err != nil {

syz-cluster/dashboard/handler_test.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,36 @@ func TestURLs(t *testing.T) {
5454
}
5555
}
5656

57+
func TestAllPatches(t *testing.T) {
58+
env, ctx := app.TestEnvironment(t)
59+
client := controller.TestServer(t, env)
60+
testSeries := &api.Series{
61+
ExtID: "ext-id",
62+
Title: "test series name",
63+
Link: "http://link/to/series",
64+
Patches: []api.SeriesPatch{
65+
{
66+
Seq: 1,
67+
Title: "first patch title",
68+
Body: []byte("first content\n"),
69+
},
70+
{
71+
Seq: 2,
72+
Title: "second patch title",
73+
Body: []byte("second content\n"),
74+
},
75+
},
76+
}
77+
ids := controller.UploadTestSeries(t, ctx, client, testSeries)
78+
_, baseURL := testServer(t, env)
79+
80+
resp, err := http.Get(baseURL + "/series/" + ids.SeriesID + "/all_patches")
81+
body, _ := io.ReadAll(resp.Body)
82+
resp.Body.Close()
83+
assert.NoError(t, err)
84+
assert.Equal(t, "first content\nsecond content\n", string(body))
85+
}
86+
5787
func testServer(t *testing.T, env *app.AppEnvironment) (*dashboardHandler, string) {
5888
handler, err := newHandler(env)
5989
require.NoError(t, err)

syz-cluster/dashboard/templates/series.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ <h3>Patches ({{.TotalPatches}})</h3>
7171
<thead>
7272
<tr>
7373
<th>Name</th>
74-
<th>Content</th>
74+
<th>Content <a href="/series/{{.ID}}/all_patches">[All]</a></th>
7575
</tr>
7676
</thead>
7777
<tbody>

0 commit comments

Comments
 (0)