mesh-delivery-pipeline: a cycle among unplaced movers ends the pipeline failed
A cycle the running build module does not break left a pipeline running with journal lines only, since validate is asked only for a placed mover. The placing now ends it failed, its why naming each artifact and edge kind. Builds: design 47 H H-A-175, G §270, G-22 A-326, H-A-101 (2)
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
|||||||
"slices"
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
builds "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshbuilds"
|
builds "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshbuilds"
|
||||||
catalog "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
catalog "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
||||||
@@ -171,3 +172,65 @@ func TestAToolchainEdgeIsNotAwaitedByTheBuildModulesOwnInputs(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Design 47 H H-A-175 (G §270, A-326; H-A-101 (2)): a cycle among a pipeline's movers without steps ends the pipeline failed
|
||||||
|
// at its placing, its why `cycle` naming each artifact and edge kind, each of their steps ended not asked; a cycle through
|
||||||
|
// a build module's own inputs is broken (G §270) and placed; a mover waiting on a placed mover only waits.
|
||||||
|
func TestACycleAmongUnplacedMoversEndsThePipelineFailed(t *testing.T) {
|
||||||
|
reg, base := placeFixture()
|
||||||
|
reg.Policy = catalog.Policy{Steps: catalog.StepStatuses{Lint: "bypass", Unit: "bypass", Integration: "bypass", Validate: "bypass", Composition: "bypass"}}
|
||||||
|
entry := func(m string, edges ...catalog.Edge) catalog.CatalogEntry {
|
||||||
|
return catalog.CatalogEntry{Module: m, Artifacts: []catalog.Artifact{{Ref: m + ":go", Language: "go"}}, Edges: edges}
|
||||||
|
}
|
||||||
|
e := func(from, to string, kind int64) catalog.Edge { return catalog.Edge{From: from, To: to, Kind: kind} }
|
||||||
|
for _, c := range []struct {
|
||||||
|
name string
|
||||||
|
entries []catalog.CatalogEntry
|
||||||
|
failed bool
|
||||||
|
placed []string
|
||||||
|
}{
|
||||||
|
{"a cycle G §270 breaks is placed", []catalog.CatalogEntry{
|
||||||
|
entry("mesh-sdk", e("mesh-build-go:files", "mesh-sdk:go", 3)),
|
||||||
|
entry("mesh-build-go", e("mesh-sdk:go", "mesh-build-go:go", 1))}, false, []string{"mesh-sdk"}},
|
||||||
|
{"a cycle no rule breaks ends the pipeline failed naming it", []catalog.CatalogEntry{
|
||||||
|
entry("a", e("b:go", "a:go", 1)),
|
||||||
|
entry("b", e("a:go", "b:go", 1)),
|
||||||
|
entry("c")}, true, []string{"a", "b", "c"}},
|
||||||
|
{"a mover waiting on a placed mover waits", []catalog.CatalogEntry{
|
||||||
|
entry("a", e("b:go", "a:go", 1)),
|
||||||
|
entry("b")}, false, []string{"b"}},
|
||||||
|
} {
|
||||||
|
entries := map[string]catalog.CatalogEntry{"mesh-build-go": base["mesh-build-go"]}
|
||||||
|
p := seat.Pipeline{Pipeline: "main.4", Branch: "main", Source: 4, Outcome: seat.PipelineOutcomeRunning}
|
||||||
|
for _, en := range c.entries {
|
||||||
|
entries[en.Module] = en
|
||||||
|
p.Movers = append(p.Movers, seat.Mover{Module: en.Module, Commit: "c", Fingerprint: "src2:" + en.Module})
|
||||||
|
}
|
||||||
|
s := &Starter{Name: "the-runner"}
|
||||||
|
asks, _, ended, _ := s.placeMovers(&p, func(string) (catalog.Registration, bool) { return reg, true }, entries, time.Unix(1, 0))
|
||||||
|
var got []string
|
||||||
|
for _, m := range p.Movers {
|
||||||
|
if placed(p, m.Module) {
|
||||||
|
got = append(got, m.Module)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !slices.Equal(got, c.placed) {
|
||||||
|
t.Errorf("%s: placed %v, want %v", c.name, got, c.placed)
|
||||||
|
}
|
||||||
|
if !c.failed {
|
||||||
|
if p.Outcome != seat.PipelineOutcomeRunning || len(ended) != 0 || len(asks) == 0 {
|
||||||
|
t.Errorf("%s: pipeline %s (%s), %d ended, %d asks; want running and asked", c.name, p.Outcome, p.Why, len(ended), len(asks))
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if p.Outcome != seat.PipelineOutcomeFailed || !strings.HasPrefix(p.Why, "cycle: ") || !strings.Contains(p.Why, "a:go before b:go (kind 1)") ||
|
||||||
|
!strings.Contains(p.Why, "b:go before a:go (kind 1)") || len(asks) != 0 || len(ended) == 0 {
|
||||||
|
t.Errorf("%s: pipeline %s why %q, %d asks, %d ended; want failed naming the cycle, nothing asked", c.name, p.Outcome, p.Why, len(asks), len(ended))
|
||||||
|
}
|
||||||
|
for _, st := range p.Steps {
|
||||||
|
if st.Outcome != seat.StepResultOutcomeBypassed && (st.Outcome != seat.StepResultOutcomeNotAsked || st.Why != p.Why) {
|
||||||
|
t.Errorf("%s: %s's %s = %s (%s), want not asked naming the cycle", c.name, st.Module, st.Step, st.Outcome, st.Why)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -317,6 +317,7 @@ func (s *Starter) placeMovers(p *seat.Pipeline, reg func(module string) (catalog
|
|||||||
var asks []Asked
|
var asks []Asked
|
||||||
var unregistered []string
|
var unregistered []string
|
||||||
var notAsked []int
|
var notAsked []int
|
||||||
|
var waits []seat.Mover
|
||||||
for _, m := range p.Movers {
|
for _, m := range p.Movers {
|
||||||
if placed(*p, m.Module) {
|
if placed(*p, m.Module) {
|
||||||
continue
|
continue
|
||||||
@@ -331,6 +332,7 @@ func (s *Starter) placeMovers(p *seat.Pipeline, reg func(module string) (catalog
|
|||||||
due, waiting, failed := ready(*p, m.Module, entries)
|
due, waiting, failed := ready(*p, m.Module, entries)
|
||||||
if !due && failed == "" {
|
if !due && failed == "" {
|
||||||
s.logf("%s: %s waits for %s before its build", p.Pipeline, m.Module, strings.Join(waiting, ", "))
|
s.logf("%s: %s waits for %s before its build", p.Pipeline, m.Module, strings.Join(waiting, ", "))
|
||||||
|
waits = append(waits, m)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
steps, a := Place(*p, m, r, entries, now, s.Name)
|
steps, a := Place(*p, m, r, entries, now, s.Name)
|
||||||
@@ -367,6 +369,9 @@ func (s *Starter) placeMovers(p *seat.Pipeline, reg func(module string) (catalog
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ended := cycled(p, waits, unregistered, reg, entries, now, s.Name); len(ended) > 0 {
|
||||||
|
return nil, unregistered, ended, notAsked
|
||||||
|
}
|
||||||
// A mover placed after the validate ended has its composition asked, or not asked, at once (§745).
|
// A mover placed after the validate ended has its composition asked, or not asked, at once (§745).
|
||||||
more, _ := releaseCompositions(p, now)
|
more, _ := releaseCompositions(p, now)
|
||||||
asks = append(asks, more...)
|
asks = append(asks, more...)
|
||||||
@@ -374,6 +379,46 @@ func (s *Starter) placeMovers(p *seat.Pipeline, reg func(module string) (catalog
|
|||||||
return asks, unregistered, ended, notAsked
|
return asks, unregistered, ended, notAsked
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cycled ends p failed at its placing when every mover still without steps waits only on movers without steps (H-A-175;
|
||||||
|
// G §270 and A-326 break a build module's own inputs before this): a cycle no build can start, its why `cycle` naming each
|
||||||
|
// artifact and edge kind on it. The waiting movers' steps are placed ended not asked (as H-A-101 (2) does), and every other
|
||||||
|
// step still open ends not asked, the way a holderless pipeline ends at once (A-470g). It answers the steps it ended,
|
||||||
|
// none when there is no such cycle.
|
||||||
|
func cycled(p *seat.Pipeline, waits []seat.Mover, unregistered []string, reg func(module string) (catalog.Registration, bool), entries map[string]catalog.CatalogEntry, now time.Time, name string) []int {
|
||||||
|
if len(waits) == 0 || len(unregistered) > 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
var on []string
|
||||||
|
for _, m := range waits {
|
||||||
|
for _, x := range awaited(*p, m.Module, entries) {
|
||||||
|
if placed(*p, moduleOf(x.From)) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
on = append(on, fmt.Sprintf("%s before %s (kind %d)", x.From, x.To, x.Kind))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sort.Strings(on)
|
||||||
|
why := "cycle: " + strings.Join(on, "; ")
|
||||||
|
for _, m := range waits {
|
||||||
|
r, _ := reg(m.Module)
|
||||||
|
steps, _ := Place(*p, m, r, entries, now, name)
|
||||||
|
p.Steps = append(p.Steps, steps...)
|
||||||
|
}
|
||||||
|
var ended []int
|
||||||
|
for i := range p.Steps {
|
||||||
|
st := &p.Steps[i]
|
||||||
|
if st.Outcome == seat.StepResultOutcomeBypassed || (!open(*st) && st.Outcome != seat.StepResultOutcomeWaiting) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
st.Outcome, st.Why, st.Ask, st.Shared, st.Ended = seat.StepResultOutcomeNotAsked, why, "", nil, &now
|
||||||
|
p.Unlogged = append(p.Unlogged, endEntry(p.Pipeline, *st, now))
|
||||||
|
ended = append(ended, i)
|
||||||
|
}
|
||||||
|
p.Outcome, p.Why, p.Ended = seat.PipelineOutcomeFailed, why, &now
|
||||||
|
p.EndCount++
|
||||||
|
return ended
|
||||||
|
}
|
||||||
|
|
||||||
// sayNotAsked says the step-ended of each step of p placed not asked because its mover's dependency did not build, naming
|
// sayNotAsked says the step-ended of each step of p placed not asked because its mover's dependency did not build, naming
|
||||||
// the dependency in its why, so no step ends silently (H-A-101 (2)).
|
// the dependency in its why, so no step ends silently (H-A-101 (2)).
|
||||||
func (s *Starter) sayNotAsked(p seat.Pipeline, steps []int) {
|
func (s *Starter) sayNotAsked(p seat.Pipeline, steps []int) {
|
||||||
|
|||||||
Reference in New Issue
Block a user