Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d1d092980a | ||
|
|
241cfd581a | ||
|
|
fe5fa6ac94 | ||
|
|
99b25a7db4 | ||
|
|
7606d515fd | ||
|
|
7e597a623e | ||
|
|
6a847a8d9c | ||
|
|
dc83ef3e27 |
@@ -24,9 +24,24 @@ func (b *Builder) BuildStep(ctx context.Context, run meshbuilds.StepRun) meshbui
|
||||
b.init()
|
||||
started := b.now()
|
||||
end := meshbuilds.StepEnded{V: 1, Pipeline: run.Pipeline, Step: meshbuilds.StepEndedStepBuild, Rerun: run.Rerun, By: run.By, Entries: run.Entries, Node: b.Node, Started: &started}
|
||||
// finish is the one place the ask is answered: its line names the pipeline, the movers, the step and the outcome, with
|
||||
// the words of an end that did not pass (H-A-320 (1), H-A-333).
|
||||
finish := func(outcome, said string) meshbuilds.StepEnded {
|
||||
at := b.now()
|
||||
end.Ended, end.Outcome, end.Said = &at, outcome, said
|
||||
movers := make([]string, 0, len(run.Entries))
|
||||
for _, e := range run.Entries {
|
||||
movers = append(movers, e.Module)
|
||||
}
|
||||
mv := strings.Join(movers, ",")
|
||||
if mv == "" {
|
||||
mv = "-"
|
||||
}
|
||||
if said != "" {
|
||||
b.logf("%s %s %s step answered %s: %s", run.Pipeline, mv, end.Step, outcome, said)
|
||||
} else {
|
||||
b.logf("%s %s %s step answered %s", run.Pipeline, mv, end.Step, outcome)
|
||||
}
|
||||
return end
|
||||
}
|
||||
if len(run.Entries) == 0 {
|
||||
@@ -43,7 +58,7 @@ func (b *Builder) BuildStep(ctx context.Context, run meshbuilds.StepRun) meshbui
|
||||
var failed []string
|
||||
for _, e := range run.Entries {
|
||||
var pins map[string]string
|
||||
outcome, said := b.buildEntry(ctx, e, &pins)
|
||||
outcome, said := b.buildEntry(ctx, run.Pipeline, e, &pins)
|
||||
// The end reports the pins each entry was built with, so the runner asks its held test steps with them (H-A-207).
|
||||
for path, version := range pins {
|
||||
if version == "" {
|
||||
@@ -88,9 +103,10 @@ func (b *Builder) askedRevision(run meshbuilds.StepRun) {
|
||||
}
|
||||
}
|
||||
|
||||
// buildEntry builds one entry at its fingerprint and waits for its end; pins is set, when it is done, to the pins its
|
||||
// done key keeps it was built with, the registry's included (H-A-207).
|
||||
func (b *Builder) buildEntry(ctx context.Context, e meshbuilds.BuildEntry, pins *map[string]string) (outcome, said string) {
|
||||
// buildEntry builds one entry at its fingerprint for pipeline and waits for its end; pins is set, when it is done, to the pins
|
||||
// its done key keeps it was built with, the registry's included (H-A-207). The answer from a build is one journal line,
|
||||
// naming the entry, its outcome, the pipeline and whether the build existed or was built now (H-A-320 (1)).
|
||||
func (b *Builder) buildEntry(ctx context.Context, pipeline string, e meshbuilds.BuildEntry, pins *map[string]string) (outcome, said string) {
|
||||
entry, err := b.StepEntry(ctx, e.Fingerprint)
|
||||
if err != nil {
|
||||
return meshbuilds.StepEndedOutcomeCouldNotRun, fmt.Sprintf("the entry %s at %s cannot be read: %v", e.Module, e.Fingerprint, err)
|
||||
@@ -110,13 +126,18 @@ func (b *Builder) buildEntry(ctx context.Context, e meshbuilds.BuildEntry, pins
|
||||
}
|
||||
ended := b.awaitEnd(key)
|
||||
defer b.dropEnd(key, ended)
|
||||
answered := func(outcome, said, how string) (string, string) {
|
||||
b.logf("%s@%s build step answered %s for %s (%s)", entry.Module, entry.Fp, outcome, pipeline, how)
|
||||
return outcome, said
|
||||
}
|
||||
if done, failedWords, found := b.keyEnd(ctx, key); found {
|
||||
if done {
|
||||
// A key done before reports the pins it was built with, kept with it, never the ones a publish gives now.
|
||||
*pins = b.keptPins(ctx, key)
|
||||
return b.passedWithItsVersion(ctx, entry)
|
||||
outcome, said := b.passedWithItsVersion(ctx, entry)
|
||||
return answered(outcome, said, "existing build")
|
||||
}
|
||||
return meshbuilds.StepEndedOutcomeFailed, failedWords
|
||||
return answered(meshbuilds.StepEndedOutcomeFailed, failedWords, "existing build")
|
||||
}
|
||||
m := meshcatalog.ModulesByModuleValue{Repository: entry.Repository, Commit: entry.Commit, Fp2: entry.Fp, Manifest: meshcatalogclient.BareManifestDigest(entry.ManifestDigest), Path: entry.Path,
|
||||
Toolchains: CatalogToolchains(b.agreedFor(ctx, meshcatalogclient.BareManifestDigest(entry.ManifestDigest))), Packages: entry.Packages}
|
||||
@@ -125,9 +146,10 @@ func (b *Builder) buildEntry(ctx context.Context, e meshbuilds.BuildEntry, pins
|
||||
case log := <-ended:
|
||||
if log.Outcome == builds.BuildDone {
|
||||
*pins = b.keptPins(ctx, key)
|
||||
return b.passedWithItsVersion(ctx, entry)
|
||||
outcome, said := b.passedWithItsVersion(ctx, entry)
|
||||
return answered(outcome, said, "built now")
|
||||
}
|
||||
return meshbuilds.StepEndedOutcomeFailed, fmt.Sprintf("%s at %s: %s %s", log.Module, log.FP, log.Outcome, log.Error)
|
||||
return answered(meshbuilds.StepEndedOutcomeFailed, fmt.Sprintf("%s at %s: %s %s", log.Module, log.FP, log.Outcome, log.Error), "built now")
|
||||
case <-ctx.Done():
|
||||
return meshbuilds.StepEndedOutcomeCouldNotRun, fmt.Sprintf("%s at %s: the builder stopped before its build ended", entry.Module, entry.Fp)
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"reflect"
|
||||
"slices"
|
||||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -36,12 +37,23 @@ func TestABuildStepAnswersItsEnd(t *testing.T) {
|
||||
ask := func(entries ...meshbuilds.BuildEntry) meshbuilds.StepEnded {
|
||||
return r.b.BuildStep(t.Context(), meshbuilds.StepRun{Pipeline: "main.1.m", Step: meshbuilds.StepRunStepBuild, Entries: entries})
|
||||
}
|
||||
// Every answer is one journal line naming the pipeline, the movers, the step and the outcome (H-A-320 (1), H-A-333).
|
||||
var answers []string
|
||||
r.b.Logf = func(f string, a ...any) {
|
||||
if l := fmt.Sprintf(f, a...); strings.Contains(l, " step answered ") {
|
||||
answers = append(answers, l)
|
||||
}
|
||||
}
|
||||
if end := ask(); end.Outcome != meshbuilds.StepEndedOutcomeNothingToRun {
|
||||
t.Errorf("an ask naming no entry: %+v", end)
|
||||
}
|
||||
if end := ask(meshbuilds.BuildEntry{Module: "m", Fingerprint: "src2:" + strings.Repeat("2", 64)}); end.Outcome != meshbuilds.StepEndedOutcomeCouldNotRun || !strings.Contains(end.Said, "cannot be read") {
|
||||
t.Errorf("an entry the seat does not hold: %+v", end)
|
||||
}
|
||||
if len(answers) != 2 || answers[0] != "main.1.m - build step answered nothing to run: the ask names no entry" ||
|
||||
!strings.HasPrefix(answers[1], "main.1.m m build step answered could not run: the entry m at ") {
|
||||
t.Errorf("the answers journaled %q, want one line per answer", answers)
|
||||
}
|
||||
if end := ask(meshbuilds.BuildEntry{Module: "m", Fingerprint: fp1, Commit: "other"}); end.Outcome != meshbuilds.StepEndedOutcomeCouldNotRun {
|
||||
t.Errorf("an entry at another commit: %+v", end)
|
||||
}
|
||||
@@ -171,6 +183,18 @@ func awaitWaiting[T any](t *testing.T, waiting <-chan struct{}, ended <-chan T)
|
||||
// another series and the module's release number pin nothing.
|
||||
func aPackageWithNoPinWaitsForItsRelease(t *testing.T) {
|
||||
r, _, waiting := unpinnedRig(t)
|
||||
// Each entry's answer from a build is one journal line, built now or existing, beside the ask's answer (H-A-320 (1), H-A-333).
|
||||
var mu sync.Mutex
|
||||
var answers []string
|
||||
logf := r.b.Logf
|
||||
r.b.Logf = func(format string, args ...any) {
|
||||
logf(format, args...)
|
||||
if l := fmt.Sprintf(format, args...); strings.HasPrefix(l, "m@") && strings.Contains(l, "build step answered") {
|
||||
mu.Lock()
|
||||
answers = append(answers, l)
|
||||
mu.Unlock()
|
||||
}
|
||||
}
|
||||
r.b.PackagePublished(unpinnedX, "v0.2.9") // another series than the 0.1 the module accepts: no pin
|
||||
r.b.PackagePublished(unpinnedX, "0.1.4-feat-x.2") // a group's tagged version: no pin
|
||||
ended := make(chan meshbuilds.StepEnded, 1)
|
||||
@@ -206,6 +230,12 @@ func aPackageWithNoPinWaitsForItsRelease(t *testing.T) {
|
||||
if again.Outcome != meshbuilds.StepEndedOutcomePassed || again.Packages[unpinnedX] != "v0.1.3" {
|
||||
t.Errorf("the done key's end = %+v; want passed reporting x at v0.1.3, as built", again)
|
||||
}
|
||||
mu.Lock()
|
||||
want := []string{"m@" + fp1 + " build step answered passed for main.9.m (built now)", "m@" + fp1 + " build step answered passed for main.9.m (existing build)"}
|
||||
if !reflect.DeepEqual(answers, want) {
|
||||
t.Errorf("the answers journaled %q, want %q", answers, want)
|
||||
}
|
||||
mu.Unlock()
|
||||
// A done key that keeps no pins reports none, so the runner ends the waiting steps loud.
|
||||
v, err := builds.DecodeBuilderBuild(r.st.vals[r.key])
|
||||
if err != nil {
|
||||
|
||||
@@ -143,8 +143,9 @@ func TestAnArtifactOfNoToolchainHasNoLanguageAndNoLock(t *testing.T) { // 1450/A
|
||||
|
||||
func TestAManifestTheParserRefusesLeavesNoInputsAndSaysWhy(t *testing.T) { // 1450/AC5
|
||||
for name, raw := range map[string]string{
|
||||
"not json": "not json",
|
||||
"unknown field": strings.Replace(catalogueManifest(t, "avahi"), `"version": "1",`, `"version": "1", "scope": "everything",`, 1),
|
||||
"not json": "not json",
|
||||
// A word inside a known one is still refused; a top-level word is set aside (below).
|
||||
"unknown field": strings.Replace(catalogueManifest(t, "avahi"), `"name": "tools",`, `"name": "tools", "a-field-from-later": "everything",`, 1),
|
||||
} {
|
||||
in := inputsOf("avahi", raw, "t", nil, noBases)
|
||||
if in.Kept != nil || !strings.HasPrefix(in.None2, "the manifest cannot be read: ") || len(in.None2) <= len("the manifest cannot be read: ") {
|
||||
@@ -154,6 +155,15 @@ func TestAManifestTheParserRefusesLeavesNoInputsAndSaysWhy(t *testing.T) { // 14
|
||||
if in := inputsOf("someone-else", catalogueManifest(t, "avahi"), "t", nil, noBases); in.Kept != nil || !strings.Contains(in.None2, "avahi") {
|
||||
t.Errorf("a manifest of another module: kept %+v none2 %q", in.Kept, in.None2)
|
||||
}
|
||||
// H-A-465: a top-level word the running indexer's SDK does not know yet (`class`, which a newer SDK adds) is set
|
||||
// aside, and the inputs are those of the same manifest without it.
|
||||
without := inputsOf("avahi", catalogueManifest(t, "avahi"), "t", map[string]string{"go.sum": avahiGoSum}, noBases)
|
||||
with := inputsOf("avahi", strings.Replace(catalogueManifest(t, "avahi"), `"version": "1",`, `"version": "1", "class": "core",`, 1),
|
||||
"t", map[string]string{"go.sum": avahiGoSum}, noBases)
|
||||
if with.Kept == nil || without.Kept == nil || !reflect.DeepEqual(*with.Kept, *without.Kept) || with.None2 != without.None2 ||
|
||||
!reflect.DeepEqual(with.Languages, without.Languages) || !reflect.DeepEqual(with.ArtifactPaths, without.ArtifactPaths) {
|
||||
t.Errorf("with an unknown top-level word: %+v (kept %+v), want the inputs without it %+v (kept %+v)", with, with.Kept, without, without.Kept)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAContextIsNotPinned(t *testing.T) { // 1450 (the rule 1444 keeps: context not pinned, as today's form)
|
||||
|
||||
@@ -7,12 +7,12 @@ import (
|
||||
)
|
||||
|
||||
// unreadableAvahi is avahi's manifest with a field the running parser refuses: the shape of a manifest an older SDK could
|
||||
// not read.
|
||||
// not read. The field is inside an artifact, since a top-level word the take-in does not know is set aside (H-A-465).
|
||||
func unreadableAvahi(t *testing.T) string {
|
||||
t.Helper()
|
||||
raw := strings.Replace(catalogueManifest(t, "avahi"), `"version": "1",`, `"version": "1", "scope": "everything",`, 1)
|
||||
raw := strings.Replace(catalogueManifest(t, "avahi"), `"name": "tools",`, `"name": "tools", "a-field-from-later": "everything",`, 1)
|
||||
if raw == catalogueManifest(t, "avahi") {
|
||||
t.Fatal("the fixture has no version line")
|
||||
t.Fatal("the fixture has no artifact named tools")
|
||||
}
|
||||
return raw
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ func Manifest(raw []byte, predefined catalogue.PredefinedList) (m catalogue.Mani
|
||||
if predefined != nil {
|
||||
m, err = ParseManifestWith(raw, predefined)
|
||||
} else {
|
||||
m, err = ParseManifestForInputs(raw)
|
||||
m, err = parseManifestFallingBack(raw)
|
||||
}
|
||||
if err != nil {
|
||||
return catalogue.Manifest{}, problemsOf(err)
|
||||
|
||||
@@ -27,6 +27,9 @@ func TestTheJudge(t *testing.T) {
|
||||
want: map[string]string{"a": `secret-`}},
|
||||
{name: "an unknown field", raws: map[string]string{"a": `{"module":"a","version":"1.0","a-field-from-later":1}`},
|
||||
want: map[string]string{"a": `"a-field-from-later"`}},
|
||||
// H-A-465: the take-in sets a top-level word it does not know aside (ForInputs); the judgement still refuses it.
|
||||
{name: "a word a newer SDK adds", raws: map[string]string{"a": `{"module":"a","version":"1.0","class":"core"}`},
|
||||
want: map[string]string{"a": `"class"`}},
|
||||
// Design 47 G §23, §28: a step's status is kept in the registration and never in a manifest.
|
||||
{name: "a manifest naming a step's status", raws: map[string]string{"a": `{"module":"a","version":"1.0","policy":{"lint":"bypass"}}`},
|
||||
want: map[string]string{"a": `"policy"`}},
|
||||
|
||||
@@ -3995,13 +3995,23 @@ var protectedRoots = []string{"/", "/bin", "/boot", "/dev", "/etc", "/home", "/l
|
||||
"/var/spool"}
|
||||
|
||||
// ParseManifestForInputs reads a manifest for the inputs of its build and its fingerprint: the indexer's and the
|
||||
// builder's read (novox/hq issue 1751). It is never a judge of config values. A value falling back to a predefined key
|
||||
// builder's read (novox/hq issue 1751). It is never a judge of config values, and never of words: a top-level word the
|
||||
// SDK's manifest does not know (a word a newer SDK adds, such as `class`) is set aside, as the SDK's decoder sets it
|
||||
// aside, and the inputs are taken from the words it knows (design 47 H, H-A-465), so a revision carrying a new word
|
||||
// still gets its fingerprint from the running indexer. The judgement's read (Manifest, ParseManifest) stays strict: the
|
||||
// validator built from the revision's own indexer refuses what it does not know. A value falling back to a predefined key
|
||||
// (ADR 0348 §7) is judged against the list the mesh published when this process holds one (PublishedPredefined);
|
||||
// where it holds none, as in the indexer and the builder, each key a value names is taken as the value declares it (its
|
||||
// type, trusted when it is), since the list is read where a manifest is judged: the merge gate from the tree's root,
|
||||
// the controller from what it published. No input of a fingerprint or a build comes from the list. Everything else
|
||||
// ParseManifest refuses is refused here too.
|
||||
func ParseManifestForInputs(raw []byte) (catalogue.Manifest, error) {
|
||||
return parseManifestFallingBack(withoutUnknownWords(raw))
|
||||
}
|
||||
|
||||
// parseManifestFallingBack is the strict read judging each predefined key a value falls back to against the list the
|
||||
// mesh published, or, where this process holds none, as the value declares it (fallbacksOf).
|
||||
func parseManifestFallingBack(raw []byte) (catalogue.Manifest, error) {
|
||||
list := catalogue.PublishedPredefined()
|
||||
if list == nil {
|
||||
list = fallbacksOf(raw)
|
||||
@@ -4009,6 +4019,61 @@ func ParseManifestForInputs(raw []byte) (catalogue.Manifest, error) {
|
||||
return parseManifest(raw, list)
|
||||
}
|
||||
|
||||
// withoutUnknownWords is raw without each top-level word the SDK's manifest does not know, the others in their order
|
||||
// and their values as written; raw itself when it knows every word or is no JSON object (the strict read then says
|
||||
// what is wrong with it). A word inside a known one is not set aside here: the strict read refuses it.
|
||||
func withoutUnknownWords(raw []byte) []byte {
|
||||
decoder := json.NewDecoder(bytes.NewReader(raw))
|
||||
if t, err := decoder.Token(); err != nil || t != json.Delim('{') {
|
||||
return raw
|
||||
}
|
||||
var out bytes.Buffer
|
||||
out.WriteByte('{')
|
||||
kept, setAside := 0, false
|
||||
for decoder.More() {
|
||||
t, err := decoder.Token()
|
||||
if err != nil {
|
||||
return raw
|
||||
}
|
||||
word, _ := t.(string)
|
||||
var value json.RawMessage
|
||||
if err := decoder.Decode(&value); err != nil {
|
||||
return raw
|
||||
}
|
||||
if !knownWord(word) {
|
||||
setAside = true
|
||||
continue
|
||||
}
|
||||
if kept > 0 {
|
||||
out.WriteByte(',')
|
||||
}
|
||||
quoted, _ := json.Marshal(word)
|
||||
out.Write(quoted)
|
||||
out.WriteByte(':')
|
||||
out.Write(value)
|
||||
kept++
|
||||
}
|
||||
if !setAside {
|
||||
return raw
|
||||
}
|
||||
out.WriteByte('}')
|
||||
return out.Bytes()
|
||||
}
|
||||
|
||||
// knownWord is whether the SDK's manifest knows a top-level word: a manifest of that word alone, valued null, is read
|
||||
// with nothing set aside. A word the SDK reads by a rule of its own that refuses null is known.
|
||||
func knownWord(word string) bool {
|
||||
probe, err := json.Marshal(map[string]json.RawMessage{word: json.RawMessage("null")})
|
||||
if err != nil {
|
||||
return true
|
||||
}
|
||||
var m catalogue.Manifest
|
||||
if err := json.Unmarshal(probe, &m); err != nil {
|
||||
return true
|
||||
}
|
||||
return m.SetAside() == ""
|
||||
}
|
||||
|
||||
// fallbacksOf is the list of the predefined keys a manifest's config values fall back to, each as the value declares
|
||||
// it. A manifest that is not JSON gives an empty list, and the parser says what is wrong with it.
|
||||
func fallbacksOf(raw []byte) catalogue.PredefinedList {
|
||||
|
||||
@@ -176,7 +176,7 @@ func (v Verbs) AskUnanswered(onSeat, ask string, again bool) error {
|
||||
return nil // its second bound ends the step
|
||||
}
|
||||
v.Starter.carry(key, []Asked{*a})
|
||||
return askAll(v.Starter.Steps, key, []Asked{*a}, func(commit string) bool { return v.Starter.recovered(key, commit) }, nil)
|
||||
return askAll(v.Starter.Steps, key, []Asked{*a}, func(commit string) bool { return v.Starter.recovered(key, commit) }, nil, nil)
|
||||
}
|
||||
|
||||
// HolderStarted puts again every open ask of each silent seat module holds (H-A-243 (1)): its holder takes its asks on a plain
|
||||
@@ -234,7 +234,7 @@ func (v Verbs) HolderStarted(module string) (int, error) {
|
||||
continue
|
||||
}
|
||||
st.carry(key, due)
|
||||
if err := askAll(st.Steps, key, due, func(commit string) bool { return st.recovered(key, commit) }, nil); err != nil && first == nil {
|
||||
if err := askAll(st.Steps, key, due, func(commit string) bool { return st.recovered(key, commit) }, nil, nil); err != nil && first == nil {
|
||||
first = err
|
||||
}
|
||||
asked += len(due)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package pipeline
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"slices"
|
||||
"strings"
|
||||
"testing"
|
||||
@@ -20,7 +21,7 @@ func TestAnAskNobodyAnswersIsAskedOnceMoreThenEndsItsStep(t *testing.T) {
|
||||
v, store, said, asks, _, _ := verbsFixture()
|
||||
var armed, unbound, raised, cleared []string
|
||||
logs := []string{}
|
||||
v.Hearer.Logf = func(f string, a ...any) { logs = append(logs, f) }
|
||||
v.Hearer.Logf = func(f string, a ...any) { logs = append(logs, fmt.Sprintf(f, a...)) }
|
||||
c := &AskClock{Bound: 10 * time.Minute,
|
||||
Arm: func(key string, ttl time.Duration) error { armed = append(armed, key+" "+ttl.String()); return nil },
|
||||
Unbound: func(key string) error { unbound = append(unbound, key); return nil },
|
||||
@@ -83,6 +84,10 @@ func TestAnAskNobodyAnswersIsAskedOnceMoreThenEndsItsStep(t *testing.T) {
|
||||
if s.Outcome != seat.StepResultOutcomeCouldNotRun || s.Why != "its ask "+ask+" was not answered" || s.Ended == nil {
|
||||
t.Errorf("the step = %+v", s)
|
||||
}
|
||||
// The unanswered-bound end is one journal line, as every said end (H-A-320 (1), H-A-333).
|
||||
if n := countLines(logs, pkey+" app lint ended could not run (no node, "); n != 1 {
|
||||
t.Errorf("the unanswered end journaled %d times in %q, want once", n, logs)
|
||||
}
|
||||
if got.Outcome != seat.PipelineOutcomeFailed || len(asks.ids) != 2 {
|
||||
t.Errorf("the pipeline is %s (%s), asked %d, want failed and nothing more asked", got.Outcome, got.Why, len(asks.ids))
|
||||
}
|
||||
|
||||
@@ -139,13 +139,16 @@ var buildKinds = []int64{3, 1}
|
||||
// awaited are the artifact references mover m's steps wait for in p (§746, H-A-51): the From of each edge of a build kind
|
||||
// into m from another mover of p, toolchain edges first, each once. A toolchain edge (kind 3) from a build module whose
|
||||
// own new version is built from m is not awaited: what a build module's new version is built from is built by its
|
||||
// running version, never waited for (G §270, A-326), so the running build module builds m and the new one the rest.
|
||||
// running version, never waited for (G §270, A-326), so the running build module builds m and the new one the rest. A
|
||||
// mover that left p for a newer pipeline is not awaited either: m builds against the newest published package (H-A-53),
|
||||
// and its build ended superseded is no dependency that did not build (H-A-361).
|
||||
func awaited(p seat.Pipeline, m string, entries map[string]catalog.CatalogEntry) []catalog.Edge {
|
||||
var out []catalog.Edge
|
||||
for _, kind := range buildKinds {
|
||||
for _, x := range entries[m].Edges {
|
||||
from := moduleOf(x.From)
|
||||
if x.Kind != kind || from == m || !Moves(p, from) || slices.ContainsFunc(out, func(e catalog.Edge) bool { return e.From == x.From }) {
|
||||
if x.Kind != kind || from == m || !Moves(p, from) || slices.Contains(p.Superseded, from) ||
|
||||
slices.ContainsFunc(out, func(e catalog.Edge) bool { return e.From == x.From }) {
|
||||
continue
|
||||
}
|
||||
if kind == 3 && builtFrom(p, from, entries)[m] {
|
||||
|
||||
@@ -179,6 +179,135 @@ func TestAMoversBuildWaitsForItsDependenciesInThePipeline(t *testing.T) {
|
||||
if _, err := s2.Turn("main.7", view); err != nil || len(s2.publishedRead) != 0 {
|
||||
t.Errorf("after main.7's end %d answers are kept (%v), want none", len(s2.publishedRead), err)
|
||||
}
|
||||
|
||||
// H-A-361 (main.158 at 22:51, main.163 at 23:00 of 2026-11-21), H-A-53, H-A-223: a newer pipeline takes mesh-sdk and
|
||||
// builder, whose builds run, and web, not placed yet; app and tool, which awaited them, stay. They are placed and asked
|
||||
// at the hand-off, building against the newest published package, never ended not asked as if their dependency had
|
||||
// failed; web is not placed here; the journal says the hand-off and what stays; a later placing and the end judgement
|
||||
// leave the pipeline running until its kept steps end.
|
||||
t.Run("a hand-off places the kept movers that awaited a mover that left", func(t *testing.T) {
|
||||
web := entries["app"]
|
||||
web.Module, web.Edges = "web", []catalog.Edge{{From: "mesh-sdk:go", To: "web:program", Kind: 1}}
|
||||
entries["web"] = web
|
||||
mem := memStore{}
|
||||
s := &Starter{Pipelines: memCreated{mem}, Store: mem, Say: func(string, any) error { return nil }, Steps: &stepAsks{}, Name: "the-runner",
|
||||
Registration: func(string) (catalog.Registration, bool) { return reg, true }}
|
||||
ev := ev
|
||||
ev.Entries = append(slices.Clone(ev.Entries), catalog.TakeInEntry{Module: "web", Commit: "c4", Fingerprint: "src2:dd"})
|
||||
if n, err := s.TakenIn(ev, view); n != 1 || err != nil {
|
||||
t.Fatalf("the take-in started %d (%v)", n, err)
|
||||
}
|
||||
var journal []string
|
||||
h := &Hearer{Store: mem, Name: "the-runner", Say: func(string, any) error { return nil },
|
||||
Logf: func(f string, a ...any) { journal = append(journal, fmt.Sprintf(f, a...)) },
|
||||
Release: func(key string) { _, _ = s.Release(mem, key, view) }}
|
||||
h.SupersedeRunning(seat.Pipeline{Pipeline: "main.9", Branch: "main", Revision: 9, Movers: []seat.Mover{
|
||||
{Module: "mesh-sdk", Commit: "c5", Fingerprint: "src2:01"}, {Module: "builder", Commit: "c5", Fingerprint: "src2:b2"},
|
||||
{Module: "web", Commit: "c5", Fingerprint: "src2:d2"}}})
|
||||
check := func(when string) {
|
||||
p, _, _ := mem.Get("main.7")
|
||||
if p.Outcome != seat.PipelineOutcomeRunning {
|
||||
t.Fatalf("%s: main.7 = %s (%s), want running until its kept steps end", when, p.Outcome, p.Why)
|
||||
}
|
||||
for _, m := range []string{"app", "tool"} {
|
||||
st := stepsOf(p, m)
|
||||
if len(st) == 0 || st[0].Step != seat.StepResultStepBuild || st[0].Outcome != seat.StepResultOutcomeRunning || st[0].Ask == "" {
|
||||
t.Errorf("%s: %s's steps = %+v, want its build placed and asked", when, m, st)
|
||||
}
|
||||
}
|
||||
if st := stepsOf(p, "app"); len(st) > 0 && !strings.Contains(st[0].Why, "mesh-sdk") {
|
||||
t.Errorf("%s: app's build why %q does not say mesh-sdk was taken out (H-A-53)", when, st[0].Why)
|
||||
}
|
||||
if placed(p, "web") {
|
||||
t.Errorf("%s: web, which left, is placed in main.7: %+v", when, stepsOf(p, "web"))
|
||||
}
|
||||
}
|
||||
check("at the hand-off")
|
||||
if !slices.ContainsFunc(journal, func(l string) bool {
|
||||
return strings.Contains(l, "main.7: ") && strings.Contains(l, "leave it") && strings.Contains(l, "stay: app, tool")
|
||||
}) {
|
||||
t.Errorf("the journal %q does not say the hand-off and that app and tool stay", journal)
|
||||
}
|
||||
// A placing heard later (a publish, a step end) and the end judgement again: still running.
|
||||
if _, err := s.Release(mem, "main.7", view); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
p, rev, _ := mem.Get("main.7")
|
||||
if endPipeline(&p, time.Now(), nil) {
|
||||
_, _ = mem.Update("main.7", p, rev)
|
||||
}
|
||||
check("after a later placing and the end judgement")
|
||||
})
|
||||
|
||||
// H-A-361, the reverse order (21:50:16 of 2026-11-21, mesh-contracts' old build withdrawn): builder's build ends without
|
||||
// passing first, so tool, awaiting it, and ext, awaiting tool, are placed not asked; only then does a newer pipeline take
|
||||
// builder away. At the hand-off tool and ext, not asked on a dependency that left (ext through tool), are taken out and
|
||||
// placed again: tool is asked, building against the newest published package, ext waits for tool's build; the journal
|
||||
// says it, and a later placing and the end judgement leave the pipeline running.
|
||||
t.Run("a build that did not pass, then a hand-off, places again the movers not asked on the mover that left", func(t *testing.T) {
|
||||
ext := entries["app"]
|
||||
ext.Module, ext.Edges = "ext", []catalog.Edge{{From: "tool:program", To: "ext:program", Kind: 1}}
|
||||
entries["ext"] = ext
|
||||
mem := memStore{}
|
||||
s := &Starter{Pipelines: memCreated{mem}, Store: mem, Say: func(string, any) error { return nil }, Steps: &stepAsks{}, Name: "the-runner",
|
||||
Registration: func(string) (catalog.Registration, bool) { return reg, true }}
|
||||
ev := ev
|
||||
ev.Entries = append(slices.Clone(ev.Entries), catalog.TakeInEntry{Module: "ext", Commit: "c6", Fingerprint: "src2:ee"})
|
||||
if n, err := s.TakenIn(ev, view); n != 1 || err != nil {
|
||||
t.Fatalf("the take-in started %d (%v)", n, err)
|
||||
}
|
||||
var journal []string
|
||||
h := &Hearer{Store: mem, Name: "the-runner", Say: func(string, any) error { return nil },
|
||||
Logf: func(f string, a ...any) { journal = append(journal, fmt.Sprintf(f, a...)) },
|
||||
Release: func(key string) { _, _ = s.Release(mem, key, view) }}
|
||||
p, _, _ := mem.Get("main.7")
|
||||
b := stepsOf(p, "builder")[0]
|
||||
e, err := bs.Decode([]byte(`{"id":"` + b.Ask + `","pipeline":"main.7","step":"build","node":"n1","outcome":"failed","entries":[{"module":"builder","commit":"c2","fingerprint":"src2:bb"}]}`))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := h.OnStepEnded(bs, bs.Prefix+"n1", e); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// A later placing places ext, whose dependency tool was not asked, not asked too.
|
||||
if _, err := s.Release(mem, "main.7", view); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
p, _, _ = mem.Get("main.7")
|
||||
for _, m := range []string{"tool", "ext"} {
|
||||
if st := stepsOf(p, m); len(st) == 0 || st[0].Outcome != seat.StepResultOutcomeNotAsked {
|
||||
t.Fatalf("after builder's build failed, %s's steps = %+v, want placed not asked", m, st)
|
||||
}
|
||||
}
|
||||
h.SupersedeRunning(seat.Pipeline{Pipeline: "main.9", Branch: "main", Revision: 9, Movers: []seat.Mover{
|
||||
{Module: "builder", Commit: "c5", Fingerprint: "src2:b2"}}})
|
||||
check := func(when string) {
|
||||
p, _, _ := mem.Get("main.7")
|
||||
if p.Outcome != seat.PipelineOutcomeRunning {
|
||||
t.Fatalf("%s: main.7 = %s (%s), want running until its kept steps end", when, p.Outcome, p.Why)
|
||||
}
|
||||
if st := stepsOf(p, "tool"); len(st) == 0 || st[0].Step != seat.StepResultStepBuild || st[0].Outcome != seat.StepResultOutcomeRunning || st[0].Ask == "" {
|
||||
t.Errorf("%s: tool's steps = %+v, want its build placed again and asked", when, st)
|
||||
}
|
||||
if placed(p, "ext") {
|
||||
t.Errorf("%s: ext's steps = %+v, want it waiting for tool's build, not placed", when, stepsOf(p, "ext"))
|
||||
}
|
||||
}
|
||||
check("at the hand-off")
|
||||
if !slices.ContainsFunc(journal, func(l string) bool {
|
||||
return strings.Contains(l, "main.7: tool, ext, not asked on a dependency that left, placed again")
|
||||
}) {
|
||||
t.Errorf("the journal %q does not say tool and ext are placed again", journal)
|
||||
}
|
||||
if _, err := s.Release(mem, "main.7", view); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
p, rev, _ := mem.Get("main.7")
|
||||
if endPipeline(&p, time.Now(), nil) {
|
||||
_, _ = mem.Update("main.7", p, rev)
|
||||
}
|
||||
check("after a later placing and the end judgement")
|
||||
})
|
||||
}
|
||||
|
||||
// Design 47 G §270, A-326 (H §746, H-A-83 (2)): what a build module's new version is built from is built by its running
|
||||
|
||||
@@ -446,8 +446,10 @@ func stepAsk(p seat.Pipeline, m seat.Mover, e catalog.CatalogEntry, a catalog.Ar
|
||||
}
|
||||
|
||||
// askAll puts each ask on its seat's work queue; the first refusal is named, the rest are still put. arm, when not nil, arms
|
||||
// each ask's bound before it is put (H-A-235, H-A-238 (5)); an ask whose bound is not armed is not put.
|
||||
func askAll(asker StepAsker, key string, asks []Asked, recovery func(commit string) bool, arm func(Asked) error) error {
|
||||
// each ask's bound before it is put (H-A-235, H-A-238 (5)); an ask whose bound is not armed is not put. logf, when not nil,
|
||||
// writes one journal line per ask put, naming the pipeline, the mover, the step and the seat (H-A-320 (1)); a caller that
|
||||
// says the ask in a line of its own (an ask put again) gives none.
|
||||
func askAll(asker StepAsker, key string, asks []Asked, recovery func(commit string) bool, arm func(Asked) error, logf func(string, ...any)) error {
|
||||
var first error
|
||||
for _, a := range asks {
|
||||
accept, ok := acceptStep[a.Seat]
|
||||
@@ -464,6 +466,10 @@ func askAll(asker StepAsker, key string, asks []Asked, recovery func(commit stri
|
||||
if err == nil {
|
||||
err = asker.AskStep(accept, a.ID, a.Ask)
|
||||
}
|
||||
if err == nil && logf != nil {
|
||||
mover, step := askedStep(a)
|
||||
logf("%s %s %s asked on %s", key, mover, step, a.Seat)
|
||||
}
|
||||
if err != nil && first == nil {
|
||||
first = fmt.Errorf("the step %s of %s is not asked of %s: %w", a.ID, key, a.Seat, err)
|
||||
}
|
||||
@@ -471,6 +477,31 @@ func askAll(asker StepAsker, key string, asks []Asked, recovery func(commit stri
|
||||
return first
|
||||
}
|
||||
|
||||
// askedStep is the mover and the step an ask names, read from its body; "-" where it names none (the validate ask names no
|
||||
// mover, H-A-51).
|
||||
func askedStep(a Asked) (mover, step string) {
|
||||
switch b := a.Ask.(type) {
|
||||
case nodebuildgo.StepAsk:
|
||||
if b.Step != nil {
|
||||
mover, step = b.Step.Module, b.Step.Step
|
||||
}
|
||||
case builds.StepRun:
|
||||
step = b.Step
|
||||
if len(b.Entries) == 1 {
|
||||
mover = b.Entries[0].Module
|
||||
}
|
||||
case wants.StepRun:
|
||||
mover, step = b.Module, b.Step
|
||||
}
|
||||
if mover == "" {
|
||||
mover = "-"
|
||||
}
|
||||
if step == "" {
|
||||
step = "-"
|
||||
}
|
||||
return mover, step
|
||||
}
|
||||
|
||||
// artifactPaths are the named paths the entry keeps for the artifact, by its reference or its name.
|
||||
func artifactPaths(e catalog.CatalogEntry, ref string) []string {
|
||||
if e.Inputs == nil {
|
||||
|
||||
@@ -137,6 +137,7 @@ func (s *Starter) keepIn(key string, half Half, movers []seat.Mover) []seat.Move
|
||||
}
|
||||
was := p
|
||||
was.Movers = olds
|
||||
logEnded(s.logf, key, st)
|
||||
if err := s.Say(stepEvent(seat.EventStepEnded, was, st, now)); err != nil {
|
||||
s.logf("step-ended of %s's %s %s, superseded, is not said: %v", key, st.Module, st.Step, err)
|
||||
}
|
||||
@@ -188,7 +189,7 @@ func (s *Starter) placeAgain(p *seat.Pipeline, m seat.Mover, half Half, now time
|
||||
supersededWhy(*p, m.Module, half.Entries, steps)
|
||||
var notAsked []int
|
||||
if failed != "" {
|
||||
why := "its dependency " + failed + " did not build"
|
||||
why := notBuiltWhy(failed)
|
||||
for k := range steps {
|
||||
st := &steps[k]
|
||||
if st.Outcome == seat.StepResultOutcomeBypassed {
|
||||
|
||||
@@ -134,6 +134,22 @@ func placed(p seat.Pipeline, module string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// notBuiltWhy is the why of a step placed not asked because dependency failed did not build (H-A-101 (2)).
|
||||
func notBuiltWhy(failed string) string { return "its dependency " + failed + " did not build" }
|
||||
|
||||
// notBuiltDependency answers the dependency a step placed not asked names as not built (notBuiltWhy), if it is one.
|
||||
func notBuiltDependency(st seat.StepResult) (string, bool) {
|
||||
if st.Outcome != seat.StepResultOutcomeNotAsked {
|
||||
return "", false
|
||||
}
|
||||
d, ok := strings.CutPrefix(st.Why, "its dependency ")
|
||||
if !ok {
|
||||
return "", false
|
||||
}
|
||||
d, ok = strings.CutSuffix(d, " did not build")
|
||||
return d, ok && d != ""
|
||||
}
|
||||
|
||||
// Starter starts pipelines (design 47 G §54, §103): it writes a pipeline's key by compare-and-set on its absence, so one
|
||||
// source revision and module has one pipeline whichever event starts it first, and says pipeline-started for the one it
|
||||
// wrote.
|
||||
@@ -327,7 +343,7 @@ func (s *Starter) askSteps(key string, asks []Asked) error {
|
||||
var err error
|
||||
if len(asks) > 0 {
|
||||
s.carry(key, asks)
|
||||
err = askAll(s.Steps, key, asks, func(commit string) bool { return s.recovered(key, commit) }, s.Asks.arm)
|
||||
err = askAll(s.Steps, key, asks, func(commit string) bool { return s.recovered(key, commit) }, s.Asks.arm, s.logf)
|
||||
}
|
||||
s.sayStarted(key, placed)
|
||||
return err
|
||||
@@ -409,7 +425,8 @@ func (s *Starter) placeMovers(p *seat.Pipeline, reg func(module string) (catalog
|
||||
}
|
||||
all := entries
|
||||
for _, m := range p.Movers {
|
||||
if placed(*p, m.Module) {
|
||||
// A mover that left for a newer pipeline is placed there, never here (H-A-223, H-A-361).
|
||||
if placed(*p, m.Module) || slices.Contains(p.Superseded, m.Module) {
|
||||
continue
|
||||
}
|
||||
r, ok := reg(m.Module)
|
||||
@@ -443,7 +460,7 @@ func (s *Starter) placeMovers(p *seat.Pipeline, reg func(module string) (catalog
|
||||
}
|
||||
}
|
||||
if failed != "" {
|
||||
why := "its dependency " + failed + " did not build"
|
||||
why := notBuiltWhy(failed)
|
||||
for k := range steps {
|
||||
st := &steps[k]
|
||||
if st.Outcome == seat.StepResultOutcomeBypassed {
|
||||
@@ -560,6 +577,7 @@ func (s *Starter) sayNotAsked(p seat.Pipeline, steps []int) {
|
||||
}
|
||||
at := s.now()
|
||||
for _, i := range steps {
|
||||
logEnded(s.logf, p.Pipeline, p.Steps[i])
|
||||
subject, ev := stepEvent(seat.EventStepEnded, p, p.Steps[i], at)
|
||||
if err := s.Say(subject, ev); err != nil {
|
||||
s.logf("step-ended of %s's %s %s, not asked, is not said: %v", p.Pipeline, p.Steps[i].Module, p.Steps[i].Step, err)
|
||||
@@ -1023,7 +1041,7 @@ func (s *Starter) Release(store Updater, key string, view func(branch string) (H
|
||||
return false
|
||||
}
|
||||
for _, m := range p.Movers {
|
||||
if !placed(p, m.Module) {
|
||||
if !placed(p, m.Module) && !slices.Contains(p.Superseded, m.Module) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -554,6 +554,26 @@ func endEntry(key string, s seat.StepResult, at time.Time, kept ...string) seat.
|
||||
Output: s.Output, Kept: kept, At: at}
|
||||
}
|
||||
|
||||
// logEnded writes the journal line of a step's end said (H-A-320 (1), H-A-333): the pipeline, the mover, the step, its
|
||||
// outcome, the node that ended it and how long it ran from its start. It is written where step-ended is said, Hearer.say and
|
||||
// the starter's two sayers, so every said end has its one line.
|
||||
func logEnded(logf func(string, ...any), key string, s seat.StepResult) {
|
||||
if logf == nil {
|
||||
return
|
||||
}
|
||||
mover, node, took := s.Module, s.Node, "no start"
|
||||
if mover == "" {
|
||||
mover = "-"
|
||||
}
|
||||
if node == "" {
|
||||
node = "no node"
|
||||
}
|
||||
if s.Started != nil && s.Ended != nil {
|
||||
took = s.Ended.Sub(*s.Started).Round(time.Millisecond).String()
|
||||
}
|
||||
logf("%s %s %s ended %s (%s, %s)", key, mover, s.Step, s.Outcome, node, took)
|
||||
}
|
||||
|
||||
func (h *Hearer) logf(format string, args ...any) {
|
||||
if h.Logf != nil {
|
||||
h.Logf(format, args...)
|
||||
@@ -567,6 +587,9 @@ func (h *Hearer) say(event string, p seat.Pipeline, step *seat.StepResult) error
|
||||
at := h.now()
|
||||
switch event {
|
||||
case seat.EventStepEnded, seat.EventStepStarted:
|
||||
if event == seat.EventStepEnded {
|
||||
logEnded(h.logf, p.Pipeline, *step)
|
||||
}
|
||||
subject, ev := stepEvent(event, p, *step, at)
|
||||
return h.Say(subject, ev)
|
||||
case seat.EventPipelineEnded:
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
|
||||
"git.novox.be/novox/mesh-contracts/operator-and-conversation/go/clients/operatorchannelclient"
|
||||
oc "git.novox.be/novox/mesh-contracts/operator-and-conversation/go/seats/operatorchannel"
|
||||
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"
|
||||
seat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner"
|
||||
wants "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshwants"
|
||||
@@ -363,10 +364,21 @@ func TestARecoverysStepsAreAskedOnTheStreamDelivery(t *testing.T) {
|
||||
}{{true, "mesh.seat.node-build-go.accept.delivery.mesh-pipeline-runner," + wants.AcceptSubjectStep}, {false, "mesh.seat.node-build-go.accept.check.mesh-pipeline-runner," + wants.AcceptSubjectStep}} {
|
||||
var to []string
|
||||
asker := askerFunc(func(accept, _ string, _ any) error { to = append(to, accept); return nil })
|
||||
if err := askAll(asker, "k", asks, func(string) bool { return c.recovery }, nil); err != nil || strings.Join(to, ",") != c.want {
|
||||
if err := askAll(asker, "k", asks, func(string) bool { return c.recovery }, nil, nil); err != nil || strings.Join(to, ",") != c.want {
|
||||
t.Errorf("recovery %v: asked on %v (%v), want %s", c.recovery, to, err, c.want)
|
||||
}
|
||||
}
|
||||
// Each ask put is one journal line naming the pipeline, the mover, the step and the seat: the build ask on mesh-builds and a
|
||||
// check ask alike (H-A-320 (1)); an ask refused writes none.
|
||||
var lines []string
|
||||
put := []Asked{{Seat: builds.Seat, ID: "b1", Ask: builds.StepRun{Step: builds.StepRunStepBuild, Entries: []builds.BuildEntry{{Module: "app"}}}},
|
||||
{Seat: nodebuildgo.Seat, ID: "u1", Ask: nodebuildgo.StepAsk{Step: &nodebuildgo.StepRun{Module: "app", Step: "unit"}}},
|
||||
{Seat: "no-seat", ID: "x1", Ask: 3}}
|
||||
_ = askAll(askerFunc(func(string, string, any) error { return nil }), "main.4", put, nil, nil,
|
||||
func(f string, a ...any) { lines = append(lines, fmt.Sprintf(f, a...)) })
|
||||
if want := "main.4 app build asked on mesh-builds\nmain.4 app unit asked on node-build-go"; strings.Join(lines, "\n") != want {
|
||||
t.Errorf("journal %q, want %q", lines, want)
|
||||
}
|
||||
// Starter.recovered reads the commit; a failed read asks on check and says so.
|
||||
var said []string
|
||||
s := &Starter{Logf: func(f string, a ...any) { said = append(said, f) }, Recovered: func(c string) (bool, error) {
|
||||
|
||||
@@ -124,6 +124,7 @@ func (h *Hearer) supersedeRunningOne(key string, newer seat.Pipeline) bool {
|
||||
ended = append(ended, i)
|
||||
}
|
||||
p.Superseded = append(p.Superseded, moved...)
|
||||
again := takeOutNotAsked(&p)
|
||||
done := h.endPipeline(&p, now, wr)
|
||||
if _, err := h.Store.Update(key, p, rev); errors.Is(err, ErrChanged) {
|
||||
continue
|
||||
@@ -131,7 +132,17 @@ func (h *Hearer) supersedeRunningOne(key string, newer seat.Pipeline) bool {
|
||||
h.logf("the running pipeline %s is not written, so its movers moved by %s stay: %v", key, newer.Pipeline, err)
|
||||
return false
|
||||
}
|
||||
h.logf("%s: %s moved by the newer %s leave it, %d of its open steps ended superseded (H-A-223)", key, strings.Join(moved, ", "), newer.Pipeline, len(ended))
|
||||
var stay []string
|
||||
for _, m := range p.Movers {
|
||||
if !slices.Contains(p.Superseded, m.Module) {
|
||||
stay = append(stay, m.Module)
|
||||
}
|
||||
}
|
||||
h.logf("%s: %s moved by the newer %s leave it, %d of its open steps ended superseded (H-A-223); %d stay: %s (H-A-361)", key,
|
||||
strings.Join(moved, ", "), newer.Pipeline, len(ended), len(stay), strings.Join(stay, ", "))
|
||||
if len(again) > 0 {
|
||||
h.logf("%s: %s, not asked on a dependency that left, placed again (H-A-361)", key, strings.Join(again, ", "))
|
||||
}
|
||||
for _, i := range ended {
|
||||
if err := h.say(seat.EventStepEnded, p, &p.Steps[i]); err != nil {
|
||||
h.logf("step-ended of %s's %s %s, superseded, is not said: %v", key, p.Steps[i].Module, p.Steps[i].Step, err)
|
||||
@@ -142,10 +153,44 @@ func (h *Hearer) supersedeRunningOne(key string, newer seat.Pipeline) bool {
|
||||
h.logf("%v", err)
|
||||
}
|
||||
h.appendUnlogged(key)
|
||||
// The movers that stay and waited on a mover that left are placed now, building against the newest published package
|
||||
// (H-A-53, H-A-361): no event of the mover that left comes to this pipeline again.
|
||||
if !done && h.Release != nil {
|
||||
h.Release(key)
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
// takeOutNotAsked takes out of p the steps of each mover that stays whose steps ended not asked because a dependency did not
|
||||
// build, that dependency a mover that left p, or a mover itself taken out here (H-A-361): a left mover is no dependency of
|
||||
// the movers that stay (H-A-53), so they are placed again, and a dependency that truly did not build is named again at that
|
||||
// placing. It answers the movers taken out, in p's order.
|
||||
func takeOutNotAsked(p *seat.Pipeline) []string {
|
||||
var out []string
|
||||
for changed := true; changed; {
|
||||
changed = false
|
||||
for _, m := range p.Movers {
|
||||
if slices.Contains(p.Superseded, m.Module) || slices.Contains(out, m.Module) {
|
||||
continue
|
||||
}
|
||||
dep := ""
|
||||
for _, st := range stepsOf(*p, m.Module) {
|
||||
if d, ok := notBuiltDependency(st); ok {
|
||||
dep = d
|
||||
break
|
||||
}
|
||||
}
|
||||
if dep == "" || (!slices.Contains(p.Superseded, dep) && !slices.Contains(out, dep)) {
|
||||
continue
|
||||
}
|
||||
p.Steps = slices.DeleteFunc(p.Steps, func(st seat.StepResult) bool { return st.Module == m.Module })
|
||||
out, changed = append(out, m.Module), true
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// supersedeStep ends the open or waiting step st of p superseded, naming why, with its step log entry: a step reading a test
|
||||
// run is answered to leave it, and one with its own ask on a build node to drop it (H-A-223).
|
||||
func supersedeStep(p *seat.Pipeline, st *seat.StepResult, why string, now time.Time) (leave, drop []seat.StepResult) {
|
||||
|
||||
@@ -279,6 +279,12 @@ func TestATestRunsEndMovesEveryReaderAndIsCountedOnce(t *testing.T) {
|
||||
a := f.start(t, 4, 9)
|
||||
b := f.start(t, 6, 9) // the same candidate: it reads a's runs
|
||||
unit := stepNamed(a, "app:program", "unit")
|
||||
// One journal line per ask put, naming the pipeline, the mover, the step and the seat (H-A-320 (1)).
|
||||
if n := countLines(f.logged, a.Pipeline+" app unit asked on node-build-go"); n != 1 || len(f.asks.ids) == 0 ||
|
||||
countLines(f.logged, " asked on ") != len(f.asks.ids) {
|
||||
t.Errorf("journal %q for %d asks put; want one asked-on line per ask, a's unit ask once", f.logged, len(f.asks.ids))
|
||||
}
|
||||
f.logged = nil
|
||||
ended := time.Now()
|
||||
if _, err := f.h.OnStepEnded(stepSeatOf(t, "node-build-go"), "mesh.seat.node-build-go.event.step-ended.ace", StepEnded{ID: unit.Ask,
|
||||
Pipeline: a.Pipeline, Module: "app", Commit: "c1", Fingerprint: "src2:aa", Step: "unit", Node: "ace", Outcome: "failed",
|
||||
@@ -309,6 +315,13 @@ func TestATestRunsEndMovesEveryReaderAndIsCountedOnce(t *testing.T) {
|
||||
if saidReaders != 4 {
|
||||
t.Errorf("said %d unit step-ended, want one per reading step", saidReaders)
|
||||
}
|
||||
// One journal line per step's end, the asking step's and each reader's, naming its pipeline, mover, step, outcome and node
|
||||
// (H-A-320 (1)).
|
||||
for _, key := range []string{a.Pipeline, b.Pipeline} {
|
||||
if n := countLines(f.logged, key+" app unit ended failed (ace, "); n != 2 {
|
||||
t.Errorf("%s's unit ends journaled %d times in %q, want once per artifact", key, n, f.logged)
|
||||
}
|
||||
}
|
||||
// a, cancelled, leaves the lint run to b's readers; b, cancelled after, leaves none: the ask is dropped and the run ends.
|
||||
lint := stepNamed(a, "app:program", "lint")
|
||||
v := Verbs{Hearer: f.h, Acts: &actLog{}}
|
||||
@@ -678,3 +691,14 @@ func TestNoWriteOfATestRunActsOnAReadBeforeItsLatestChange(t *testing.T) {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// countLines is how many of the journal's lines hold part.
|
||||
func countLines(lines []string, part string) int {
|
||||
n := 0
|
||||
for _, l := range lines {
|
||||
if strings.Contains(l, part) {
|
||||
n++
|
||||
}
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
@@ -326,7 +326,7 @@ func (v Verbs) Rerun(caller string, in seat.RerunInput) (seat.RerunAnswer, error
|
||||
}
|
||||
if ask != nil {
|
||||
v.Starter.carry(in.Pipeline, []Asked{*ask})
|
||||
if err := askAll(v.Starter.Steps, in.Pipeline, []Asked{*ask}, func(commit string) bool { return v.Starter.recovered(in.Pipeline, commit) }, v.Starter.Asks.arm); err != nil {
|
||||
if err := askAll(v.Starter.Steps, in.Pipeline, []Asked{*ask}, func(commit string) bool { return v.Starter.recovered(in.Pipeline, commit) }, v.Starter.Asks.arm, v.Starter.logf); err != nil {
|
||||
return seat.RerunAnswer{}, fmt.Errorf("the step is written running but not asked, it is asked again at the next start: %w", err)
|
||||
}
|
||||
}
|
||||
@@ -473,7 +473,7 @@ func (v Verbs) rerunTest(caller string, in seat.RerunInput, st seat.StepResult)
|
||||
break
|
||||
}
|
||||
v.Starter.carry(in.Pipeline, []Asked{*ask})
|
||||
if err := askAll(v.Starter.Steps, in.Pipeline, []Asked{*ask}, func(commit string) bool { return v.Starter.recovered(in.Pipeline, commit) }, v.Starter.Asks.arm); err != nil {
|
||||
if err := askAll(v.Starter.Steps, in.Pipeline, []Asked{*ask}, func(commit string) bool { return v.Starter.recovered(in.Pipeline, commit) }, v.Starter.Asks.arm, v.Starter.logf); err != nil {
|
||||
return seat.RerunAnswer{}, fmt.Errorf("the step is written running but not asked, it is asked again at the next start: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user