Compare commits
17
Commits
go/v0.1.22
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
277c53067e | ||
|
|
227f6e68ce | ||
|
|
744204c5ab | ||
|
|
0f41b405ba | ||
|
|
20f0e9baaf | ||
|
|
75c636a5ec | ||
|
|
0cbabe9860 | ||
|
|
d2c9dc7de6 | ||
|
|
53199f16ce | ||
|
|
256eb34a0d | ||
|
|
a47c8e7922 | ||
|
|
16f9ad2950 | ||
|
|
b1f25f91d5 | ||
|
|
d281faeeb7 | ||
|
|
e312999843 | ||
|
|
5dba7fe68b | ||
|
|
20a7bd0f3c |
@@ -1769,6 +1769,11 @@ func serveCatalog(t *testing.T, b *bed, nc *nats.Conn) {
|
||||
}
|
||||
if kept, ok := b.cat.at[branch][in.Revision]; ok {
|
||||
rev := meshcatalog.CatalogRevision{Kind: "trunk", Branch: in.Branch, Revision: in.Revision}
|
||||
for k := range b.cat.at[branch] { // its base, the newest kept below it, as the take-in names it (H-A-154)
|
||||
if k < in.Revision && k > rev.Base {
|
||||
rev.Base = k
|
||||
}
|
||||
}
|
||||
for _, e := range kept {
|
||||
rev.Entries = append(rev.Entries, meshcatalog.EntryRef{Module: e.Module, Digest: e.ManifestDigest})
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ import (
|
||||
// `<pipeline>.validate` of the state composition-runs in the CompositionRun form with no machine, which every mover's step
|
||||
// reads: the cycle the revision's entries make (graph.RefusedCycle) ends it at once; else the manifest validator built from
|
||||
// the revision's own entry of the module holding the seat mesh-catalog, on the Go build seat as the composer is, runs in the
|
||||
// sandbox over the revision's manifests and the branch's previous revision's, its input kept and served on mesh-wants' input.
|
||||
// sandbox over the revision's manifests and its base's (H-A-154), its input kept and served on mesh-wants' input.
|
||||
// Every mover's step ends the same: failed `cycle` naming the cycle, failed `manifest-refused` naming every problem of a
|
||||
// manifest the revision alters or between manifests one it alters takes part in, or passed.
|
||||
|
||||
@@ -32,7 +32,7 @@ const (
|
||||
validatorPackage = "mesh-delivery-indexer/cmd/mesh-judge"
|
||||
// validateKeySuffix ends the key of a revision's validate run, `<pipeline>.validate` (H-A-108).
|
||||
validateKeySuffix = "." + meshwants.StepRunStepValidate
|
||||
// beforeCase is the validator's case of the branch's previous revision, beside changeCase (H-A-108 (3)).
|
||||
// beforeCase is the validator's case of the revision's base, beside changeCase (H-A-108 (3), H-A-151, H-A-154).
|
||||
beforeCase = "before"
|
||||
// The reasons a validate step fails with, the first word of its said (§745).
|
||||
reasonManifestRefused = "manifest-refused"
|
||||
@@ -112,16 +112,29 @@ func (r *compositionRun) judgeValidate(ctx context.Context, step meshwants.StepR
|
||||
if err != nil {
|
||||
return couldNotRun("the step's catalog revision is not read: " + err.Error())
|
||||
}
|
||||
before, err := r.before(ctx, step)
|
||||
before, err := r.before(ctx, step, half)
|
||||
if err != nil {
|
||||
return couldNotRun("the branch's previous catalog revision is not read: " + err.Error())
|
||||
return couldNotRun("the base of the case before is not read: " + err.Error())
|
||||
}
|
||||
// A revision that names no base (the branch's first take-in) is judged against an empty case before, and says so (H-A-151).
|
||||
empty := ""
|
||||
if half.Revision.Base <= 0 {
|
||||
empty = emptyBeforeWords
|
||||
}
|
||||
if problems := causedProblems(v.Change, v.Before, altered(half, before)); len(problems) > 0 {
|
||||
return stepOutcome{Outcome: meshwants.StepEndedOutcomeFailed, Said: reasonManifestRefused + ": " + strings.Join(problems, "; ")}
|
||||
said := reasonManifestRefused + ": " + strings.Join(problems, "; ")
|
||||
if empty != "" {
|
||||
said += " (" + empty + ")"
|
||||
}
|
||||
return stepOutcome{Outcome: meshwants.StepEndedOutcomeFailed, Said: said}
|
||||
}
|
||||
return stepOutcome{Outcome: meshwants.StepEndedOutcomePassed}
|
||||
return stepOutcome{Outcome: meshwants.StepEndedOutcomePassed, Said: empty}
|
||||
}
|
||||
|
||||
// emptyBeforeWords say, in a validate step's end, that its revision names no base: the branch's first take-in, judged against
|
||||
// an empty case before (H-A-151, H-A-154).
|
||||
const emptyBeforeWords = "the case before is empty: the revision names no base, the branch's first take-in"
|
||||
|
||||
// validateVerdict is a validate run's verdict as the run keeps it: the cycle the revision makes, or the validator's two cases.
|
||||
type validateVerdict struct {
|
||||
Cycle []meshcatalog.ArtifactRef `json:"cycle,omitempty"`
|
||||
@@ -148,15 +161,16 @@ func cycleWords(cycle []meshcatalog.ArtifactRef) string {
|
||||
return strings.Join(words, " → ")
|
||||
}
|
||||
|
||||
// before is the branch's catalog revision before the step's, read through the seat mesh-catalog's verb revision (H-A-108 (3));
|
||||
// none before the first.
|
||||
func (r *compositionRun) before(ctx context.Context, step meshwants.StepRun) (mcc.Half, error) {
|
||||
if step.Revision <= 1 {
|
||||
// before is the case before of the step's revision half: the revision its base names, the newest kept revision below it that
|
||||
// its take-in pinned, read through the seat mesh-catalog's verb revision (H-A-108 (3), H-A-151, H-A-154); empty where the
|
||||
// revision names no base, the branch's first take-in.
|
||||
func (r *compositionRun) before(ctx context.Context, step meshwants.StepRun, half mcc.Half) (mcc.Half, error) {
|
||||
if half.Revision.Base <= 0 {
|
||||
return mcc.Half{Entries: map[string]meshcatalog.CatalogEntry{}}, nil
|
||||
}
|
||||
prev := step
|
||||
prev.Revision--
|
||||
return r.revision(ctx, prev)
|
||||
base := step
|
||||
base.Revision = half.Revision.Base
|
||||
return r.revision(ctx, base)
|
||||
}
|
||||
|
||||
// altered are the modules whose manifest the revision adds or changes against the one before it.
|
||||
@@ -270,9 +284,9 @@ func (r *compositionRun) startValidate(ctx context.Context, key string, run mesh
|
||||
end(meshwants.CompositionRunOutcomePassed, "", verdict)
|
||||
return
|
||||
}
|
||||
before, err := r.before(ctx, step)
|
||||
before, err := r.before(ctx, step, half)
|
||||
if err != nil {
|
||||
couldNot("the branch's previous catalog revision is not read: " + err.Error())
|
||||
couldNot("the base of the case before is not read: " + err.Error())
|
||||
return
|
||||
}
|
||||
entry, ok := catalogEntry(half.Entries)
|
||||
|
||||
@@ -20,7 +20,9 @@ import (
|
||||
// run, `<pipeline>.validate` of the state composition-runs; a manifest the revision alters that names an unknown field fails
|
||||
// it `manifest-refused` naming the problem, a problem of a manifest it leaves as it was does not, and the validator is the
|
||||
// revision's own entry of the module holding the seat mesh-catalog, on the Go build seat; a revision whose entries make a cycle
|
||||
// fails it `cycle` naming the cycle, with no validator asked.
|
||||
// fails it `cycle` naming the cycle, with no validator asked. The case before is the revision its base names (H-A-151, H-A-154:
|
||||
// the newest kept below it, which the stand-in names as the indexer does); a revision naming no base, the branch's first take-in,
|
||||
// is judged against an empty case before, said in its end, and no revision below it is asked.
|
||||
func TestTheValidateStepRefusesAManifestProblemAndACycle(t *testing.T) {
|
||||
indexer := meshcatalog.CatalogEntry{Module: "indexer", Repository: "novox/mesh-delivery", Commit: commitE3, Path: "modules/mesh-delivery-indexer",
|
||||
Fp: "src2:ix", Serves: []string{"seat:" + meshcatalog.Seat + ".revision"}, Manifest: map[string]any{"module": "indexer"}, ManifestDigest: "d-ix"}
|
||||
@@ -28,9 +30,24 @@ func TestTheValidateStepRefusesAManifestProblemAndACycle(t *testing.T) {
|
||||
return meshcatalog.CatalogEntry{Module: module, Manifest: map[string]any{"module": module, "d": digest}, ManifestDigest: digest, Edges: edges}
|
||||
}
|
||||
revisions := map[int64][]meshcatalog.CatalogEntry{
|
||||
6: {indexer, entry("web", "d-web-1"), entry("db", "d-db")},
|
||||
7: {indexer, entry("web", "d-web-2"), entry("db", "d-db")},
|
||||
9: {indexer, entry("a", "d-a", meshcatalog.Edge{From: "a:x", To: "b:y", Kind: 3}, meshcatalog.Edge{From: "b:y", To: "a:x", Kind: 3}), entry("b", "d-b")},
|
||||
6: {indexer, entry("web", "d-web-1"), entry("db", "d-db")},
|
||||
7: {indexer, entry("web", "d-web-2"), entry("db", "d-db")},
|
||||
9: {indexer, entry("a", "d-a", meshcatalog.Edge{From: "a:x", To: "b:y", Kind: 3}, meshcatalog.Edge{From: "b:y", To: "a:x", Kind: 3}), entry("b", "d-b")},
|
||||
3: {indexer},
|
||||
12: {indexer, entry("web", "d-web-2"), entry("db", "d-db")},
|
||||
}
|
||||
// base is the newest kept revision below n, as the take-in names it; none below the first. Revision 12 names 7 with 8 to 11
|
||||
// never kept, so a case before read as the number minus one could not run (H-A-154).
|
||||
base := func(n int64) (b int64) {
|
||||
if n == 12 {
|
||||
return 7
|
||||
}
|
||||
for k := range revisions {
|
||||
if k < n && k > b {
|
||||
b = k
|
||||
}
|
||||
}
|
||||
return b
|
||||
}
|
||||
call := func(key string, body any) (json.RawMessage, error) {
|
||||
raw, _ := json.Marshal(body)
|
||||
@@ -42,7 +59,7 @@ func TestTheValidateStepRefusesAManifestProblemAndACycle(t *testing.T) {
|
||||
if !ok || in.Branch != "main" {
|
||||
return nil, errors.New("asked another revision")
|
||||
}
|
||||
return json.Marshal(meshcatalog.RevisionAnswer{Revision: &meshcatalog.CatalogRevision{Revision: in.Revision,
|
||||
return json.Marshal(meshcatalog.RevisionAnswer{Revision: &meshcatalog.CatalogRevision{Revision: in.Revision, Base: base(in.Revision),
|
||||
Definitions: []meshcatalog.CatalogRevisionDefinitionsItem{{Seat: "s1", Digest: "sd"}}}, Entries: entries})
|
||||
case seatDefinitionsKey:
|
||||
return json.Marshal(meshcatalog.SeatDefinitionsAnswer{Found: true, Entry: &meshcatalog.SeatDefinitionsAnswerEntry{Seat: "s1", Digest: "sd", Definition: map[string]any{"seat": "s1"}}})
|
||||
@@ -117,4 +134,17 @@ func TestTheValidateStepRefusesAManifestProblemAndACycle(t *testing.T) {
|
||||
if o.Outcome != meshwants.StepEndedOutcomeFailed || o.Said != reasonCycle+": a:x → b:y → a:x" || len(asks) != 1 {
|
||||
t.Errorf("a revision making a cycle ended %+v (%d validator asks)", o, len(asks))
|
||||
}
|
||||
// The stand-in validator answers its one verdict: judged against the empty case before, web's problem is the revision's.
|
||||
if o := r.validate(ctx, "ask-first", step("indexer", 3)); o.Outcome != meshwants.StepEndedOutcomeFailed ||
|
||||
o.Said != reasonManifestRefused+`: web: unknown field "colour" (`+emptyBeforeWords+")" || len(asks) != 2 || len(requests[1].Cases[1].Manifests) != 0 {
|
||||
t.Errorf("a revision naming no base ended %+v (%d validator asks), want it judged against an empty case before, said", o, len(asks))
|
||||
}
|
||||
// Revision 12 holds revision 7's manifests and names base 7: judged against it, web's problem is the revision's, db's old one
|
||||
// is not, and the case before holds base 7's manifests.
|
||||
if o := r.validate(ctx, "ask-base", step("web", 12)); o.Outcome != meshwants.StepEndedOutcomeFailed ||
|
||||
o.Said != reasonManifestRefused+`: web: unknown field "colour"` || len(asks) != 3 {
|
||||
t.Errorf("a revision naming base 7 below its number ended %+v (%d validator asks), want it judged against base 7", o, len(asks))
|
||||
} else if web := requests[2].Cases[1].Manifests["web"]; len(requests[2].Cases[1].Manifests) != 3 || !strings.Contains(string(web.Raw), "d-web-2") {
|
||||
t.Errorf("the case before of revision 12 is %+v, want base 7's manifests", requests[2].Cases[1].Manifests)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,6 +132,20 @@ func (c *catalogHalf) Changed(ctx context.Context) func(branch, module string, e
|
||||
}
|
||||
}
|
||||
|
||||
// picture is build.Builder.Picture: the source revision the view of branch holds (design 47 H H-A-155), false while the branch
|
||||
// is not followed or its view holds none.
|
||||
func (c *catalogHalf) picture(branch string) (int64, bool) {
|
||||
cat, ok := c.branches.Catalog(branch)
|
||||
if !ok {
|
||||
return 0, false
|
||||
}
|
||||
half, ok := cat.View()
|
||||
if !ok {
|
||||
return 0, false
|
||||
}
|
||||
return half.Revision.Source, true
|
||||
}
|
||||
|
||||
// namesOf are the package names an entry's artifacts carry, in one line.
|
||||
func namesOf(e meshcatalog.CatalogEntry) string {
|
||||
var names []string
|
||||
|
||||
+7
-2
@@ -33,8 +33,13 @@ type catalogHolder struct {
|
||||
mu sync.Mutex
|
||||
entries map[string]meshcatalog.CatalogEntry
|
||||
revision int64
|
||||
// source is the source revision each trunk revision is taken in from; 0 is 1.
|
||||
source int64
|
||||
}
|
||||
|
||||
// sourceLocked is the source revision of the revisions put now. The caller holds mu.
|
||||
func (h *catalogHolder) sourceLocked() int64 { return max(h.source, 1) }
|
||||
|
||||
func newCatalogHolder(t *testing.T, ctx context.Context, js jetstream.JetStream, nc *nats.Conn) *catalogHolder {
|
||||
t.Helper()
|
||||
h := &catalogHolder{ctx: ctx, js: js, entries: map[string]meshcatalog.CatalogEntry{}}
|
||||
@@ -84,7 +89,7 @@ func (h *catalogHolder) whole() meshcatalog.RevisionAnswer {
|
||||
all = append(all, e)
|
||||
}
|
||||
at := time.Now()
|
||||
return meshcatalog.RevisionAnswer{Revision: &meshcatalog.CatalogRevision{Revision: h.revision, Kind: "trunk", Branch: "main", Entries: refs, Source: 1, At: &at}, Entries: all}
|
||||
return meshcatalog.RevisionAnswer{Revision: &meshcatalog.CatalogRevision{Revision: h.revision, Kind: "trunk", Branch: "main", Entries: refs, Source: h.sourceLocked(), At: &at}, Entries: all}
|
||||
}
|
||||
|
||||
// put sets one module's entry in a new trunk revision of main and says catalog-revision.
|
||||
@@ -100,7 +105,7 @@ func (h *catalogHolder) putAll(t *testing.T, es ...meshcatalog.CatalogEntry) {
|
||||
h.entries[e.Module] = e
|
||||
changed = append(changed, e.Module)
|
||||
}
|
||||
ev, _ := json.Marshal(meshcatalog.CatalogRevisionEvent{Branch: "main", Kind: "trunk", Revision: h.revision, Source: 1, Entries: int64(len(h.entries)), Changed: changed, V: 1})
|
||||
ev, _ := json.Marshal(meshcatalog.CatalogRevisionEvent{Branch: "main", Kind: "trunk", Revision: h.revision, Source: h.sourceLocked(), Entries: int64(len(h.entries)), Changed: changed, V: 1})
|
||||
h.mu.Unlock()
|
||||
if _, err := h.js.Publish(h.ctx, meshcatalog.SubjectCatalogRevision("main"), ev); err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
@@ -522,9 +522,9 @@ func isState(state string) func(builds.BuilderBuild) bool {
|
||||
// the digests of both bundles, both build modules' toolchains, after a fetch and a build on one node (ADR 0478 clause 4).
|
||||
func TestBuilderMakesADoneKeyWithTheDigests(t *testing.T) { // 1607/AC7
|
||||
b := startBed(t)
|
||||
// DLV-B10 (design 51, round 2): the builder's versions, findings and the floor's three sources are on the bus; the seat
|
||||
// answers 0.1.4, so netcheck's bundles are numbered from 0.1.5. Two merges close together, the first replaced before
|
||||
// its claim: the second is numbered at once, and the first never.
|
||||
// The builder's versions, findings and the floor's three sources are on the bus, the seat answering 0.1.4; two merges close
|
||||
// together, the first replaced before its claim. The builder numbers neither in its state versions (design 47 H H-A-159,
|
||||
// G §348, §369): the reservation is the one place a version is numbered.
|
||||
reg := b.registry(t, "n1", "0.1.4")
|
||||
const netcheck = "catalogue-a67f0196-netcheck.module.json"
|
||||
first := "src2:" + strings.Repeat("1", 64)
|
||||
@@ -534,8 +534,8 @@ func TestBuilderMakesADoneKeyWithTheDigests(t *testing.T) { // 1607/AC7
|
||||
v := b.await(t, "netcheck", isState(builds.BuildDone))
|
||||
for _, a := range []string{"tools-go", "tools-typescript"} {
|
||||
es := reg.of(t, "netcheck/"+a)
|
||||
if len(es) != 1 || es[0].Version != "0.1.5" || es[0].Fingerprint != fp || es[0].State != versions.Numbered || es[0].Digest != digestOf(a) {
|
||||
t.Errorf("versions of netcheck/%s = %+v, want the second merge numbered 0.1.5 at once with its digest, the first never", a, es)
|
||||
if len(es) != 0 {
|
||||
t.Errorf("versions of netcheck/%s = %+v, want none: the builder numbers nothing of its own (H-A-159)", a, es)
|
||||
}
|
||||
}
|
||||
if v.By != "n1.mesh-delivery-builder" || v.Manifest != digest || len(v.Artifacts) != 2 {
|
||||
@@ -565,13 +565,13 @@ func TestBuilderMakesADoneKeyWithTheDigests(t *testing.T) { // 1607/AC7
|
||||
}
|
||||
// 1955/L7 (ADR 0571 §1): the build's start and end are in the module log build-log under the module's key, read as a
|
||||
// reader with the log's read reads them, the end naming the manifest and what was made.
|
||||
// DLV-B10: between them the build log holds the build's narrations (build.said), each version numbered, and why.
|
||||
// H-A-159: no version is numbered of the builder's own, so the build log holds no narration of one (build.said).
|
||||
var ended []builds.BuildLogEntry
|
||||
for _, e := range b.logged(t, "netcheck") {
|
||||
if e.Event != builds.BuildSaidEvent {
|
||||
ended = append(ended, e)
|
||||
} else if e.Why != versions.SaidNumbered || !strings.Contains(e.Line, "numbered 0.1.5") || e.FP != fp {
|
||||
t.Errorf("said = %+v, want netcheck's versions numbered", e)
|
||||
} else if e.Why == versions.SaidNumbered || e.Why == versions.SaidKept {
|
||||
t.Errorf("said = %+v, want no version of the builder's own numbered (H-A-159)", e)
|
||||
}
|
||||
}
|
||||
if len(ended) != 2 || ended[0].Event != builds.BuildStartedEvent || ended[1].Event != builds.BuildEndedEvent ||
|
||||
@@ -596,7 +596,7 @@ func TestBuilderMakesADoneKeyWithTheDigests(t *testing.T) { // 1607/AC7
|
||||
}
|
||||
}
|
||||
// Design 32, design 47 G §348: a package's name the catalog half's entry of the module gives later reaches the builder by the
|
||||
// branch follower's view (never the indexer's state), and looks at the module again; the done bundles are kept, not numbered twice.
|
||||
// branch follower's view (never the indexer's state), and looks at the module again.
|
||||
named := b.entry("netcheck", "modules/netcheck", commit, fp, digest, nil, bothToolchains, 0)
|
||||
named.Manifest = b.manifestOf(t, "catalogue-a67f0196-netcheck.module.json")
|
||||
named.Artifacts = []meshcatalog.Artifact{{Ref: "netcheck:lib", Language: "go", Package: &meshcatalog.ArtifactPackage{Ecosystem: "go", Name: "netcheck"}}}
|
||||
@@ -606,11 +606,12 @@ func TestBuilderMakesADoneKeyWithTheDigests(t *testing.T) { // 1607/AC7
|
||||
if got := reg.numberedOf("netcheck/tools-go"); len(got) != 0 {
|
||||
t.Errorf("version.numbered of netcheck/tools-go said %v, want none", got)
|
||||
}
|
||||
for _, a := range []string{"tools-go", "tools-typescript"} {
|
||||
reg.published(t, "netcheck/"+a, "0.1.5", digestOf(a))
|
||||
// Versions numbered before G, which the state keeps until G §372 removes it: one a holder removes below, one it refuses.
|
||||
kept, _ := json.Marshal(versions.Entry{Name: "netcheck/tools-typescript", Kind: versions.KindBundle, Series: "0.1", Version: "0.1.5", Module: "netcheck",
|
||||
Fingerprint: fp, Digest: digestOf("tools-typescript"), Seat: ociartifactregistry.Seat, State: versions.Published, At: time.Now().UTC()})
|
||||
if _, err := reg.versions.Put(b.ctx, versions.Key("netcheck/tools-typescript", "0.1.5"), kept); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
reg.awaitOf(t, "netcheck/tools-go", func(es []versions.Entry) bool { return len(es) == 1 && es[0].State == versions.Published })
|
||||
// A numbered version a holder will refuse below, written to the state as the builder numbers one.
|
||||
refusable, _ := json.Marshal(versions.Entry{Name: "netcheck/tools-go", Kind: versions.KindBundle, Series: "0.1", Version: "0.1.6", Module: "netcheck",
|
||||
Fingerprint: "src2:" + strings.Repeat("6", 64), Seat: ociartifactregistry.Seat, State: versions.Numbered, At: time.Now().UTC()})
|
||||
if _, err := reg.versions.Put(b.ctx, versions.Key("netcheck/tools-go", "0.1.6"), refusable); err != nil {
|
||||
@@ -643,7 +644,7 @@ func TestBuilderMakesADoneKeyWithTheDigests(t *testing.T) { // 1607/AC7
|
||||
t.Errorf("version.numbered of netcheck/tools-go said %v, want none", got)
|
||||
}
|
||||
// DLV-B10: a build module's bound running out fails the trunk build, which is the builder's finding build-failed; the
|
||||
// fingerprint built again keeps its number, said with why, and its done build clears the finding.
|
||||
// fingerprint built again clears it with its done build, numbering nothing of the builder's own (H-A-159).
|
||||
release := make(chan struct{})
|
||||
b.fake.hang.Store(&release)
|
||||
third := "src2:" + strings.Repeat("4", 64)
|
||||
@@ -666,12 +667,6 @@ func TestBuilderMakesADoneKeyWithTheDigests(t *testing.T) { // 1607/AC7
|
||||
close(release)
|
||||
b.moduleFP(t, "netcheck", netcheck, "modules/netcheck", bothToolchains, "89abcdef0123456789abcdef0123456789abcdef", third, 3) // the entry moves to a later commit, same fingerprint
|
||||
b.awaitFP(t, "netcheck", third, isState(builds.BuildDone))
|
||||
b.awaitSaid(t, "kept: fingerprint "+third+" is numbered under it")
|
||||
if !slices.ContainsFunc(b.logged(t, "netcheck"), func(e builds.BuildLogEntry) bool {
|
||||
return e.Event == builds.BuildSaidEvent && e.Why == versions.SaidKept && e.FP == third && strings.Contains(e.Line, "kept: fingerprint "+third)
|
||||
}) {
|
||||
t.Errorf("the build log of netcheck says no version kept at %s", third)
|
||||
}
|
||||
reg.awaitFinding(t, failed, false)
|
||||
// DLV-B4: the seats' refused and removed, heard on the builder's durable consumer, move a numbered version: a retention
|
||||
// removal turns the entry removed with its reason, a refusal refused with the holder's reason and the bytes it refused.
|
||||
|
||||
@@ -35,6 +35,7 @@ import (
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient"
|
||||
sweep "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshartifactsweep"
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshbuilds"
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep"
|
||||
"git.novox.be/novox/mesh-sdk/go/operatorask"
|
||||
"git.novox.be/novox/mesh-sdk/go/process"
|
||||
@@ -156,9 +157,9 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
|
||||
conn.SetReconnectHandler(func(*nats.Conn) { hearing.Again(); heard.Nudge("") })
|
||||
// The builder asks the controller, as its own account, whether the artifact store still holds a done key's blobs
|
||||
// (the seat verb held, novox/hq issue 1937) before it leaves the key done, on its calls connection.
|
||||
// The builder numbers each trunk build at its claim (novox/hq design 51 *The versions*): its state versions, bound once
|
||||
// the bus holds it; the floor's three sources asked as its own account.
|
||||
versionsKV := process.AwaitBucket(ctx, js, conn, own.versions, "no trunk build is numbered: each is built unnumbered and published by its digest", logger.Printf)
|
||||
// The state versions, kept from before G (design 51 *The versions*) and read through builder_versions until G §372 removes
|
||||
// it, bound once the bus holds it; the builder numbers nothing in it (design 47 H H-A-159).
|
||||
versionsKV := process.AwaitBucket(ctx, js, conn, own.versions, "builder_versions answers nothing of the versions numbered before G", logger.Printf)
|
||||
found := &findings{module: cred.Module, w: fw, logf: logger.Printf, now: time.Now}
|
||||
floorWaits := &versions.FloorWaits{Holder: versions.HolderOf(branches), Logf: logger.Printf, Said: found.floorSaid(context.WithoutCancel(ctx))}
|
||||
// The names waiting on their floor are kept in the state floor-waits (DLV-B4): a restarted builder takes them in, so
|
||||
@@ -205,13 +206,28 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
|
||||
unput := &unputs{bounds: pubBoundsKV.KV, store: b.Claimer.Store, looking: b.Looking, findings: found,
|
||||
bound: meshconditionsclient.CallUnansweredAfter, now: time.Now, logf: logger.Printf}
|
||||
b.Left, b.Ended = unput.left, unput.ended
|
||||
b.Numbers = build.VersionNumbers{N: numberer}
|
||||
// The builder numbers nothing of its own (design 47 H H-A-159, G §348, §349, §369): b.Numbers stays nil, so no trunk build
|
||||
// is numbered in the state versions, waits on a floor or arms a publish-unanswered bound of it; the reservation is the one
|
||||
// place a version is numbered. The state, kept from before G, is still read (builder_versions) until G §372 removes it.
|
||||
// The builder's toolchain waits (design 47 G §672): its state waits, and wait-held and wait-ended on its stream waits; its
|
||||
// bound is its setting toolchain-wait-minutes.
|
||||
waitBound, err := toolchainWaitOf(getenv("MESH_BUILDER_TOOLCHAIN_WAIT_FILE"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// A build step ask waits for the builder's picture of its branch to hold its source revision (design 47 H H-A-155); its
|
||||
// bound is its setting revision-wait-minutes (H-A-156).
|
||||
revisionWait, err := numberFile(getenv("MESH_BUILDER_REVISION_WAIT_FILE"), int(build.DefaultRevisionWait/time.Minute))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
b.RevisionWait = time.Duration(revisionWait) * time.Minute
|
||||
// A step ask naming a package with no pin waits for its release (H-A-165); its bound is package-wait-minutes.
|
||||
packageWait, err := numberFile(getenv("MESH_BUILDER_PACKAGE_WAIT_FILE"), int(build.DefaultPackageWait/time.Minute))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
b.PackageWait = time.Duration(packageWait) * time.Minute
|
||||
waitsBucket := process.AwaitBucket(ctx, js, conn, builds.StateBucket(cred.Module, build.WaitsState), "the toolchain waits are kept in memory only, and builder_waits shows none", logger.Printf)
|
||||
b.Waits = newWaitsKept(waitsBucket, func(ctx context.Context, event, id string, body any) error {
|
||||
return emitEvent(context.WithoutCancel(ctx), js, cred, event, id, body)
|
||||
@@ -226,6 +242,9 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
|
||||
return emitSeatEvent(context.WithoutCancel(ctx), js, cred, meshbuilds.SubjectPackagePublished, "package-published-"+p.Module+"-"+p.Version+"-"+p.Artifact, p)
|
||||
}
|
||||
b.Reserved = reserved
|
||||
// A release heard, or the newest the builder's record keeps, pins a package an entry names with none (H-A-165).
|
||||
reserved.heardReleased = b.VersionReleased
|
||||
b.NewestReleased = reserved.r.NewestReleased
|
||||
// The last versions-filled the stream keeps is read at the start (design 47 G §369, §372): a restart does not lose it.
|
||||
reserved.readFilled(ctx, lastKeptOf(js, cred, logger.Printf), sleeps)
|
||||
// A state bound later numbers the builds looked at without it.
|
||||
@@ -450,6 +469,8 @@ func run(ctx context.Context, getenv func(string) string, logOut io.Writer) erro
|
||||
// fingerprint no branch carries is closed (issue 1660) once the first view of every followed branch is in (never at the start:
|
||||
// a holder of the seat that is down holds no other part of it).
|
||||
half.b = b
|
||||
b.Picture = half.picture
|
||||
branches.Held = func(string, meshcatalog.CatalogRevision) { b.PictureHeld() } // a revision held wakes a step ask's wait (H-A-162)
|
||||
half.ready = func() {
|
||||
if err := b.Sweep(ctx, half.pictured()...); err != nil {
|
||||
errs <- err
|
||||
|
||||
@@ -44,12 +44,15 @@ type reservations struct {
|
||||
// built asks a done build's publish (design 47 G A-457a), released ends its item; nil are none.
|
||||
built func(ctx context.Context, module, version string) error
|
||||
released func(ctx context.Context, module, version string)
|
||||
filled atomic.Bool
|
||||
bounds func() jetstream.KeyValue
|
||||
found *findings
|
||||
bound time.Duration
|
||||
wake func(context.Context)
|
||||
logf func(string, ...any)
|
||||
// heardReleased is told each version-released taken in (design 47 H H-A-165): a step ask waiting for a package of the
|
||||
// module wakes. Nil tells nobody.
|
||||
heardReleased func(module, version string)
|
||||
filled atomic.Bool
|
||||
bounds func() jetstream.KeyValue
|
||||
found *findings
|
||||
bound time.Duration
|
||||
wake func(context.Context)
|
||||
logf func(string, ...any)
|
||||
// call asks a seat's verb: the git seat's tag (design 47 G §370).
|
||||
call toolCaller
|
||||
// say says package-published on the seat mesh-builds; nil says none.
|
||||
@@ -252,6 +255,9 @@ func (rv *reservations) heard(ctx context.Context, m jetstream.Msg) bool {
|
||||
if rv.released != nil {
|
||||
rv.released(ctx, ev.Module, ev.Version)
|
||||
}
|
||||
if rv.heardReleased != nil {
|
||||
rv.heardReleased(ev.Module, ev.Version)
|
||||
}
|
||||
rv.found.clear(ctx, versions.VersionUnreleased, meshconditionsclient.ScopeModule, ev.Module)
|
||||
default:
|
||||
return false
|
||||
|
||||
@@ -134,10 +134,15 @@ func TestTheCatalogsWordsMoveTheReservations(t *testing.T) {
|
||||
if err != nil || !strings.Contains(got.Summary, "m:b unpublished") || strings.Contains(got.Summary, "m:a unpublished") || !strings.Contains(got.Summary, "1.4.3") {
|
||||
t.Fatalf("finding = %+v (%v), want version-unreleased naming m:b of 1.4.3", got, err)
|
||||
}
|
||||
var heardReleases []string // H-A-165: a release heard wakes a step ask waiting for a package of the module
|
||||
rv.heardReleased = func(m, v string) { heardReleases = append(heardReleases, m+" "+v) }
|
||||
released := &wakeMsg{subject: meshcatalog.SubjectVersionReleased, data: []byte(`{"v":1,"module":"m","version":"1.4.3","source":1,"artifacts":[]}`)}
|
||||
if !rv.heard(ctx, released) || !released.acked {
|
||||
t.Fatalf("version-released was not taken in (acked %v)", released.acked)
|
||||
}
|
||||
if strings.Join(heardReleases, ", ") != "m 1.4.3" {
|
||||
t.Errorf("the release heard was told %v, want m 1.4.3 (H-A-165)", heardReleases)
|
||||
}
|
||||
if strings.Join(items, ", ") != "asked m 1.4.3, ended m 1.4.3" {
|
||||
t.Errorf("publish items %v, want the build's end to ask the publish and the release to end it", items)
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -49,4 +50,29 @@ func TestTheRunnersBuildStepAskIsAnsweredAsStepEnded(t *testing.T) {
|
||||
case <-time.After(20 * time.Second):
|
||||
t.Fatal("no step-ended within 20 s")
|
||||
}
|
||||
// H-A-155: an ask naming a source revision the builder's picture of main does not hold yet waits for it, said in the
|
||||
// journal, and is answered once a revision taken in from it arrives.
|
||||
run.Pipeline, run.Revision, run.Source = "main.2.netcheck", 2, 2
|
||||
data, _ = json.Marshal(run)
|
||||
msg = nats.NewMsg(meshbuilds.AcceptSubjectStep)
|
||||
msg.Data = data
|
||||
msg.Header.Set("x-event-id", "ask-2")
|
||||
if err := sub.PublishMsg(msg); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
b.awaitSaid(t, "main.2.netcheck: revision 2 of main not in the builder's picture yet")
|
||||
b.catalog.mu.Lock()
|
||||
b.catalog.source = 2
|
||||
b.catalog.mu.Unlock()
|
||||
// Revision 2, taken in from source 2, moves another module: netcheck's entry is the one the picture holds already.
|
||||
b.moduleFP(t, "ca-trust", "catalogue-a67f0196-ca-trust.module.json", "modules/ca-trust", nil, commit, "src2:"+strings.Repeat("4", 64), 0)
|
||||
select {
|
||||
case m := <-ended:
|
||||
var end meshbuilds.StepEnded
|
||||
if err := json.Unmarshal(m.Data, &end); err != nil || end.ID != "ask-2" || end.Outcome != meshbuilds.StepEndedOutcomePassed {
|
||||
t.Fatalf("step-ended = %+v, %v; want the ask ask-2 passed once the picture held source revision 2", end, err)
|
||||
}
|
||||
case <-time.After(20 * time.Second):
|
||||
t.Fatal("no step-ended for ask-2 within 20 s")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,210 @@
|
||||
package build
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"maps"
|
||||
"slices"
|
||||
"time"
|
||||
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds"
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshbuilds"
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
||||
)
|
||||
|
||||
// **A build waits for its revision; a build with no version is never made** (design 47 H H-A-155, H-A-156; H-A-141): a step
|
||||
// ask names its branch and source revision, and the builder reserves the version before it builds. When the builder's picture
|
||||
// of that branch does not hold that source revision yet, or holds it but has not taken in the entry of the asked fingerprint
|
||||
// from it, the ask waits for the picture to take it in, woken by each entry the picture takes in (take, EntryGone) and each
|
||||
// revision its view holds (PictureHeld, H-A-162), never a
|
||||
// timer or a poll, up to RevisionWait (the setting revision-wait-minutes); past it the ask fails, naming the revision and the
|
||||
// branch, and nothing is built. A step ask with no source (a run on request) does not wait.
|
||||
|
||||
// DefaultRevisionWait is the bound of a step ask's wait for its revision, its setting revision-wait-minutes' default (H-A-156).
|
||||
const DefaultRevisionWait = 2 * time.Minute
|
||||
|
||||
func (b *Builder) revisionWait() time.Duration {
|
||||
if b.RevisionWait > 0 {
|
||||
return b.RevisionWait
|
||||
}
|
||||
return DefaultRevisionWait
|
||||
}
|
||||
|
||||
// PictureHeld is told each revision a branch's view takes in whole, whether or not an entry changed (H-A-162): every step
|
||||
// ask waiting for its revision looks again.
|
||||
func (b *Builder) PictureHeld() {
|
||||
b.init()
|
||||
b.pictureMoved()
|
||||
}
|
||||
|
||||
// pictureMoved wakes every step ask waiting for the picture: an entry was taken in or went, or a revision was held.
|
||||
func (b *Builder) pictureMoved() {
|
||||
b.mu.Lock()
|
||||
moved := b.moved
|
||||
b.moved = make(chan struct{})
|
||||
b.mu.Unlock()
|
||||
close(moved)
|
||||
}
|
||||
|
||||
// holdsRevision says whether the builder's picture of branch holds the source revision and has taken in every entry of the
|
||||
// ask from that branch.
|
||||
func (b *Builder) holdsRevision(branch string, source int64, entries []meshbuilds.BuildEntry) bool {
|
||||
held, ok := b.Picture(branch)
|
||||
if !ok || held < source {
|
||||
return false
|
||||
}
|
||||
b.mu.Lock()
|
||||
defer b.mu.Unlock()
|
||||
for _, e := range entries {
|
||||
key, err := builds.BuilderBuildKey(e.Module, e.Fingerprint)
|
||||
if err != nil {
|
||||
return true // the build key is refused where the entry is built, with why
|
||||
}
|
||||
if b.origin[key].Branch != branch && b.heard[branch+"\x00"+e.Module].Fp2 != e.Fingerprint {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// awaitRevision returns no outcome once the builder's picture of the ask's branch holds its source revision; past the bound the
|
||||
// step's outcome failed, at the builder's stop could not run, each with its words.
|
||||
func (b *Builder) awaitRevision(ctx context.Context, run meshbuilds.StepRun) (outcome, said string) {
|
||||
if b.Picture == nil || run.Source <= 0 || run.Branch == "" {
|
||||
return "", ""
|
||||
}
|
||||
bound := b.revisionWait()
|
||||
notHeld := fmt.Sprintf("revision %d of %s not in the builder's picture", run.Source, run.Branch)
|
||||
wait, stop := context.WithTimeout(ctx, bound) // a context's bound, no timer (ADR 0437 §8)
|
||||
defer stop()
|
||||
told := false
|
||||
for {
|
||||
b.mu.Lock()
|
||||
moved := b.moved
|
||||
b.mu.Unlock()
|
||||
if b.holdsRevision(run.Branch, run.Source, run.Entries) {
|
||||
if told {
|
||||
b.logf("%s: revision %d of %s is in the builder's picture: the build goes on", run.Pipeline, run.Source, run.Branch)
|
||||
}
|
||||
return "", ""
|
||||
}
|
||||
if !told {
|
||||
b.logf("%s: %s yet: the ask waits for it, at most %s", run.Pipeline, notHeld, bound)
|
||||
told = true
|
||||
}
|
||||
select {
|
||||
case <-moved:
|
||||
case <-wait.Done():
|
||||
if ctx.Err() != nil {
|
||||
return meshbuilds.StepEndedOutcomeCouldNotRun, notHeld + ": the builder stopped before it was"
|
||||
}
|
||||
b.logf("%s: %s within %s: the step fails, nothing is built", run.Pipeline, notHeld, bound)
|
||||
return meshbuilds.StepEndedOutcomeFailed, fmt.Sprintf("%s within %s", notHeld, bound)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// **A package with no pin waits for its release** (design 47 H H-A-165, H-A-161): an entry keeps a mesh package none of
|
||||
// whose versions is released with an empty version. Its step ask waits, as for its revision, for the release of the module
|
||||
// that holds the package (the catalog's version-released, VersionReleased), up to PackageWait (the setting
|
||||
// package-wait-minutes), then builds with that release as the package's pin (v<version>); past the bound the step fails,
|
||||
// naming the package, and nothing is built.
|
||||
|
||||
// DefaultPackageWait is the bound of a step ask's wait for a package's release, its setting package-wait-minutes' default.
|
||||
const DefaultPackageWait = 10 * time.Minute
|
||||
|
||||
func (b *Builder) packageWait() time.Duration {
|
||||
if b.PackageWait > 0 {
|
||||
return b.PackageWait
|
||||
}
|
||||
return DefaultPackageWait
|
||||
}
|
||||
|
||||
// VersionReleased takes the catalog's version-released of module in: a step ask waiting for a package of it wakes.
|
||||
func (b *Builder) VersionReleased(module, version string) {
|
||||
b.init()
|
||||
b.mu.Lock()
|
||||
b.releases[module] = version
|
||||
b.mu.Unlock()
|
||||
b.pictureMoved()
|
||||
}
|
||||
|
||||
// releaseOf is the pin a package is built against: the release of the module holding it, as Go names it; "" for none yet.
|
||||
func (b *Builder) releaseOf(ctx context.Context, pkg string) string {
|
||||
if b.Members == nil {
|
||||
return ""
|
||||
}
|
||||
module, _, found, err := b.Members(ctx, pkg)
|
||||
if err != nil || !found {
|
||||
return ""
|
||||
}
|
||||
b.mu.Lock()
|
||||
v := b.releases[module]
|
||||
b.mu.Unlock()
|
||||
if v == "" && b.NewestReleased != nil {
|
||||
if kept, ok, err := b.NewestReleased(ctx, module); err == nil && ok {
|
||||
v = kept
|
||||
}
|
||||
}
|
||||
if v == "" {
|
||||
return ""
|
||||
}
|
||||
return "v" + v
|
||||
}
|
||||
|
||||
// awaitPins fills each package entry names with no pin from its release, waiting for one; no outcome once every package has
|
||||
// a pin, failed past the bound, could not run at the builder's stop.
|
||||
func (b *Builder) awaitPins(ctx context.Context, entry *meshcatalog.CatalogEntry) (outcome, said string) {
|
||||
var unpinned []string
|
||||
for p, v := range entry.Packages {
|
||||
if v == "" {
|
||||
unpinned = append(unpinned, p)
|
||||
}
|
||||
}
|
||||
if len(unpinned) == 0 {
|
||||
return "", ""
|
||||
}
|
||||
slices.Sort(unpinned)
|
||||
bound := b.packageWait()
|
||||
wait, stop := context.WithTimeout(ctx, bound) // a context's bound, no timer (ADR 0437 §8)
|
||||
defer stop()
|
||||
pins := map[string]string{}
|
||||
told := false
|
||||
for {
|
||||
b.mu.Lock()
|
||||
moved := b.moved
|
||||
b.mu.Unlock()
|
||||
missing := ""
|
||||
for _, p := range unpinned {
|
||||
if pins[p] == "" {
|
||||
pins[p] = b.releaseOf(ctx, p)
|
||||
}
|
||||
if pins[p] == "" && missing == "" {
|
||||
missing = p
|
||||
}
|
||||
}
|
||||
if missing == "" {
|
||||
packages := maps.Clone(entry.Packages)
|
||||
maps.Copy(packages, pins)
|
||||
entry.Packages = packages
|
||||
if told {
|
||||
b.logf("%s at %s: every package it names has a released version: built with %v", entry.Module, entry.Fp, pins)
|
||||
}
|
||||
return "", ""
|
||||
}
|
||||
notReleased := fmt.Sprintf("package %s has no released version", missing)
|
||||
if !told {
|
||||
b.logf("%s at %s: %s yet: the ask waits for its release, at most %s", entry.Module, entry.Fp, notReleased, bound)
|
||||
told = true
|
||||
}
|
||||
select {
|
||||
case <-moved:
|
||||
case <-wait.Done():
|
||||
if ctx.Err() != nil {
|
||||
return meshbuilds.StepEndedOutcomeCouldNotRun, notReleased + ": the builder stopped before it was"
|
||||
}
|
||||
b.logf("%s at %s: %s within %s: the step fails, nothing is built", entry.Module, entry.Fp, notReleased, bound)
|
||||
return meshbuilds.StepEndedOutcomeFailed, fmt.Sprintf("%s within %s", notReleased, bound)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -103,10 +103,21 @@ type Builder struct {
|
||||
Now func() time.Time
|
||||
Node string
|
||||
// Numbers numbers each trunk build at its claim and records what it was built with (design 51 *The versions*); nil
|
||||
// numbers nothing.
|
||||
// numbers nothing, as the builder's program leaves it (design 47 H H-A-159: the reservation numbers, G §369).
|
||||
Numbers Numbers
|
||||
// Reserved reserves the version of a trunk build at its start (design 47 G §369); nil reserves nothing.
|
||||
Reserved Reservations
|
||||
// Picture answers the source revision the builder's picture of a watched branch holds, false while it holds none (design 47
|
||||
// H H-A-155, H-A-141): a step ask naming a newer one waits for it. Nil waits for nothing.
|
||||
Picture func(branch string) (source int64, held bool)
|
||||
// RevisionWait bounds a step ask's wait for its revision, its setting revision-wait-minutes (H-A-156); DefaultRevisionWait
|
||||
// when 0.
|
||||
RevisionWait time.Duration
|
||||
// PackageWait bounds a step ask's wait for the release of a package its entry names with no pin, its setting
|
||||
// package-wait-minutes (H-A-165); DefaultPackageWait when 0. NewestReleased reads the newest version the builder's
|
||||
// record of releases keeps for a module; nil reads none, and only a release heard (VersionReleased) gives a pin.
|
||||
PackageWait time.Duration
|
||||
NewestReleased func(ctx context.Context, module string) (version string, found bool, err error)
|
||||
// Forms answers what each node's engine states it reads (ADR 0618 §2, ADR 0624 §1): present, the nodes whose engine
|
||||
// answered when last asked, and counted, every node the assignments names, present or away, a node with no statement
|
||||
// stating nothing (the baseline's first forms). A done key names each artifact in the forms these keep, the oldest in
|
||||
@@ -149,6 +160,10 @@ type Builder struct {
|
||||
// builds are the ends that withdraw the asks of a key's build in flight, by build key (ADR 0664 §4): a newer fingerprint of
|
||||
// the module takes its older one's build out, and the asker drops that build's asks.
|
||||
builds map[string]context.CancelCauseFunc
|
||||
// moved is closed and made again at each entry the picture takes in or drops: the step asks waiting for a revision wake.
|
||||
moved chan struct{}
|
||||
// releases are the versions heard released, by module (VersionReleased): a package with no pin waits for one.
|
||||
releases map[string]string
|
||||
}
|
||||
|
||||
type planned struct {
|
||||
@@ -178,6 +193,8 @@ func (b *Builder) init() {
|
||||
b.published, b.held, b.waiting = map[string]bool{}, map[string]bool{}, map[string]map[string]chan string{}
|
||||
b.hands, b.events = map[string]*handWatch{}, map[string]bool{}
|
||||
b.builds = map[string]context.CancelCauseFunc{}
|
||||
b.moved = make(chan struct{})
|
||||
b.releases = map[string]string{}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -230,6 +247,7 @@ func (b *Builder) EntryGone(branch string, first bool, module string) {
|
||||
b.mu.Lock()
|
||||
delete(b.heard, branch+"\x00"+module)
|
||||
b.mu.Unlock()
|
||||
b.pictureMoved()
|
||||
if first {
|
||||
b.Forget(module)
|
||||
}
|
||||
@@ -256,6 +274,7 @@ func (b *Builder) take(ctx context.Context, o Origin, key string, m meshcatalog.
|
||||
b.edges[bk] = e
|
||||
}
|
||||
b.mu.Unlock()
|
||||
b.pictureMoved()
|
||||
if superseded != nil {
|
||||
// A newer fingerprint of the module: the build of the older one in flight is taken out, and its asks are withdrawn
|
||||
// from the build seats (ADR 0664 §4).
|
||||
|
||||
@@ -34,6 +34,10 @@ func (b *Builder) BuildStep(ctx context.Context, run meshbuilds.StepRun) meshbui
|
||||
if b.StepEntry == nil {
|
||||
return finish(meshbuilds.StepEndedOutcomeCouldNotRun, "the builder reads no entry of the seat mesh-catalog")
|
||||
}
|
||||
// The version is reserved before the build (H-A-155): the ask waits for the builder's picture to hold its revision.
|
||||
if outcome, said := b.awaitRevision(ctx, run); outcome != "" {
|
||||
return finish(outcome, said)
|
||||
}
|
||||
var failed []string
|
||||
for _, e := range run.Entries {
|
||||
outcome, said := b.buildEntry(ctx, e)
|
||||
@@ -59,6 +63,10 @@ func (b *Builder) buildEntry(ctx context.Context, e meshbuilds.BuildEntry) (outc
|
||||
if entry.Module != e.Module || (e.Commit != "" && entry.Commit != e.Commit) {
|
||||
return meshbuilds.StepEndedOutcomeCouldNotRun, fmt.Sprintf("the entry of %s at %s is of %s at %s", e.Module, e.Fingerprint, entry.Module, entry.Commit)
|
||||
}
|
||||
// A package the entry names with no pin is built against its release, waited for (H-A-165).
|
||||
if outcome, said := b.awaitPins(ctx, &entry); outcome != "" {
|
||||
return outcome, said
|
||||
}
|
||||
key, err := builds.BuilderBuildKey(entry.Module, entry.Fp)
|
||||
if err != nil {
|
||||
return meshbuilds.StepEndedOutcomeCouldNotRun, err.Error()
|
||||
|
||||
@@ -3,13 +3,17 @@ package build
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"reflect"
|
||||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds"
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshbuilds"
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep"
|
||||
"git.novox.be/novox/mesh-sdk/go/catalogue"
|
||||
|
||||
"mesh-delivery-builder/internal/versions"
|
||||
@@ -112,6 +116,184 @@ func TestABuildStepPassesAReservingBuildOnlyWithItsReservedVersion(t *testing.T)
|
||||
}
|
||||
})
|
||||
}
|
||||
t.Run("H-A-155: an ask waits for the picture to take its revision in, then builds with its version reserved", aStepAskWaitsForItsRevision)
|
||||
t.Run("H-A-155: past the bound the ask fails naming its revision, and nothing is built", aStepAskPastItsRevisionBoundFails)
|
||||
t.Run("H-A-162: a revision held that changes no entry wakes the ask", aRevisionHeldWakesTheAsk)
|
||||
t.Run("H-A-165: a package with no pin waits for its release and is built with it", aPackageWithNoPinWaitsForItsRelease)
|
||||
t.Run("H-A-165: past its bound a package with no release fails the step", aPackageWithNoReleaseFailsPastItsBound)
|
||||
}
|
||||
|
||||
// unpinnedRig is a rig whose step entry m names the package x with no version, built by the module contracts.
|
||||
func unpinnedRig(t *testing.T) (*rig, *fakeReservations) {
|
||||
var held atomic.Int64
|
||||
r, res, entry := revisionRig(t, &held, make(chan struct{}, 1))
|
||||
r.b.Picture = nil // no revision to wait for here
|
||||
entry.Packages = map[string]string{"git.novox.be/novox/mesh-contracts/go/seats/x": "", "git.novox.be/novox/mesh-sdk/go": "v0.1.20"}
|
||||
r.b.StepEntry = func(context.Context, string) (meshcatalog.CatalogEntry, error) { return entry, nil }
|
||||
r.b.Members = func(_ context.Context, pkg string) (string, string, bool, error) {
|
||||
return "contracts", "contracts:x", pkg == "git.novox.be/novox/mesh-contracts/go/seats/x", nil
|
||||
}
|
||||
return r, res
|
||||
}
|
||||
|
||||
func aPackageWithNoPinWaitsForItsRelease(t *testing.T) {
|
||||
r, _ := unpinnedRig(t)
|
||||
var once sync.Once
|
||||
looked := make(chan struct{})
|
||||
r.b.NewestReleased = func(context.Context, string) (string, bool, error) { // the record holds none yet
|
||||
once.Do(func() { close(looked) })
|
||||
return "", false, nil
|
||||
}
|
||||
ended := make(chan meshbuilds.StepEnded, 1)
|
||||
go func() {
|
||||
ended <- r.b.BuildStep(t.Context(), meshbuilds.StepRun{Pipeline: "main.9.m", Step: meshbuilds.StepRunStepBuild, Branch: "main", Source: 41,
|
||||
Entries: []meshbuilds.BuildEntry{{Module: "m", Fingerprint: fp1}}})
|
||||
}()
|
||||
select {
|
||||
case <-looked:
|
||||
case end := <-ended:
|
||||
t.Fatalf("the ask ended before the package was released: %+v, asks %+v", end, r.asks.Asks())
|
||||
case <-time.After(5 * time.Second):
|
||||
t.Fatal("the ask never looked for the package's release")
|
||||
}
|
||||
if _, ok := r.st.vals[r.key]; ok {
|
||||
t.Fatal("the build was made before the package had a release")
|
||||
}
|
||||
r.b.VersionReleased("contracts", "0.1.3")
|
||||
var end meshbuilds.StepEnded
|
||||
select {
|
||||
case end = <-ended:
|
||||
case <-time.After(5 * time.Second):
|
||||
t.Fatal("the release did not wake the ask")
|
||||
}
|
||||
r.b.Wait()
|
||||
asks := r.asks.Asks()
|
||||
if end.Outcome != meshbuilds.StepEndedOutcomePassed || len(asks) == 0 ||
|
||||
!reflect.DeepEqual(asks[0].Packages, buildstep.PackageVersions{"git.novox.be/novox/mesh-contracts/go/seats/x": "v0.1.3", "git.novox.be/novox/mesh-sdk/go": "v0.1.20"}) {
|
||||
t.Errorf("end = %+v, asks %+v; want passed, built with x at v0.1.3", end, asks)
|
||||
}
|
||||
}
|
||||
|
||||
func aPackageWithNoReleaseFailsPastItsBound(t *testing.T) {
|
||||
r, _ := unpinnedRig(t)
|
||||
r.b.PackageWait = time.Nanosecond
|
||||
end := r.b.BuildStep(t.Context(), meshbuilds.StepRun{Pipeline: "main.9.m", Step: meshbuilds.StepRunStepBuild, Branch: "main", Source: 41,
|
||||
Entries: []meshbuilds.BuildEntry{{Module: "m", Fingerprint: fp1}}})
|
||||
r.b.Wait()
|
||||
if _, built := r.st.vals[r.key]; end.Outcome != meshbuilds.StepEndedOutcomeFailed || built ||
|
||||
!strings.Contains(end.Said, "package git.novox.be/novox/mesh-contracts/go/seats/x has no released version") {
|
||||
t.Errorf("end = %+v, built %v; want failed naming the package, nothing built", end, built)
|
||||
}
|
||||
// A release the builder's own record keeps gives the pin at once.
|
||||
r.b.NewestReleased = func(_ context.Context, module string) (string, bool, error) {
|
||||
return "0.1.2", module == "contracts", nil
|
||||
}
|
||||
if end := r.b.BuildStep(t.Context(), meshbuilds.StepRun{Pipeline: "main.9.m", Step: meshbuilds.StepRunStepBuild, Branch: "main", Source: 41,
|
||||
Entries: []meshbuilds.BuildEntry{{Module: "m", Fingerprint: fp1}}}); strings.Contains(end.Said, "no released version") {
|
||||
t.Errorf("a release the record keeps did not pin the package: %+v", end)
|
||||
}
|
||||
}
|
||||
|
||||
func aRevisionHeldWakesTheAsk(t *testing.T) {
|
||||
var held atomic.Int64
|
||||
held.Store(40)
|
||||
asked := make(chan struct{}, 1)
|
||||
r, res, entry := revisionRig(t, &held, asked)
|
||||
r.b.Entry(context.Background(), Origin{Branch: "main", Source: 40, First: true}, entry) // the entry, unchanged since 40
|
||||
r.b.Wait()
|
||||
ended := make(chan meshbuilds.StepEnded, 1)
|
||||
go func() {
|
||||
ended <- r.b.BuildStep(t.Context(), meshbuilds.StepRun{Pipeline: "main.8.m", Step: meshbuilds.StepRunStepBuild, Branch: "main", Revision: 8, Source: 41,
|
||||
Entries: []meshbuilds.BuildEntry{{Module: "m", Fingerprint: fp1}}})
|
||||
}()
|
||||
select {
|
||||
case <-asked:
|
||||
case end := <-ended:
|
||||
t.Fatalf("the ask ended before the picture held its revision: %+v", end)
|
||||
case <-time.After(5 * time.Second):
|
||||
t.Fatal("the ask never read the builder's picture")
|
||||
}
|
||||
held.Store(41)
|
||||
r.b.PictureHeld() // revision 8, from source 41, changes no entry
|
||||
select {
|
||||
case end := <-ended:
|
||||
if end.Outcome != meshbuilds.StepEndedOutcomePassed || len(res.sources) != 1 {
|
||||
t.Errorf("end = %+v, reserved from %+v; want passed with its version reserved", end, res.sources)
|
||||
}
|
||||
case <-time.After(5 * time.Second):
|
||||
t.Fatal("a revision held did not wake the ask")
|
||||
}
|
||||
}
|
||||
|
||||
// revisionRig is a rig whose builder reserves, its step entry m at fp1, its picture of main holding the source revision held.
|
||||
func revisionRig(t *testing.T, held *atomic.Int64, asked chan struct{}) (*rig, *fakeReservations, meshcatalog.CatalogEntry) {
|
||||
r := newRig(t, goBundle)
|
||||
r.mf.byDigest[mdigest('a')] = catalogue.Manifest{Module: "m", Version: "0.1", Build: &catalogue.Build{Artifacts: []catalogue.Artifact{goBundle}}}
|
||||
res := &fakeReservations{filled: true}
|
||||
r.b.Reserved = res
|
||||
entry := meshcatalog.CatalogEntry{Module: "m", Repository: "novox/mesh-catalog", Path: "modules/m", Commit: "7a74cee83f88e6585a5511c3cc53bdf0f5303d20", Fp: fp1,
|
||||
ManifestDigest: mdigest('a'), Inputs: &meshcatalog.EntryInputs{Toolchains: CatalogToolchains(agreedToolchains)}}
|
||||
r.b.StepEntry = func(context.Context, string) (meshcatalog.CatalogEntry, error) { return entry, nil }
|
||||
r.b.Picture = func(branch string) (int64, bool) {
|
||||
select {
|
||||
case asked <- struct{}{}:
|
||||
default:
|
||||
}
|
||||
return held.Load(), branch == "main" && held.Load() > 0
|
||||
}
|
||||
return r, res, entry
|
||||
}
|
||||
|
||||
func aStepAskWaitsForItsRevision(t *testing.T) {
|
||||
var held atomic.Int64
|
||||
held.Store(40)
|
||||
asked := make(chan struct{}, 1)
|
||||
r, res, entry := revisionRig(t, &held, asked)
|
||||
ended := make(chan meshbuilds.StepEnded, 1)
|
||||
go func() {
|
||||
ended <- r.b.BuildStep(t.Context(), meshbuilds.StepRun{Pipeline: "main.7.m", Step: meshbuilds.StepRunStepBuild, Branch: "main", Revision: 7, Source: 41,
|
||||
Entries: []meshbuilds.BuildEntry{{Module: "m", Fingerprint: fp1}}})
|
||||
}()
|
||||
select {
|
||||
case <-asked: // the ask read the picture, which holds source revision 40
|
||||
case end := <-ended:
|
||||
t.Fatalf("the ask ended before the picture held its revision: %+v, reserved from %+v", end, res.sources)
|
||||
case <-time.After(5 * time.Second):
|
||||
t.Fatal("the ask never read the builder's picture")
|
||||
}
|
||||
if _, ok := r.st.vals[r.key]; ok {
|
||||
t.Fatal("the ask built before the picture held its revision")
|
||||
}
|
||||
held.Store(41)
|
||||
r.b.Entry(context.Background(), Origin{Branch: "main", Source: 41, First: true}, entry) // the picture takes revision 41 in
|
||||
var end meshbuilds.StepEnded
|
||||
select {
|
||||
case end = <-ended:
|
||||
case <-time.After(5 * time.Second):
|
||||
t.Fatal("the ask was not woken by the entry the picture took in")
|
||||
}
|
||||
r.b.Wait()
|
||||
if end.Outcome != meshbuilds.StepEndedOutcomePassed || len(res.sources) != 1 || res.sources[0].Revision != 41 {
|
||||
t.Errorf("end = %+v, reserved from %+v; want passed with one version reserved from revision 41", end, res.sources)
|
||||
}
|
||||
}
|
||||
|
||||
func aStepAskPastItsRevisionBoundFails(t *testing.T) {
|
||||
var held atomic.Int64
|
||||
held.Store(40)
|
||||
r, res, _ := revisionRig(t, &held, make(chan struct{}, 1))
|
||||
r.b.RevisionWait = time.Nanosecond
|
||||
end := r.b.BuildStep(t.Context(), meshbuilds.StepRun{Pipeline: "main.7.m", Step: meshbuilds.StepRunStepBuild, Branch: "main", Revision: 7, Source: 41,
|
||||
Entries: []meshbuilds.BuildEntry{{Module: "m", Fingerprint: fp1}}})
|
||||
r.b.Wait()
|
||||
if _, built := r.st.vals[r.key]; end.Outcome != meshbuilds.StepEndedOutcomeFailed || !strings.Contains(end.Said, "revision 41 of main not in the builder's picture") || built || len(res.sources) != 0 {
|
||||
t.Errorf("end = %+v, built %v, reserved %+v; want failed naming revision 41 of main, nothing built", end, built, res.sources)
|
||||
}
|
||||
// A step ask with no source (a run on request) does not wait (H-A-156).
|
||||
end = r.b.BuildStep(t.Context(), meshbuilds.StepRun{Pipeline: "run.1.m", Step: meshbuilds.StepRunStepBuild, Branch: "main", Entries: []meshbuilds.BuildEntry{{Module: "m", Fingerprint: fp1}}})
|
||||
if strings.Contains(end.Said, "not in the builder's picture") {
|
||||
t.Errorf("an ask with no source waited: %+v", end)
|
||||
}
|
||||
}
|
||||
|
||||
// digestOf is the manifest digest a step's entry names: the rig's manifest, or one no store holds, whose plan cannot be read.
|
||||
|
||||
@@ -3,16 +3,14 @@ package versions
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// The tools' descriptions.
|
||||
const (
|
||||
FloorAgainDescription = "Ask the floor of one name again now, by hand (design 51 *The floor*): the seat's versions, the seat git's " +
|
||||
"git.tags and the indexer's indexer_requirements, as the builder asks them by itself when a silent source says something. " +
|
||||
"Answers which sources were silent and whether the floor is now known. A name the builder's versions already hold needs no floor: " +
|
||||
"refused, saying so. A hand act."
|
||||
FloorAgainDescription = "Refused for every name: the builder numbers nothing of its own and asks no floor (design 47 H H-A-159); " +
|
||||
"a version is numbered by the reservation (design 47 G §369, builder_reserved). Kept until design 47 G §372 removes it with " +
|
||||
"the state versions."
|
||||
)
|
||||
|
||||
// Acts are the builder's hand acts on its versions, answered by its program (the tools bundle writes them to reasks).
|
||||
@@ -31,24 +29,9 @@ type Acts struct {
|
||||
DropReserved func(ctx context.Context, module, series, by, why string, at time.Time) (string, error)
|
||||
}
|
||||
|
||||
// FloorAgain is builder_floor_again of name: the floor counts only for a name the versions hold nothing of.
|
||||
func (a Acts) FloorAgain(ctx context.Context, name string) (string, error) {
|
||||
entries, err := a.Numberer.Versions.Of(ctx, name)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if len(entries) > 0 {
|
||||
return "", fmt.Errorf("%s holds %d versions: its floor counts only for its first number, so nothing is asked", name, len(entries))
|
||||
}
|
||||
answer := name + " waits on no floor in this builder: the floor is asked at its next claim"
|
||||
if a.Numberer.Waits != nil {
|
||||
for _, w := range a.Numberer.Waits.Waiting() {
|
||||
if w.Name == name {
|
||||
answer = fmt.Sprintf("the floor of %s is asked again (%s were silent)", name, strings.Join(w.Silent, ", "))
|
||||
}
|
||||
}
|
||||
a.Numberer.Waits.Wake(WakeByHand, "", "", name)
|
||||
}
|
||||
a.Reconsider(ctx)
|
||||
return answer + "; builder_versions shows its version once numbered", nil
|
||||
// FloorAgain is builder_floor_again of name: refused, since the builder numbers nothing of its own and no claim asks a floor
|
||||
// (design 47 H H-A-159; the reservation numbers, G §369). The tool stays until G §372 removes it with the state versions.
|
||||
func (a Acts) FloorAgain(_ context.Context, name string) (string, error) {
|
||||
return "", fmt.Errorf("the floor of %s is not asked: the builder numbers nothing of its own and asks no floor (design 47 H H-A-159); "+
|
||||
"a version is numbered by the reservation (G §369, builder_reserved)", name)
|
||||
}
|
||||
|
||||
@@ -43,6 +43,11 @@ func (n *Numberer) Heard(ctx context.Context, seat, event, id string, o Outcome)
|
||||
var change func(*Entry)
|
||||
switch event {
|
||||
case HeardPublished:
|
||||
// A published of other bytes than an entry records under its number is no publish of that entry: the reservation
|
||||
// numbered it and takes it in (design 47 H H-A-159, G §369, A-415; ADR 0605 §4), and the entry stays as it is.
|
||||
if e, ok, _, err := n.Versions.Recorded(ctx, o.Name, o.Version, o.Digest); err == nil && !ok && e.Digest != "" && o.Digest != "" && e.Digest != o.Digest {
|
||||
return wake, fmt.Errorf("%s@%s is recorded with digest %s, so %s's published of %s is %w", o.Name, o.Version, e.Digest, seat, o.Digest, ErrNotNumbered)
|
||||
}
|
||||
change = func(e *Entry) {
|
||||
e.State, e.Reason = Published, ""
|
||||
if e.Digest == "" {
|
||||
|
||||
@@ -295,6 +295,23 @@ func (r *Reserver) ReleasedFor(ctx context.Context, module, fingerprint string)
|
||||
return false, nil
|
||||
}
|
||||
|
||||
// NewestReleased is the newest version the builder's own record of releases keeps for module (design 47 H H-A-165): a
|
||||
// package with no pin is built against it; false when the record holds none.
|
||||
func (r *Reserver) NewestReleased(ctx context.Context, module string) (string, bool, error) {
|
||||
if r.Releases == nil {
|
||||
return "", false, nil
|
||||
}
|
||||
raw, _, found, err := r.Releases.Get(ctx, ReleasedKey(module))
|
||||
if err != nil || !found {
|
||||
return "", false, err
|
||||
}
|
||||
var rec ReleasedRecord
|
||||
if json.Unmarshal(raw, &rec) != nil || len(rec.Kept) == 0 {
|
||||
return "", false, nil
|
||||
}
|
||||
return rec.Kept[len(rec.Kept)-1].Version, true, nil
|
||||
}
|
||||
|
||||
// keepRelease adds a release to the module's record, dropping the oldest past ReleasedKept.
|
||||
func (r *Reserver) keepRelease(ctx context.Context, module, fingerprint, version string) error {
|
||||
n := r.ReleasedKept
|
||||
|
||||
@@ -201,11 +201,13 @@ func TestAReleaseIsRecordedByFingerprintBeforeItsReservationGoes(t *testing.T) {
|
||||
t.Errorf("reservations left: %v", all)
|
||||
}
|
||||
// One key per module holds the last releases, the oldest dropped (A-456b).
|
||||
newest := ""
|
||||
for _, fp := range []string{"src2:b1", "src2:b2"} {
|
||||
n, err := r.Reserve(ctx, "m", "0.1", []string{"m:a"}, Source{Fingerprint: fp})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
newest = n.Version
|
||||
if _, err := r.Released(ctx, "m", n.Version); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -219,6 +221,13 @@ func TestAReleaseIsRecordedByFingerprintBeforeItsReservationGoes(t *testing.T) {
|
||||
if ok, _ := r.ReleasedFor(ctx, "m", "src2:b2"); !ok {
|
||||
t.Error("the newest release is not kept")
|
||||
}
|
||||
// H-A-165: the newest version the record keeps is the pin of a package with none.
|
||||
if v, ok, err := r.NewestReleased(ctx, "m"); !ok || err != nil || v != newest {
|
||||
t.Errorf("newest released of m = %q, %v (%v), want %s", v, ok, err, newest)
|
||||
}
|
||||
if _, ok, _ := r.NewestReleased(ctx, "other"); ok {
|
||||
t.Error("a module never released has a newest release")
|
||||
}
|
||||
}
|
||||
|
||||
// TestARebuildReservesAboveTheCatalogsHighestWhateverItsStandingNumberWas: design 47 G A-490b — a build again of a done key replaces
|
||||
|
||||
@@ -440,6 +440,13 @@ func TestTheBuildersVersions(t *testing.T) {
|
||||
if wake, _ := n.Heard(ctx, SeatGoPackages, HeardPublished, "e2", Outcome{Name: "m/x", Digest: "sha256:dd"}); !reflect.DeepEqual(wake, []string{"m/lib"}) {
|
||||
t.Fatalf("a published on the Go seat woke %v, want m/lib, whose seat was silent", wake)
|
||||
}
|
||||
// Design 47 G §369, A-415; ADR 0605 §4: a published of other bytes under the number is the reservation's, never this entry's.
|
||||
if _, err := n.Heard(ctx, SeatArtifacts, HeardPublished, "e5", Outcome{Name: "m/program", Version: "0.1.14", Digest: "sha256:new"}); !errors.Is(err, ErrNotNumbered) {
|
||||
t.Fatalf("a published of other bytes under 0.1.14: %v, want ErrNotNumbered", err)
|
||||
}
|
||||
if all, _ := n.Versions.Of(ctx, "m/program"); all[0].State != Numbered || all[0].Digest != "sha256:aa" {
|
||||
t.Fatalf("after a published of other bytes: %+v, want it numbered with sha256:aa", all[0])
|
||||
}
|
||||
for _, h := range []struct{ event, state, reason string }{{HeardRefused, Refused, "bytes differ"}, {HeardPublished, Published, ""}, {HeardRefused, Published, ""}, {HeardRemoved, Removed, "retention"}} {
|
||||
if _, err := n.Heard(ctx, SeatArtifacts, h.event, "e3", Outcome{Name: "m/program", Version: "0.1.14", Digest: "sha256:aa", Reason: h.reason}); err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -581,11 +588,13 @@ func TestTheBuildersVersions(t *testing.T) {
|
||||
}
|
||||
_, _ = v.Mark(ctx, "m/p", "0.1.4", func(e *Entry) { e.State = Published })
|
||||
acts := Acts{Numberer: &Numberer{Versions: v, Waits: &FloorWaits{}}, Reconsider: func(context.Context) {}}
|
||||
if _, err := acts.FloorAgain(ctx, "m/p"); err == nil {
|
||||
t.Error("a name with versions asks its floor again")
|
||||
}
|
||||
if ans, err := acts.FloorAgain(ctx, "m/new"); err != nil || ans == "" {
|
||||
t.Errorf("floor again of a new name: %q %v", ans, err)
|
||||
reconsidered := false
|
||||
acts.Reconsider = func(context.Context) { reconsidered = true }
|
||||
// H-A-159: the builder numbers nothing of its own, so no claim asks a floor: the tool refuses, saying so, and does nothing.
|
||||
for _, name := range []string{"m/p", "m/new"} {
|
||||
if ans, err := acts.FloorAgain(ctx, name); err == nil || !strings.Contains(err.Error(), "numbers nothing of its own") || reconsidered {
|
||||
t.Errorf("floor again of %s: %q %v, looked again %v; want refused naming H-A-159, nothing looked at", name, ans, err, reconsidered)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -186,9 +186,9 @@ func TestManifestDeclarations(t *testing.T) { // 1607/AC1
|
||||
m.Streams[2].Name != "mesh-delivery-builder-findings" || !reflect.DeepEqual(m.Streams[2].Events, []string{"finding-written.*", "finding-cleared.*", "findings-stated.*"}) {
|
||||
t.Errorf("streams = %+v, want waits with wait-held.** and wait-ended.**, 7 days, 16 MiB, the builds' stream (build.ended.**, 7 days, kept last per subject: design 47 G A-181) and the findings' stream", m.Streams)
|
||||
}
|
||||
if c, ok := m.Config["toolchain-wait-minutes"]; !ok || c.Default != float64(60) || len(m.Config) != 5 ||
|
||||
if c, ok := m.Config["toolchain-wait-minutes"]; !ok || c.Default != float64(60) || len(m.Config) != 7 || m.Config["revision-wait-minutes"].Default != float64(2) || m.Config["package-wait-minutes"].Default != float64(10) ||
|
||||
m.Config["publish-pause"].Default != float64(30) || m.Config["publish-pause-max"].Default != float64(30) || m.Config["publish-tries"].Default != float64(8) {
|
||||
t.Errorf("config = %+v, want toolchain-wait-minutes of 60, the publish settings 30 s, 30 min and 8 tries (design 47 G §588, §633, A-457a)", m.Config)
|
||||
t.Errorf("config = %+v, want toolchain-wait-minutes of 60, revision-wait-minutes of 2 (H-A-156), package-wait-minutes of 10 (H-A-165), the publish settings 30 s, 30 min and 8 tries (design 47 G §588, §633, A-457a)", m.Config)
|
||||
}
|
||||
// Design 47 G §349: version.numbered is no longer said; old-form-closed on the family version, apart from the builds' ends.
|
||||
if want := []string{"build.asked-again", "version.old-form-closed"}; !reflect.DeepEqual(m.Emits, want) {
|
||||
@@ -241,7 +241,7 @@ func TestManifestProcess(t *testing.T) { // 1607/AC1
|
||||
t.Errorf("process = %v", p)
|
||||
}
|
||||
env, _ := p["env"].(map[string]any)
|
||||
if len(env) != 6 || env["MESH_BUILDER_PUBLISH_TRIES_FILE"] != "${dir:state}/publish-tries" || env["MESH_BROKER_FILE"] != "${dir:state}/broker" || env["MESH_BUILDER_TOOLCHAIN_WAIT_FILE"] != "${dir:state}/toolchain-wait-minutes" {
|
||||
if len(env) != 8 || env["MESH_BUILDER_REVISION_WAIT_FILE"] != "${dir:state}/revision-wait-minutes" || env["MESH_BUILDER_PACKAGE_WAIT_FILE"] != "${dir:state}/package-wait-minutes" || env["MESH_BUILDER_PUBLISH_TRIES_FILE"] != "${dir:state}/publish-tries" || env["MESH_BROKER_FILE"] != "${dir:state}/broker" || env["MESH_BUILDER_TOOLCHAIN_WAIT_FILE"] != "${dir:state}/toolchain-wait-minutes" {
|
||||
t.Errorf("env = %v, want the broker file and the path of the toolchain wait's file, never the setting itself (design 47 G §672, A-71)", p["env"])
|
||||
}
|
||||
for k, v := range env {
|
||||
|
||||
@@ -147,6 +147,22 @@
|
||||
"trusted": false,
|
||||
"default": 60
|
||||
},
|
||||
"revision-wait-minutes": {
|
||||
"type": "number",
|
||||
"description": "minutes a build step ask waits for the builder's picture of its branch to hold its source revision before it fails, building nothing (design 47 H H-A-155, H-A-156).",
|
||||
"minimum": 1,
|
||||
"maximum": 60,
|
||||
"trusted": false,
|
||||
"default": 2
|
||||
},
|
||||
"package-wait-minutes": {
|
||||
"type": "number",
|
||||
"description": "minutes a build step ask waits for the release of a mesh package its entry names with no pin before it fails, building nothing (design 47 H H-A-165).",
|
||||
"minimum": 1,
|
||||
"maximum": 120,
|
||||
"trusted": false,
|
||||
"default": 10
|
||||
},
|
||||
"publish-pause": {
|
||||
"type": "number",
|
||||
"description": "seconds before a version's second publish try, doubled per try up to publish-pause-max (design 47 G A-457a).",
|
||||
@@ -223,6 +239,22 @@
|
||||
"mode": "0600",
|
||||
"content": "${config:toolchain-wait-minutes}"
|
||||
},
|
||||
{
|
||||
"id": "revision-wait",
|
||||
"type": "file",
|
||||
"path": "${dir:state}/revision-wait-minutes",
|
||||
"owner": "mesh-delivery-builder",
|
||||
"mode": "0600",
|
||||
"content": "${config:revision-wait-minutes}"
|
||||
},
|
||||
{
|
||||
"id": "package-wait",
|
||||
"type": "file",
|
||||
"path": "${dir:state}/package-wait-minutes",
|
||||
"owner": "mesh-delivery-builder",
|
||||
"mode": "0600",
|
||||
"content": "${config:package-wait-minutes}"
|
||||
},
|
||||
{
|
||||
"id": "publish-pause",
|
||||
"type": "file",
|
||||
@@ -269,6 +301,8 @@
|
||||
"env": {
|
||||
"MESH_BROKER_FILE": "${dir:state}/broker",
|
||||
"MESH_BUILDER_TOOLCHAIN_WAIT_FILE": "${dir:state}/toolchain-wait-minutes",
|
||||
"MESH_BUILDER_REVISION_WAIT_FILE": "${dir:state}/revision-wait-minutes",
|
||||
"MESH_BUILDER_PACKAGE_WAIT_FILE": "${dir:state}/package-wait-minutes",
|
||||
"MESH_BUILDER_PUBLISH_PAUSE_FILE": "${dir:state}/publish-pause",
|
||||
"MESH_BUILDER_PUBLISH_PAUSE_MAX_FILE": "${dir:state}/publish-pause-max",
|
||||
"MESH_BUILDER_PUBLISH_TRIES_FILE": "${dir:state}/publish-tries",
|
||||
|
||||
@@ -74,6 +74,8 @@ type Branches struct {
|
||||
holders atomic.Pointer[seatHolders]
|
||||
// Changed, when not nil, is told of each change to a branch's view (module, its entry, deleted), set before Wire.
|
||||
Changed func(branch, module string, entry json.RawMessage, deleted bool, at time.Time)
|
||||
// Held, when not nil, is told of each revision a branch's view takes in whole (Catalog.Held; H-A-162), set before Wire.
|
||||
Held func(branch string, revision seat.CatalogRevision)
|
||||
// Adopted, when not nil, is told on a goroutine of its own of each branch whose view was adopted, with that view (a part that waits for
|
||||
// its first branch's first view, design 47 G §507), set before Wire.
|
||||
Adopted func(branch string, c *Catalog)
|
||||
@@ -253,6 +255,11 @@ func (b *Branches) reconcile() {
|
||||
b.Changed(branch, module, entry, deleted, at)
|
||||
}
|
||||
}
|
||||
c.Held = func(r seat.CatalogRevision) {
|
||||
if b.Held != nil {
|
||||
b.Held(branch, r)
|
||||
}
|
||||
}
|
||||
// A catalog-revision also asks again each entry whose ask failed in transport (design 47 H, H-A-60).
|
||||
hear := func(ctx context.Context, data []byte) error {
|
||||
err := c.Hear(ctx, data)
|
||||
|
||||
@@ -59,6 +59,9 @@ type Catalog struct {
|
||||
waits int64
|
||||
// made is when the view's numbering last started again (H-A-141), the follower's Created; zero is catalogCreated.
|
||||
made time.Time
|
||||
// Held, when not nil, is told each revision the view takes in whole, once it holds it, whether or not an entry
|
||||
// changed (design 47 H H-A-162): a part waiting for a revision wakes on it. Set before Start.
|
||||
Held func(seat.CatalogRevision)
|
||||
}
|
||||
|
||||
// created is madeLocked, taking mu.
|
||||
@@ -232,7 +235,9 @@ func (c *Catalog) ask(_ context.Context, after string) (views.Answer, error) {
|
||||
}
|
||||
rev := a.Revision.Revision
|
||||
holds := false
|
||||
if a.Next == "" {
|
||||
whole := a.Next == ""
|
||||
held := *a.Revision
|
||||
if whole {
|
||||
c.held, c.paging = c.paging, nil
|
||||
if c.waits <= rev {
|
||||
c.waits, holds = 0, true
|
||||
@@ -242,6 +247,9 @@ func (c *Catalog) ask(_ context.Context, after string) (views.Answer, error) {
|
||||
if holds {
|
||||
c.Follower.Holds(ViewName(rev))
|
||||
}
|
||||
if whole && c.Held != nil {
|
||||
c.Held(held)
|
||||
}
|
||||
return views.Answer{V: 1, Owner: seat.Seat, State: c.Follower.State, Revision: uint64(rev), Created: c.created(), Values: values, Next: a.Next, At: time.Now()}, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"slices"
|
||||
"strings"
|
||||
"sync"
|
||||
"testing"
|
||||
@@ -83,6 +84,14 @@ func TestCatalogIsAViewPerWatchedBranch(t *testing.T) {
|
||||
c.Follower.Wait = time.Nanosecond
|
||||
c.Follower.Logf = logf
|
||||
}
|
||||
// H-A-162: each revision the view takes in whole is told to Held.
|
||||
var heldMu sync.Mutex
|
||||
var held []int64
|
||||
main.Held = func(r seat.CatalogRevision) {
|
||||
heldMu.Lock()
|
||||
defer heldMu.Unlock()
|
||||
held = append(held, r.Revision)
|
||||
}
|
||||
if main.Follower.State == rel.Follower.State || main.Follower.State != "catalog-revisions.main" || rel.Follower.State != views.BranchState(seat.StateCatalogRevisions, "release/1") {
|
||||
t.Fatalf("views are named %q and %q", main.Follower.State, rel.Follower.State)
|
||||
}
|
||||
@@ -116,17 +125,25 @@ func TestCatalogIsAViewPerWatchedBranch(t *testing.T) {
|
||||
}
|
||||
deadline := time.Now().Add(5 * time.Second)
|
||||
for {
|
||||
if h, _ := main.View(); h.Revision.Revision == 4 {
|
||||
heldMu.Lock()
|
||||
told := len(held)
|
||||
heldMu.Unlock()
|
||||
if h, _ := main.View(); h.Revision.Revision == 4 && told == 2 {
|
||||
break
|
||||
}
|
||||
if time.Now().After(deadline) {
|
||||
t.Fatal("main never held revision 4")
|
||||
t.Fatal("main never held revision 4, told to Held")
|
||||
}
|
||||
time.Sleep(time.Millisecond)
|
||||
}
|
||||
if n := f.asked("release/1"); n != 1 {
|
||||
t.Errorf("release/1 asked %d times after main's revision", n)
|
||||
}
|
||||
heldMu.Lock()
|
||||
if !slices.Equal(held, []int64{3, 4}) {
|
||||
t.Errorf("Held was told %v, want 3 then 4", held)
|
||||
}
|
||||
heldMu.Unlock()
|
||||
logMu.Lock()
|
||||
said := false
|
||||
for _, l := range logged {
|
||||
|
||||
@@ -711,6 +711,8 @@ type CatalogRevisionDefinitionsItem struct {
|
||||
type CatalogRevision struct {
|
||||
// when (RFC 3339 time)
|
||||
At *time.Time `json:"at,omitempty"`
|
||||
// the newest kept revision of its branch below it, which the take-in that wrote it pinned for its pipeline: the base of the validate step's case before (design 47 H-A-147, H-A-151, H-A-154); absent on the branch's first take-in
|
||||
Base int64 `json:"base,omitempty"`
|
||||
// the watched branch the revision is of
|
||||
Branch string `json:"branch,omitempty"`
|
||||
// the seat definitions it was judged with, each by its digest, read whole through seat-definitions
|
||||
|
||||
@@ -59,7 +59,7 @@ func TestFixtures(t *testing.T) {
|
||||
decode: func(b []byte) (any, error) { var v ModulesAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "the module verb (captured: xclip)", subject: "", given: "{\"module\":{\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"fp\":\"src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56\",\"manifest\":{\"build\":{\"artifacts\":[{\"binary\":\"xclip-tools\",\"from\":\"cmd/xclip-tools\",\"kind\":\"bundle\",\"language\":\"go\",\"loads\":[\"xclip-tools\"],\"name\":\"tools\",\"system\":\"arch\"}]},\"capabilities\":[\"package-manager\"],\"module\":\"xclip\",\"resources\":[{\"id\":\"package\",\"package\":\"xclip\",\"type\":\"package\"}],\"tools\":[\"xclip_copy\",\"xclip_paste\",\"xclip_targets\",\"xclip_session\"],\"version\":\"1\"},\"module\":\"xclip\",\"path\":\"modules/xclip\",\"repository\":\"novox/mesh-catalog\"}}", wire: "{\"module\":{\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"fp\":\"src2:b427bdde1f100e2f52490cfa9df0c5112dd3700226b4892349f0c14a15a4af56\",\"manifest\":{\"build\":{\"artifacts\":[{\"binary\":\"xclip-tools\",\"from\":\"cmd/xclip-tools\",\"kind\":\"bundle\",\"language\":\"go\",\"loads\":[\"xclip-tools\"],\"name\":\"tools\",\"system\":\"arch\"}]},\"capabilities\":[\"package-manager\"],\"module\":\"xclip\",\"resources\":[{\"id\":\"package\",\"package\":\"xclip\",\"type\":\"package\"}],\"tools\":[\"xclip_copy\",\"xclip_paste\",\"xclip_targets\",\"xclip_session\"],\"version\":\"1\"},\"module\":\"xclip\",\"path\":\"modules/xclip\",\"repository\":\"novox/mesh-catalog\"}}",
|
||||
decode: func(b []byte) (any, error) { var v ModuleAnswer; err := json.Unmarshal(b, &v); return v, err }, subjectIs: nil},
|
||||
{name: "a watched branch's catalog graph revision", subject: "", given: "{\"at\":\"2026-11-09T19:00:00Z\",\"branch\":\"main\",\"definitions\":[{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"seat\":\"node-build-go\"}],\"entries\":[{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"module\":\"mesh-build-go\"},{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"module\":\"xclip\"}],\"kind\":\"trunk\",\"movers\":[{\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"fingerprint\":\"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\",\"module\":\"xclip\",\"repository\":\"novox/mesh-catalog\"}],\"revision\":12,\"source\":3589,\"trunk\":[{\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"repository\":\"novox/mesh-catalog\"}],\"v\":1}", wire: "{\"at\":\"2026-11-09T19:00:00Z\",\"branch\":\"main\",\"definitions\":[{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"seat\":\"node-build-go\"}],\"entries\":[{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"module\":\"mesh-build-go\"},{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"module\":\"xclip\"}],\"kind\":\"trunk\",\"movers\":[{\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"fingerprint\":\"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\",\"module\":\"xclip\",\"repository\":\"novox/mesh-catalog\"}],\"revision\":12,\"source\":3589,\"trunk\":[{\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"repository\":\"novox/mesh-catalog\"}],\"v\":1}",
|
||||
{name: "a watched branch's catalog graph revision", subject: "", given: "{\"at\":\"2026-11-09T19:00:00Z\",\"base\":9,\"branch\":\"main\",\"definitions\":[{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"seat\":\"node-build-go\"}],\"entries\":[{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"module\":\"mesh-build-go\"},{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"module\":\"xclip\"}],\"kind\":\"trunk\",\"movers\":[{\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"fingerprint\":\"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\",\"module\":\"xclip\",\"repository\":\"novox/mesh-catalog\"}],\"revision\":12,\"source\":3589,\"trunk\":[{\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"repository\":\"novox/mesh-catalog\"}],\"v\":1}", wire: "{\"at\":\"2026-11-09T19:00:00Z\",\"base\":9,\"branch\":\"main\",\"definitions\":[{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"seat\":\"node-build-go\"}],\"entries\":[{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"module\":\"mesh-build-go\"},{\"digest\":\"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855\",\"module\":\"xclip\"}],\"kind\":\"trunk\",\"movers\":[{\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"fingerprint\":\"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\",\"module\":\"xclip\",\"repository\":\"novox/mesh-catalog\"}],\"revision\":12,\"source\":3589,\"trunk\":[{\"commit\":\"f469eb387a3015569d9b16c66ed418e9dd098f64\",\"repository\":\"novox/mesh-catalog\"}],\"v\":1}",
|
||||
decode: func(b []byte) (any, error) {
|
||||
var v CatalogRevisionsByBranchRevisionValue
|
||||
err := json.Unmarshal(b, &v)
|
||||
|
||||
@@ -208,7 +208,8 @@
|
||||
"fingerprint": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
|
||||
"repository": "novox/mesh-catalog"
|
||||
}
|
||||
]
|
||||
],
|
||||
"base": 9
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -1927,6 +1927,10 @@
|
||||
"$ref": "#/defs/TakeInEntry"
|
||||
},
|
||||
"description": "the movers of the take-in that wrote it, so a redelivered source-moved whose revision is kept says take-in.taken again from them, recomputing nothing (design 47 H §743, H-A-92); absent for one with no mover"
|
||||
},
|
||||
"base": {
|
||||
"type": "integer",
|
||||
"description": "the newest kept revision of its branch below it, which the take-in that wrote it pinned for its pipeline: the base of the validate step's case before (design 47 H-A-147, H-A-151, H-A-154); absent on the branch's first take-in"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
|
||||
@@ -273,6 +273,8 @@ export interface CatalogRevisionDefinitionsItem {
|
||||
export interface CatalogRevision {
|
||||
/** when (RFC 3339 time) */
|
||||
"at"?: string;
|
||||
/** the newest kept revision of its branch below it, which the take-in that wrote it pinned for its pipeline: the base of the validate step's case before (design 47 H-A-147, H-A-151, H-A-154); absent on the branch's first take-in */
|
||||
"base"?: number;
|
||||
/** the watched branch the revision is of */
|
||||
"branch"?: string;
|
||||
/** the seat definitions it was judged with, each by its digest, read whole through seat-definitions */
|
||||
|
||||
@@ -49,10 +49,12 @@ import (
|
||||
)
|
||||
|
||||
// busConf is the shape of the composed accounts file (mesh-controller internal/broker): one account with JetStream, the
|
||||
// controller's user and the indexer's own principal <node>.<module>.
|
||||
// controller's user and the indexer's own principal <node>.<module>; and the bus's system account, whose disconnect events
|
||||
// tell a restart when the stopped indexer's connections are gone (restartWaits).
|
||||
const busConf = `
|
||||
listen: 127.0.0.1:-1
|
||||
jetstream { store_dir: %q }
|
||||
system_account: SYS
|
||||
accounts {
|
||||
MESH {
|
||||
jetstream: enabled
|
||||
@@ -61,6 +63,11 @@ accounts {
|
||||
{ user: "n1.mesh-delivery-indexer", password: "pw" }
|
||||
]
|
||||
}
|
||||
SYS {
|
||||
users = [
|
||||
{ user: "sys", password: "pw" }
|
||||
]
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
@@ -420,12 +427,54 @@ func startIndexerRun(t *testing.T, put func(context.Context, buildLog), before .
|
||||
}
|
||||
start()
|
||||
t.Cleanup(func() { stop() })
|
||||
// restart stops the program and starts it again on the same bus, as the node-engine does with a new build.
|
||||
restart := func() { stop(); start() }
|
||||
// restart stops the program and starts it again on the same bus, as the node-engine does with a new build, once the bus has
|
||||
// closed every connection of the stopped one (restartWaits).
|
||||
gone := restartWaits(t, srv)
|
||||
restart := func() { gone(stop); start() }
|
||||
|
||||
return js, ctx, candidates, modules, restart
|
||||
}
|
||||
|
||||
// restartWaits gives a stop that returns only once the bus has closed every connection the indexer held, heard on the system
|
||||
// account's disconnect events, never by sleeping. A program's stop closes its connections on its side alone; until the bus
|
||||
// has closed them its pulls on a durable still count, and a source-moved said in between is delivered to the stopped
|
||||
// program, unacknowledged for the durable's whole acknowledgement wait, while the branch's durable delivers one message
|
||||
// at a time (design 47 H §743).
|
||||
func restartWaits(t *testing.T, srv *server.Server) func(stop func()) {
|
||||
t.Helper()
|
||||
sys, err := nats.Connect(srv.ClientURL(), nats.UserInfo("sys", "pw"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(sys.Close)
|
||||
return func(stop func()) {
|
||||
t.Helper()
|
||||
disconnects, err := sys.SubscribeSync("$SYS.ACCOUNT.MESH.DISCONNECT")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer func() { _ = disconnects.Unsubscribe() }()
|
||||
if err := sys.Flush(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
open, err := srv.Connz(&server.ConnzOptions{User: "n1.mesh-delivery-indexer"})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
stop()
|
||||
for left := open.NumConns; left > 0; {
|
||||
m, err := disconnects.NextMsg(waitBound)
|
||||
if err != nil {
|
||||
t.Fatalf("the bus closed %d of the stopped indexer's %d connections within %s: %v", open.NumConns-left, open.NumConns, waitBound, err)
|
||||
}
|
||||
var ev server.DisconnectEventMsg
|
||||
if json.Unmarshal(m.Data, &ev) == nil && ev.Client.User == "n1.mesh-delivery-indexer" {
|
||||
left--
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The build seats and their holders as the mesh has them (design 47:482-485 and 1583: a language's build module is the
|
||||
// module claiming the seat whose `acts` is step build on that language): the seat definitions as modules/mesh-delivery-contracts/seats/<seat>/
|
||||
// seat.json has them (acts included) and the manifests as the catalog's modules/mesh-build-go and mesh-build-node claim them.
|
||||
@@ -691,6 +740,7 @@ func TestIndexerBuildsARunsCandidateAndDropsItWhenEveryMembersPipelineEnded(t *t
|
||||
func TestIndexerCountsOnlyThePlacedBuildNodesToolchains(t *testing.T) {
|
||||
const goSum = "3b5028f0c1e9bde04dd766abd63eb5931bc516bae695cf46f00abcd8510b0381"
|
||||
var assignments, toolchains jetstream.KeyValue
|
||||
var heard *takeIns
|
||||
place := func(ctx context.Context, t *testing.T, node string, modules ...string) {
|
||||
p := meshmoduleassigner.Assignments{Node: node}
|
||||
for _, m := range modules {
|
||||
@@ -712,6 +762,7 @@ func TestIndexerCountsOnlyThePlacedBuildNodesToolchains(t *testing.T) {
|
||||
assignerLate = up
|
||||
t.Cleanup(func() { assignerLate = nil })
|
||||
js, ctx, _, modules, restart := startIndexerRun(t, func(context.Context, buildLog) {}, func(ctx context.Context, js jetstream.JetStream) {
|
||||
heard = hearTakeIns(t, js.Conn())
|
||||
registerAvahi(t, ctx, js, "main")
|
||||
kv, err := js.CreateKeyValue(ctx, jetstream.KeyValueConfig{Bucket: index.ToolchainsBucket("mesh-build-go"), History: 1})
|
||||
if err != nil {
|
||||
@@ -762,6 +813,10 @@ func TestIndexerCountsOnlyThePlacedBuildNodesToolchains(t *testing.T) {
|
||||
if !agreed(held) {
|
||||
t.Fatalf("within 20 s avahi has fp2 %q, none2 %q, toolchains %v: want a fingerprint of n1's go1.27 alone", held.Fp2, held.None2, held.Toolchains)
|
||||
}
|
||||
// The module is written before its take-in ends: each restart below waits for the source-moved's acknowledgement, the
|
||||
// take-in's end (design 47 H §743), so the stop cancels no take-in and leaves none unacknowledged ahead of the next one
|
||||
// on the branch's durable, which delivers one message at a time.
|
||||
heard.acked(t, "main")
|
||||
place(ctx, t, "n2", "mesh-build-go")
|
||||
key, _ := index.ToolchainKey("n2", "go")
|
||||
value, err := index.EncodeToolchain(nodebuildgo.Toolchain{Language: "go", Version: "go1.28.1", Recipe: "1", At: ptr(time.Now().Add(time.Second))})
|
||||
@@ -789,6 +844,7 @@ func TestIndexerCountsOnlyThePlacedBuildNodesToolchains(t *testing.T) {
|
||||
if m := read(disagree); !disagree(m) {
|
||||
t.Fatalf("within 20 s of a merge after n2's assignments avahi has fp2 %q, none2 %q: want the builders to disagree", m.Fp2, m.None2)
|
||||
}
|
||||
heard.acked(t, "main")
|
||||
// The view moves only at a take-in (design 47 H-A-49, H-A-103): with n2's assignments taken away, the next take-in agrees.
|
||||
place(ctx, t, "n2")
|
||||
restart()
|
||||
|
||||
@@ -457,6 +457,11 @@ func TestIndexerWhole(t *testing.T) {
|
||||
}
|
||||
sayPipeline(t, ctx, js, false, "main", 12)
|
||||
untilKey(t, ctx, pins, index.PinKey("main", 12), pinned("pipeline.main.12"))
|
||||
// The restart waits for the take-ins' ends, their source-moved acknowledged (design 47 H §743: main 10, 11, 11 given
|
||||
// again and 12), so the stop cancels none and leaves none unacknowledged ahead of main 13.
|
||||
for range 4 {
|
||||
heard.acked(t, "main")
|
||||
}
|
||||
restart()
|
||||
for _, name := range []string{"main.10", "main.11"} {
|
||||
if _, _, err := index.ReadRevision(ctx, objects, name); err != nil {
|
||||
|
||||
@@ -305,6 +305,12 @@ func (ix *Indexer) keepBranchEntries(ctx context.Context, branch string, src int
|
||||
return err
|
||||
}
|
||||
rev.Movers = movers
|
||||
// The base of the validate step's case before: the newest revision kept before this write, which the take-in pins for its
|
||||
// pipeline below, named on the revision in this same write (H-A-147, H-A-151, H-A-154); none on the branch's first take-in.
|
||||
pinsBase := len(movers) > 0 && ix.Pins != nil && newest.Revision > 0 && newest.Revision != src
|
||||
if pinsBase {
|
||||
rev.Base = newest.Revision
|
||||
}
|
||||
changed := changedEntries(newest.Entries, rev.Entries)
|
||||
used, capacity, fillErr := ix.Revisions.Fill(ctx)
|
||||
if fillErr == nil && capacity > 0 && used+newBytes(ctx, ix.Revisions, rev, objects) > capacity {
|
||||
@@ -332,8 +338,8 @@ func (ix *Indexer) keepBranchEntries(ctx context.Context, branch string, src int
|
||||
}
|
||||
// The branch's previous revision, the newest kept before this write, pinned for the same pipeline: it is the base of
|
||||
// the validate step's case before (H-A-108 (3), H-A-147), kept as long as the pipeline that needs it.
|
||||
if newest.Revision > 0 && newest.Revision != src {
|
||||
if err := ix.pin(ctx, PinKey(branch, newest.Revision), record); err != nil {
|
||||
if pinsBase {
|
||||
if err := ix.pin(ctx, PinKey(branch, rev.Base), record); err != nil {
|
||||
ix.logf("pins: the previous revision %s is not pinned for %s: %v", BranchObject(branch, newest.Revision), record, err)
|
||||
return fmt.Errorf("the pin of %s: %w", BranchObject(branch, newest.Revision), err)
|
||||
}
|
||||
|
||||
@@ -106,7 +106,8 @@ func mustRecords(t *testing.T, v []byte) []string {
|
||||
|
||||
// H-A-147 (§743, §749, H-A-108 (3)): a take-in with a mover pins, in its write, the branch's previous revision (the newest kept
|
||||
// before the write) for the same pipeline record as its own, so the validate step's case before can read it while the pipeline
|
||||
// runs; a take-in with no revision before it pins only its own; the pipeline's end frees both.
|
||||
// runs, and names it as its base on the revision it writes (H-A-151, H-A-154); a take-in with no revision before it pins only
|
||||
// its own and names no base; the pipeline's end frees both.
|
||||
func TestATakeInPinsTheBranchsPreviousRevisionForItsPipeline(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
reader := meshcatalog.CatalogEntry{Module: "reader", Repository: "novox/r", Manifest: map[string]any{}}
|
||||
@@ -116,9 +117,10 @@ func TestATakeInPinsTheBranchsPreviousRevisionForItsPipeline(t *testing.T) {
|
||||
before []int64 // sources taken in with no mover before the take-in of source 5
|
||||
whileRuns []string
|
||||
afterTheEnd []string
|
||||
base int64 // the base main.5 names (H-A-154)
|
||||
}{
|
||||
{name: "the previous revision kept and pinned", before: []int64{3, 4}, whileRuns: []string{"main.4", "main.5"}, afterTheEnd: []string{"main.5"}},
|
||||
{name: "the newest kept before, whatever its number", before: []int64{2}, whileRuns: []string{"main.2", "main.5"}, afterTheEnd: []string{"main.5"}},
|
||||
{name: "the previous revision kept and pinned", before: []int64{3, 4}, whileRuns: []string{"main.4", "main.5"}, afterTheEnd: []string{"main.5"}, base: 4},
|
||||
{name: "the newest kept before, whatever its number", before: []int64{2}, whileRuns: []string{"main.2", "main.5"}, afterTheEnd: []string{"main.5"}, base: 2},
|
||||
{name: "no revision before it pins only its own", whileRuns: []string{"main.5"}, afterTheEnd: []string{"main.5"}},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
@@ -143,6 +145,9 @@ func TestATakeInPinsTheBranchsPreviousRevisionForItsPipeline(t *testing.T) {
|
||||
keep(s, nil)
|
||||
}
|
||||
keep(5, mover)
|
||||
if rev, _, err := ReadRevision(ctx, ix.Revisions, "main.5"); err != nil || rev.Base != tc.base {
|
||||
t.Errorf("main.5 names the base %d (%v), want %d, the revision its take-in pinned (H-A-154)", rev.Base, err, tc.base)
|
||||
}
|
||||
if got := kept(); !slices.Equal(got, tc.whileRuns) {
|
||||
t.Errorf("while the pipeline runs: kept %v, want %v", got, tc.whileRuns)
|
||||
}
|
||||
|
||||
@@ -98,8 +98,14 @@ func place(p seat.Pipeline, m seat.Mover, reg catalog.Registration, entries map[
|
||||
build := seat.StepResult{Step: seat.StepResultStepBuild, Module: m.Module, Status: seat.StepResultStatusRequired, Fingerprint: m.Fingerprint,
|
||||
Seat: builds.Seat, Outcome: seat.StepResultOutcomeRunning, Started: &now, Ask: AskID(startOf(p, now), p.Pipeline, m.Module, "", seat.StepResultStepBuild)}
|
||||
steps = append(steps, build)
|
||||
// A run on request's build step ask names no source (the seat mesh-builds' contract; H-A-162): its candidate's
|
||||
// fingerprints are never in the builder's picture of the branch, so it waits for no revision there.
|
||||
source := p.Source
|
||||
if p.Run != "" {
|
||||
source = 0
|
||||
}
|
||||
asks = append(asks, Asked{Seat: builds.Seat, ID: build.Ask, Commit: m.Commit, Ask: builds.StepRun{Pipeline: p.Pipeline, Step: builds.StepRunStepBuild, Branch: p.Branch,
|
||||
Revision: p.Revision, Source: p.Source, Entries: []builds.BuildEntry{{Module: m.Module, Commit: m.Commit, Fingerprint: m.Fingerprint}}}})
|
||||
Revision: p.Revision, Source: source, Entries: []builds.BuildEntry{{Module: m.Module, Commit: m.Commit, Fingerprint: m.Fingerprint}}}})
|
||||
for _, a := range arts {
|
||||
name := a.Ref
|
||||
if _, after, ok := strings.Cut(a.Ref, ":"); ok {
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
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"
|
||||
)
|
||||
@@ -97,6 +98,19 @@ func TestRunOnRequest(t *testing.T) {
|
||||
if ids, _ := s.UnplacedRuns(); len(ids) != 0 {
|
||||
t.Errorf("a placed run is still unplaced: %v", ids)
|
||||
}
|
||||
// H-A-162: a run's build step asks name no source, as the seat mesh-builds' contract says of a run on request.
|
||||
builtAsks := 0
|
||||
for _, x := range asks.asks {
|
||||
if r, ok := x.(builds.StepRun); ok {
|
||||
builtAsks++
|
||||
if r.Source != 0 {
|
||||
t.Errorf("the run's build step ask names source %d, want none", r.Source)
|
||||
}
|
||||
}
|
||||
}
|
||||
if builtAsks == 0 {
|
||||
t.Errorf("the run asked no build step: %v", asks.asks)
|
||||
}
|
||||
if n, _ := s.PlaceRun(ev, Half{Revision: 12, Entries: cand}, base); n != 0 {
|
||||
t.Errorf("the revision heard again placed %d", n)
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
// at a commit of the repository that builds it. The indexer reads it so at each trunk merge (its packages state's series
|
||||
// keys), and the checker so at a delivery group member's head for a package new in the group, so the judge is handed one
|
||||
// name for each package whoever reads it (mesh-sdk composer.Request.Packages).
|
||||
// Design 47 H1, proof 2: this comment is the mesh-delivery-sdk half of a two-module change its pipeline delivers.
|
||||
package packagename
|
||||
|
||||
import (
|
||||
|
||||
Reference in New Issue
Block a user