runner: test the refusal of superseded from another seat and a dependent that stays

Review round 1: a node-build-go end naming superseded is refused as an
outcome the runner does not know, moving nothing; a dependent whose steps
ended not asked on a mover whose build ended superseded is taken out and
placed again.

Builds: design 47 H2 H-A-508 (and its addendum)
This commit is contained in:
2026-11-23 00:27:52 +01:00
parent 1a19c5c4c1
commit a2b916a896
@@ -1,6 +1,7 @@
package pipeline
import (
"errors"
"fmt"
"slices"
"strings"
@@ -58,8 +59,20 @@ func TestAPipelineWithNothingOpenEndsAtOnce(t *testing.T) {
{"its last open step, a build, ends superseded (H-A-508)",
[]seat.StepResult{step("a", seat.StepResultOutcomeRunning, "x1"), {Module: "a", Artifact: "program", Step: seat.StepResultStepUnit,
Status: seat.StepResultStatusRequired, Outcome: seat.StepResultOutcomeWaiting, Seat: "node-build-go"},
{Module: "a", Artifact: "program", Step: seat.StepResultStepLint, Status: seat.StepResultStatusRequired, Outcome: seat.StepResultOutcomeRunning,
Ask: "l1", Seat: "node-build-go"},
step("b", seat.StepResultOutcomePassed, "x2"), step("c", seat.StepResultOutcomePassed, "x3")},
func(t *testing.T, h *Hearer) {
// Another seat's end naming superseded is an outcome the runner does not know: refused, loud, nothing taken.
gs := stepSeatOf(t, "node-build-go")
lint := StepEnded{ID: "l1", Node: "n1", Pipeline: "main.117", Module: "a", Commit: "c1", Fingerprint: "src2:a1", Step: "lint",
Outcome: builds.StepEndedOutcomeSuperseded}
if _, err := h.OnStepEnded(gs, gs.Prefix+"n1", lint); !errors.Is(err, ErrRefused) || !strings.Contains(err.Error(), "not an outcome of step-ended") {
t.Errorf("a node-build-go end naming superseded: %v, want refused as no outcome of step-ended", err)
}
if p, _, _ := h.Store.Get("main.117"); p.Steps[2].Outcome != seat.StepResultOutcomeRunning {
t.Errorf("the refused end moved the lint step: %+v", p.Steps[2])
}
bs := stepSeatOf(t, builds.Seat)
end := StepEnded{ID: "x1", Node: "n1", Pipeline: "main.117", Module: "a", Commit: "c1", Fingerprint: "src2:a1", Step: "build",
Outcome: builds.StepEndedOutcomeSuperseded, Said: "a at src2:a1 is superseded by src2:a2, the newest entry heard on its first branch"}
@@ -68,8 +81,8 @@ func TestAPipelineWithNothingOpenEndsAtOnce(t *testing.T) {
}
p, _, _ := h.Store.Get("main.117")
if !slices.Equal(p.Superseded, []string{"a"}) || p.Steps[0].Outcome != seat.StepResultOutcomeSuperseded || !strings.Contains(p.Steps[0].Why, "src2:a2") ||
p.Steps[1].Outcome != seat.StepResultOutcomeSuperseded {
t.Errorf("after a's build ended superseded: superseded %v, steps %+v; want a left, its build and unit superseded naming src2:a2", p.Superseded, p.Steps[:2])
p.Steps[1].Outcome != seat.StepResultOutcomeSuperseded || p.Steps[2].Outcome != seat.StepResultOutcomeSuperseded {
t.Errorf("after a's build ended superseded: superseded %v, steps %+v; want a left, its build and unit superseded naming src2:a2", p.Superseded, p.Steps[:3])
}
}, seat.PipelineOutcomePassed},
{"its last open step ends could not run on the silent bound (H-A-243)",
@@ -145,4 +158,25 @@ func TestAPipelineWithNothingOpenEndsAtOnce(t *testing.T) {
}
})
}
// H-A-508, H-A-361: a dependent that stays, whose steps ended not asked on the mover whose build ended superseded, is
// taken out and placed again; the pipeline does not end on it, and the superseded build's end is said as its own step's.
t.Run("a dependent that stays is placed again when its dependency's build ends superseded", func(t *testing.T) {
store := memStore{"main.117": {p: seat.Pipeline{V: 1, Pipeline: "main.117", Branch: "main", Source: 117, Revision: 117, Outcome: seat.PipelineOutcomeRunning,
Movers: slices.Clone(movers[:2]), Steps: []seat.StepResult{step("b", seat.StepResultOutcomeNotAsked, ""), step("a", seat.StepResultOutcomeRunning, "x1")}}, rev: 1}}
e := store["main.117"]
e.p.Steps[0].Why = notBuiltWhy("a")
store["main.117"] = e
var released []string
h := &Hearer{Store: store, Say: func(string, any) error { return nil }, Now: func() time.Time { return t0 }, Release: func(key string) { released = append(released, key) }}
bs := stepSeatOf(t, builds.Seat)
got, err := h.OnStepEnded(bs, bs.Prefix+"n1", StepEnded{ID: "x1", Node: "n1", Pipeline: "main.117", Module: "a", Commit: "c1", Fingerprint: "src2:a1",
Step: "build", Outcome: builds.StepEndedOutcomeSuperseded, Said: "a at src2:a1 is superseded by src2:a2"})
if err != nil {
t.Fatal(err)
}
if got.Outcome != seat.PipelineOutcomeRunning || !slices.Equal(got.Superseded, []string{"a"}) || len(got.Steps) != 1 || got.Steps[0].Module != "a" ||
got.Steps[0].Outcome != seat.StepResultOutcomeSuperseded || !slices.Equal(released, []string{"main.117"}) {
t.Errorf("pipeline %s superseded %v steps %+v released %v; want running, a left, b taken out to be placed again", got.Outcome, got.Superseded, got.Steps, released)
}
})
}