mesh-delivery-pipeline: test the place's join of the head's running pipeline at the head's commit (H-A-769, review round 2)
Builds: design 47 H2 H-A-769 (1), H-A-768
This commit is contained in:
@@ -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
|
// 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
|
||||||
// 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
|
// pipeline's mover is at c2 and its build ask names c2, whatever commit the ended pipeline's record held.
|
||||||
// it was asked at is taken after the record adopted a newer one.
|
|
||||||
func TestAPlacedGroupJoinsTheHeadAtTheHeadsCommit(t *testing.T) {
|
func TestAPlacedGroupJoinsTheHeadAtTheHeadsCommit(t *testing.T) {
|
||||||
_, entries := placeFixture()
|
reg, entries := placeFixture()
|
||||||
e := entries["app"]
|
e := entries["app"]
|
||||||
e.Fp, e.Commit, e.Repository = "src2:ab", "c2", "o/app-moved"
|
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()}
|
store := &MoverStore{Raw: newMemRaw()}
|
||||||
end := time.Unix(50, 0)
|
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,
|
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"}}}
|
Movers: []seat.Mover{{Module: "app", Commit: "c1", Fingerprint: "src2:ab", Repository: "o/app"}}}
|
||||||
raw, _ := json.Marshal(old)
|
running := seat.Pipeline{V: 1, Pipeline: Key("main", 13), Branch: "main", Revision: 13, Source: 42, Outcome: seat.PipelineOutcomeRunning,
|
||||||
if err := store.Create(old.Pipeline, raw); err != nil {
|
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)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
u := memUnfinished{"main.app": `{"fingerprint":"src2:ab","revision":10,"pipeline":"` + old.Pipeline + `","outcome":"failed"}`}
|
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 }}
|
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 }}
|
acts := &actLog{}
|
||||||
plan, err := v.planUnfinished("main.app")
|
v := Verbs{Starter: s, Hearer: &Hearer{Store: store, Unfinished: s.Unfinished, Say: func(string, any) error { return nil }},
|
||||||
if err != nil {
|
View: func(string) (Half, bool) { return head, true }, Acts: acts}
|
||||||
t.Fatal(err)
|
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" {
|
p, _, _ := store.Get(running.Pipeline)
|
||||||
t.Errorf("the plan's movers = %+v, want app at the head entry's commit c2 of o/app-moved", plan.movers)
|
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" {
|
seen := false
|
||||||
t.Errorf("the pipeline read was changed: %+v", m)
|
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))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user