diff --git a/modules/mesh-delivery-pipeline/internal/pipeline/repin_test.go b/modules/mesh-delivery-pipeline/internal/pipeline/repin_test.go index 1b2fd1edd..ab1528795 100644 --- a/modules/mesh-delivery-pipeline/internal/pipeline/repin_test.go +++ b/modules/mesh-delivery-pipeline/internal/pipeline/repin_test.go @@ -593,34 +593,52 @@ 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. +// design 47 H2 H-A-769 (1): runner_unfinished_place joins a group the head's running pipeline at the head's entry's commit: the head +// pipeline's mover is at c2 and its build ask names c2, whatever commit the ended pipeline's record held. func TestAPlacedGroupJoinsTheHeadAtTheHeadsCommit(t *testing.T) { - _, entries := placeFixture() + reg, 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}} + head := Half{Revision: 13, Source: 42, Entries: map[string]catalog.CatalogEntry{"app": e, "mesh-build-go": entries["mesh-build-go"]}} 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) + running := seat.Pipeline{V: 1, Pipeline: Key("main", 13), Branch: "main", Revision: 13, Source: 42, Outcome: seat.PipelineOutcomeRunning, + Movers: []seat.Mover{{Module: "lib", Commit: "c9", Fingerprint: "src2:lb"}}} + for _, p := range []seat.Pipeline{old, running} { + raw, _ := json.Marshal(p) + if err := store.Create(p.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 }} + asks := &stepAsks{} + s := &Starter{Pipelines: store, Store: store, Steps: asks, Name: "the-runner", Now: ticking(), Say: func(string, any) error { return nil }, + Revision: func(_ string, r int64) (Half, error) { return head, nil }, + Registration: func(m string) (catalog.Registration, bool) { return reg, m == "app" }} 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) + acts := &actLog{} + v := Verbs{Starter: s, Hearer: &Hearer{Store: store, Unfinished: s.Unfinished, Say: func(string, any) error { return nil }}, + View: func(string) (Half, bool) { return head, true }, Acts: acts} + a, err := v.PlaceUnfinished("op@shanks", seat.PlaceUnfinishedInput{Key: "main.app", Why: "again"}) + if err != nil || a.Pipeline != running.Pipeline { + t.Fatalf("place-unfinished = %+v (%v), want it answering %s", a, err, running.Pipeline) } - 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) + p, _, _ := store.Get(running.Pipeline) + if m, ok := MoverOf(p, "app"); !ok || m.Commit != "c2" || m.Repository != "o/app-moved" { + t.Errorf("the head pipeline's app mover = %+v, want it at the head entry's commit c2", m) } - if m, _ := MoverOf(old, "app"); m.Commit != "c1" { - t.Errorf("the pipeline read was changed: %+v", m) + seen := false + for _, ask := range asks.asks { + if b, ok := ask.(builds.StepRun); ok { + seen = true + if len(b.Entries) != 1 || b.Entries[0].Module != "app" || b.Entries[0].Commit != "c2" { + t.Errorf("the build asked %+v, want app at c2", b.Entries) + } + } + } + if !seen { + t.Errorf("no build was asked of the joined mover (asks %d)", len(asks.asks)) } }