mesh-delivery-pipeline: the place's plan adopts the head's commit; a step's end is matched by ask, module and fingerprint (H-A-769)
Builds: design 47 H2 H-A-769 (1), (2), H-A-768, H-A-530
This commit is contained in:
@@ -409,8 +409,10 @@ func (v Verbs) planUnfinished(key string) (handPlan, error) {
|
|||||||
}
|
}
|
||||||
half := head
|
half := head
|
||||||
group := v.closedGroup(from, module, half.Entries)
|
group := v.closedGroup(from, module, half.Entries)
|
||||||
|
from.Movers = slices.Clone(from.Movers)
|
||||||
plan := handPlan{from: from, group: group, entries: half.Entries}
|
plan := handPlan{from: from, group: group, entries: half.Entries}
|
||||||
for _, g := range group {
|
for _, g := range group {
|
||||||
|
adoptHead(&from, g, half.Entries) // a mover joins the head at the head's commit (design 47 H2 H-A-769 (1), H-A-768)
|
||||||
mv, _ := MoverOf(from, g)
|
mv, _ := MoverOf(from, g)
|
||||||
plan.movers = append(plan.movers, mv)
|
plan.movers = append(plan.movers, mv)
|
||||||
if k := UnfinishedKey(branch, g); slices.ContainsFunc(unfinishedOf(from), func(x string) bool { return x == g }) {
|
if k := UnfinishedKey(branch, g); slices.ContainsFunc(unfinishedOf(from), func(x string) bool { return x == g }) {
|
||||||
|
|||||||
@@ -592,3 +592,35 @@ func TestAReopenedGroupIsClosedOverTheHeadsEdges(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// design 47 H2 H-A-769 (1): the plan of runner_unfinished_place takes each mover's commit and repository from the head's entry at its
|
||||||
|
// fingerprint, so a group that joins the head's running pipeline joins it at the head's commit; H-A-769 (2): a step's end at the commit
|
||||||
|
// it was asked at is taken after the record adopted a newer one.
|
||||||
|
func TestAPlacedGroupJoinsTheHeadAtTheHeadsCommit(t *testing.T) {
|
||||||
|
_, entries := placeFixture()
|
||||||
|
e := entries["app"]
|
||||||
|
e.Fp, e.Commit, e.Repository = "src2:ab", "c2", "o/app-moved"
|
||||||
|
head := Half{Revision: 13, Source: 41, Entries: map[string]catalog.CatalogEntry{"app": e}}
|
||||||
|
store := &MoverStore{Raw: newMemRaw()}
|
||||||
|
end := time.Unix(50, 0)
|
||||||
|
old := seat.Pipeline{V: 1, Pipeline: Key("main", 10), Branch: "main", Revision: 10, Source: 41, Outcome: seat.PipelineOutcomeFailed, Ended: &end, EndCount: 1,
|
||||||
|
Movers: []seat.Mover{{Module: "app", Commit: "c1", Fingerprint: "src2:ab", Repository: "o/app"}}}
|
||||||
|
raw, _ := json.Marshal(old)
|
||||||
|
if err := store.Create(old.Pipeline, raw); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
u := memUnfinished{"main.app": `{"fingerprint":"src2:ab","revision":10,"pipeline":"` + old.Pipeline + `","outcome":"failed"}`}
|
||||||
|
s := &Starter{Pipelines: store, Store: store, Name: "the-runner", Now: ticking(), Say: func(string, any) error { return nil }}
|
||||||
|
s.Unfinished = &Unfinished{Store: u, Kept: func(string) map[string]int64 { return nil }}
|
||||||
|
v := Verbs{Starter: s, View: func(string) (Half, bool) { return head, true }}
|
||||||
|
plan, err := v.planUnfinished("main.app")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if len(plan.movers) != 1 || plan.movers[0].Commit != "c2" || plan.movers[0].Repository != "o/app-moved" {
|
||||||
|
t.Errorf("the plan's movers = %+v, want app at the head entry's commit c2 of o/app-moved", plan.movers)
|
||||||
|
}
|
||||||
|
if m, _ := MoverOf(old, "app"); m.Commit != "c1" {
|
||||||
|
t.Errorf("the pipeline read was changed: %+v", m)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -306,6 +306,7 @@ func (h *Hearer) OnStepEndedRevised(bs StepSeat, subject string, ev StepEnded, s
|
|||||||
return seat.Pipeline{}, fmt.Errorf("%w: ask %s names pipeline %q, which the runner cannot read: %v", ErrRefused, ev.ID, ev.Pipeline, err)
|
return seat.Pipeline{}, fmt.Errorf("%w: ask %s names pipeline %q, which the runner cannot read: %v", ErrRefused, ev.ID, ev.Pipeline, err)
|
||||||
}
|
}
|
||||||
i := stepOfAsk(p, ev.ID)
|
i := stepOfAsk(p, ev.ID)
|
||||||
|
// A step's end is matched by its ask, module and fingerprint, never by the commit (design 47 H2 H-A-769 (2), H-A-530).
|
||||||
// The validate ask is the pipeline's one, naming no mover (H-A-51): its end, naming the mover whose body the holder
|
// The validate ask is the pipeline's one, naming no mover (H-A-51): its end, naming the mover whose body the holder
|
||||||
// took, is matched by its ask alone and ends every mover's validate step under it (H-A-252).
|
// took, is matched by its ask alone and ends every mover's validate step under it (H-A-252).
|
||||||
oneValidate := i >= 0 && p.Steps[i].Step == seat.StepResultStepValidate && p.Steps[i].Seat == wants.Seat
|
oneValidate := i >= 0 && p.Steps[i].Step == seat.StepResultStepValidate && p.Steps[i].Seat == wants.Seat
|
||||||
@@ -321,7 +322,7 @@ func (h *Hearer) OnStepEndedRevised(bs StepSeat, subject string, ev StepEnded, s
|
|||||||
return p, fmt.Errorf("%w: pipeline %s asked no step under ask %s", ErrRefused, ev.Pipeline, ev.ID)
|
return p, fmt.Errorf("%w: pipeline %s asked no step under ask %s", ErrRefused, ev.Pipeline, ev.ID)
|
||||||
case p.Steps[i].Seat != bs.Seat:
|
case p.Steps[i].Seat != bs.Seat:
|
||||||
return p, fmt.Errorf("%w: ask %s was asked of %s, not %s", ErrRefused, ev.ID, p.Steps[i].Seat, bs.Seat)
|
return p, fmt.Errorf("%w: ask %s was asked of %s, not %s", ErrRefused, ev.ID, p.Steps[i].Seat, bs.Seat)
|
||||||
case ev.Step != p.Steps[i].Step || (!oneValidate && (ev.Commit != m.Commit || ev.Fingerprint != m.Fingerprint || ev.Module != m.Module)):
|
case ev.Step != p.Steps[i].Step || (!oneValidate && (ev.Fingerprint != m.Fingerprint || ev.Module != m.Module)):
|
||||||
return p, fmt.Errorf("%w: ask %s ended %s of %s at %s (%s), asked as %s of %s at %s (%s)", ErrRefused, ev.ID, ev.Step,
|
return p, fmt.Errorf("%w: ask %s ended %s of %s at %s (%s), asked as %s of %s at %s (%s)", ErrRefused, ev.ID, ev.Step,
|
||||||
ev.Module, ev.Commit, ev.Fingerprint, p.Steps[i].Step, p.Steps[i].Module, m.Commit, m.Fingerprint)
|
ev.Module, ev.Commit, ev.Fingerprint, p.Steps[i].Step, p.Steps[i].Module, m.Commit, m.Fingerprint)
|
||||||
case !open(p.Steps[i]):
|
case !open(p.Steps[i]):
|
||||||
|
|||||||
@@ -592,3 +592,18 @@ func TestEachStepEndWritesItsLineOnce(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// design 47 H2 H-A-769 (2): a step's end is matched by its ask, module and fingerprint, not by the mover's commit: a mover adopted at c2
|
||||||
|
// while its step asked at c1 runs has that end taken.
|
||||||
|
func TestAStepEndAtTheAskedCommitIsTakenAfterTheMoverAdoptedANewOne(t *testing.T) {
|
||||||
|
h, store, _, _, _ := fixture()
|
||||||
|
e := store[pkey]
|
||||||
|
e.p.Movers = []seat.Mover{{Module: "app", Commit: "c2", Fingerprint: "src2:aa"}}
|
||||||
|
store[pkey] = e
|
||||||
|
if _, err := h.OnStepEnded(goSeat, goSeat.Prefix+"n1", ended("a1", "lint", "passed")); err != nil {
|
||||||
|
t.Fatalf("the end at c1 of a step asked at c1 = %v, want it taken", err)
|
||||||
|
}
|
||||||
|
if store[pkey].p.Steps[0].Outcome != seat.StepResultOutcomePassed {
|
||||||
|
t.Errorf("the step = %s, want passed", store[pkey].p.Steps[0].Outcome)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user