From 0c7326f3a3d0b5d82cff24da03f232d53f672aba Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Mon, 2 Oct 2023 11:54:40 +0200 Subject: dashboard: fix a panic during fix candidate job generation The existing code fails if it's executed before we have finished the tree origin job for the tree where the fix is supposed to be applied to. Add a test. --- dashboard/app/tree.go | 4 ++++ dashboard/app/tree_test.go | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/dashboard/app/tree.go b/dashboard/app/tree.go index d6a2dcce5..07acde1fa 100644 --- a/dashboard/app/tree.go +++ b/dashboard/app/tree.go @@ -759,6 +759,10 @@ func crossTreeBisection(c context.Context, bug *Bug, return nil } _, successJob := bug.findResult(c, from.repo, wantNewAny{}, runOnHEAD{}) + if successJob == nil { + // The jobs is not done yet. + return nil + } if successJob.CrashTitle != "" { // The kernel tree is still crashed by the repro. return nil diff --git a/dashboard/app/tree_test.go b/dashboard/app/tree_test.go index 67390737b..f9109202f 100644 --- a/dashboard/app/tree_test.go +++ b/dashboard/app/tree_test.go @@ -363,6 +363,38 @@ For information about bisection process see: %URL%#bisection assert.NotContains(t, string(reply), treeTestCrashTitle) } +func TestNonfinalFixCandidateBisect(t *testing.T) { + c := NewCtx(t) + defer c.Close() + + ctx := setUpTreeTest(c, downstreamUpstreamRepos) + ctx.uploadBug(`https://downstream.repo/repo`, `master`, dashapi.ReproLevelC) + ctx.entries = []treeTestEntry{ + { + alias: `downstream`, + results: []treeTestEntryPeriod{{fromDay: 0, result: treeTestCrash}}, + }, + { + alias: `lts`, + mergeAlias: `downstream`, + results: []treeTestEntryPeriod{{fromDay: 0, result: treeTestCrash}}, + }, + { + alias: `upstream`, + // Ignore these jobs. + results: []treeTestEntryPeriod{}, + }, + } + ctx.jobTestDays = []int{10} + ctx.moveToDay(10) + ctx.reportToEmail() + ctx.ctx.advanceTime(time.Hour) + + // Ensure the code does not fail. + job := ctx.client.pollSpecificJobs(ctx.manager, dashapi.ManagerJobs{BisectFix: true}) + assert.Equal(t, "", job.ID) +} + func TestTreeBisectionBeforeOrigin(t *testing.T) { c := NewCtx(t) defer c.Close() @@ -1047,12 +1079,18 @@ func (ctx *treeTestCtx) doJob(resp *dashapi.JobPollResp, day int) { // Figure out what should the result be. result := treeTestOK build := testBuild(1) + var anyFound bool for _, item := range found.results { if day >= item.fromDay { result = item.result build.KernelCommit = item.commit + anyFound = true } } + if !anyFound { + // Just ignore the job. + return + } if build.KernelCommit == "" { build.KernelCommit = strings.Repeat("f", 40)[:40] } -- cgit mrf-deployment