A13: the whole test follows the newest passed version, tier by tier
The assigner's whole tests no longer assume wants follow the trunk's fingerprint: a runner's pipeline-ended names the movers and versions, the wants are written tier by tier on running, and pipeline-wanted says running at the end. Test 113's cases: a provider and its consumer in tiers, the acting part's build and the old holds ignored, a failed pipeline's version and an older end heard late writing nothing, a placement's build reverting the want, tier-late after tier-bound with no later tier written, and a node not stating want:version held awaiting its hand placement. Test 117's cases run the step validate whole: a refused manifest, a pass and a cycle. The first views answer every account (no callers), and tier-bound's unit is a variable the whole test shortens. Builds: design 47 H §774, §750, §751, §772, §745, §752; acceptance tests 113, 117; lead answers H-A-10, H-A-37, H-A-40, H-A-41, H-A-56, H-A-73, H-A-75, H-A-99, H-A-108 Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy
This commit is contained in:
+131
@@ -5,6 +5,7 @@ package main
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -241,3 +242,133 @@ func readInput(t *testing.T, nc *nats.Conn, in buildstep.RunInput) []byte {
|
||||
}
|
||||
return out.Bytes()
|
||||
}
|
||||
|
||||
// Design 47 H §745 (acceptance test 117, the assigner's half; H-A-108), started whole on the bus: the assigner serves the step
|
||||
// validate on the seat mesh-wants. A take-in whose manifest names an unknown field fails it `manifest-refused` naming it, the
|
||||
// validator being the revision's own entry of the module holding the seat mesh-catalog, run on the Go build seat over the
|
||||
// revision's manifests and the previous revision's; a take-in that changes a manifest with no problem passes it; a take-in whose
|
||||
// entries make a cycle fails it `cycle` naming the cycle, with no validator asked.
|
||||
func TestTheValidateStepServedWholeRefusesAManifestProblemAndACycle(t *testing.T) {
|
||||
b := startBed(t, "")
|
||||
nc, err := nats.Connect(b.srv.ClientURL())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(nc.Close)
|
||||
const commit = "2222222222222222222222222222222222222222"
|
||||
if _, err := b.js.CreateOrUpdateConsumer(b.ctx, "EVENTS", jetstream.ConsumerConfig{Durable: "n1_mesh-delivery-assigner",
|
||||
FilterSubjects: []string{enginereads.SubjectPrefix + "*", "mesh.mod." + buckets.IndexerModule + ".event.views.>", meshcatalog.SubjectCatalogRevisionAll,
|
||||
nodebuildgo.SubjectStepEndedAll}, AckPolicy: jetstream.AckExplicitPolicy}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
indexer := meshcatalog.CatalogEntry{Module: "indexer", Repository: "novox/mesh-delivery", Commit: commit, Path: "modules/mesh-delivery-indexer",
|
||||
Fp: "src2:ix", Serves: []string{"seat:" + meshcatalog.Seat + ".revision"}, Manifest: map[string]any{"module": "indexer"}, ManifestDigest: "d-ix"}
|
||||
entry := func(module, digest string, manifest map[string]any, edges ...meshcatalog.Edge) meshcatalog.CatalogEntry {
|
||||
manifest["module"] = module
|
||||
return meshcatalog.CatalogEntry{Module: module, Manifest: manifest, ManifestDigest: digest, Edges: edges}
|
||||
}
|
||||
b.cat.mu.Lock()
|
||||
b.cat.rev[trunkBranch] = 9
|
||||
b.cat.at = map[string]map[int64][]meshcatalog.CatalogEntry{trunkBranch: {
|
||||
6: {indexer, entry("web", "d-web-1", map[string]any{"version": "1"})},
|
||||
7: {indexer, entry("web", "d-web-2", map[string]any{"version": "2", "colour": "red"})},
|
||||
8: {indexer, entry("web", "d-web-3", map[string]any{"version": "3"})},
|
||||
9: {indexer, entry("a", "d-a", map[string]any{}, meshcatalog.Edge{From: "a:x", To: "b:y", Kind: 3}, meshcatalog.Edge{From: "b:y", To: "a:x", Kind: 3}),
|
||||
entry("b", "d-b", map[string]any{})},
|
||||
}}
|
||||
b.cat.mu.Unlock()
|
||||
ended := make(chan meshwants.StepEnded, 4)
|
||||
ends, err := nc.Subscribe("mesh.seat.mesh-wants.event.step-ended.n1", func(m *nats.Msg) {
|
||||
var e meshwants.StepEnded
|
||||
_ = json.Unmarshal(m.Data, &e)
|
||||
ended <- e
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() { _ = ends.Unsubscribe() })
|
||||
subscribed(t, nc)
|
||||
from := b.journal.mark()
|
||||
b.start(t)
|
||||
b.journal.await(t, from, "the composition step is heard on", "the steps served", 30*time.Second)
|
||||
select {
|
||||
case <-b.seatListRead:
|
||||
case <-time.After(30 * time.Second):
|
||||
t.Fatal("the assigner did not read the seat list within 30 s")
|
||||
}
|
||||
queue, _ := buildstep.AskStream(buildstep.AskGo)
|
||||
worker, err := b.js.CreateOrUpdateConsumer(b.ctx, queue, jetstream.ConsumerConfig{Durable: "stand-in", FilterSubject: "mesh.seat.node-build-go.accept.check.mesh-wants", AckPolicy: jetstream.AckExplicitPolicy})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
ask := func(revision int64, module string, run func()) meshwants.StepEnded {
|
||||
t.Helper()
|
||||
id := fmt.Sprintf("validate-%d", revision)
|
||||
step, _ := json.Marshal(meshwants.StepRun{Pipeline: fmt.Sprintf("%s.%d", trunkBranch, revision), Step: meshwants.StepRunStepValidate, Module: module,
|
||||
Branch: trunkBranch, Revision: revision, Commit: commit})
|
||||
msg := nats.NewMsg(meshwants.AcceptSubjectStep)
|
||||
msg.Header.Set("x-event-id", id)
|
||||
msg.Data = step
|
||||
if err := nc.PublishMsg(msg); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if run != nil {
|
||||
run()
|
||||
}
|
||||
for {
|
||||
select {
|
||||
case e := <-ended:
|
||||
if e.ID == id {
|
||||
return e
|
||||
}
|
||||
case <-time.After(30 * time.Second):
|
||||
t.Fatalf("the validate step of revision %d said no end", revision)
|
||||
}
|
||||
}
|
||||
}
|
||||
// The stand-in Go build seat runs the validator: it refuses a manifest naming the field colour, and accepts every other.
|
||||
validator := func() {
|
||||
t.Helper()
|
||||
got, err := worker.Next(jetstream.FetchMaxWait(30 * time.Second))
|
||||
if err != nil {
|
||||
t.Fatalf("no validator run is asked: %v", err)
|
||||
}
|
||||
_ = got.Ack()
|
||||
a, err := buildstep.DecodeStepAsk(got.Data())
|
||||
if err != nil || a.Run == nil || a.Run.Program.Repository != "novox/mesh-delivery" || a.Run.Program.Commit != commit {
|
||||
t.Fatalf("the validator's run ask %s: %v", got.Data(), err)
|
||||
}
|
||||
req, err := composer.Decode(readInput(t, nc, a.Run.Input))
|
||||
if err != nil || len(req.Cases) != 2 || req.Cases[0].Name != changeCase || req.Cases[1].Name != beforeCase {
|
||||
t.Fatalf("the validator's request: %+v %v", req, err)
|
||||
}
|
||||
v := composer.Verdict{V: composer.Version}
|
||||
for _, c := range req.Cases {
|
||||
reads := map[string]composer.ManifestRead{}
|
||||
for module, m := range c.Manifests {
|
||||
reads[module] = composer.ManifestRead{Accepted: true}
|
||||
if strings.Contains(string(m.Raw), "colour") {
|
||||
reads[module] = composer.ManifestRead{Refused: `unknown field "colour"`}
|
||||
}
|
||||
}
|
||||
v.Cases = append(v.Cases, composer.CaseVerdict{Name: c.Name, Manifests: reads})
|
||||
}
|
||||
out, _ := json.Marshal(v)
|
||||
end, _ := json.Marshal(buildstep.StepEnded{V: 1, ID: a.ID, Ask: a.ID, Asker: runAsker, Node: "b1", Outcome: buildstep.OutcomePassed, Output: string(out), At: time.Now().UTC()})
|
||||
if _, err := b.js.Publish(b.ctx, nodebuildgo.SubjectStepEnded("b1"), end); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
if e := ask(7, "web", validator); e.Outcome != meshwants.StepEndedOutcomeFailed || !strings.HasPrefix(e.Said, reasonManifestRefused+": ") || !strings.Contains(e.Said, `web: unknown field "colour"`) {
|
||||
t.Errorf("the validate step of a manifest naming an unknown field ended %+v", e)
|
||||
}
|
||||
if e := ask(8, "web", validator); e.Outcome != meshwants.StepEndedOutcomePassed {
|
||||
t.Errorf("the validate step of a manifest with no problem ended %+v", e)
|
||||
}
|
||||
if e := ask(9, "a", nil); e.Outcome != meshwants.StepEndedOutcomeFailed || e.Said != reasonCycle+": a:x → b:y → a:x" {
|
||||
t.Errorf("the validate step of a take-in making a cycle ended %+v", e)
|
||||
}
|
||||
if info, err := worker.Info(b.ctx); err != nil || info.NumPending != 0 {
|
||||
t.Errorf("a validator is asked for the cycle: %+v %v", info, err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import (
|
||||
"time"
|
||||
|
||||
"git.novox.be/novox/mesh-contracts/go/clients/nodeengineclient"
|
||||
mconds "git.novox.be/novox/mesh-contracts/health-and-repair/go/clients/meshconditionsclient"
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-assigner/asks"
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds"
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient"
|
||||
@@ -31,6 +32,8 @@ import (
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshdeliveryclient"
|
||||
mwc "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshwantsclient"
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
||||
mpr "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshpipelinerunner"
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshwants"
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-sdk/buildstep"
|
||||
"git.novox.be/novox/mesh-delivery/modules/mesh-grants/grantsstate"
|
||||
|
||||
@@ -44,7 +47,6 @@ import (
|
||||
mma "git.novox.be/novox/mesh-contracts/go/seats/meshmoduleassigner"
|
||||
occ "git.novox.be/novox/mesh-contracts/operator-and-conversation/go/clients/operatorchannelclient"
|
||||
oc "git.novox.be/novox/mesh-contracts/operator-and-conversation/go/seats/operatorchannel"
|
||||
"git.novox.be/novox/mesh-contracts/provisioning/go/clients/meshprovisionerclient"
|
||||
mdseat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshdelivery"
|
||||
stdio "git.novox.be/novox/mesh-sdk/go"
|
||||
"git.novox.be/novox/mesh-sdk/go/announce"
|
||||
@@ -77,6 +79,8 @@ type bed struct {
|
||||
buckets map[string]jetstream.KeyValue
|
||||
// placed is, by node, the modules the bed's assignments names on it (place).
|
||||
placed map[string][]string
|
||||
// builds is, by node and module, the build a placement names (placeBuild, design 47 H §750).
|
||||
builds map[string]map[string]string
|
||||
// journal is what the programs the bed starts write in their journal.
|
||||
journal *journal
|
||||
// cat is the catalog half the seat mesh-catalog serves the assigner (serveCatalog).
|
||||
@@ -90,6 +94,9 @@ type catalogBed struct {
|
||||
entries map[string]map[string]meshcatalog.CatalogEntry
|
||||
rev map[string]int64
|
||||
bodies map[string]string
|
||||
// at is, by branch and revision, a revision's entries a test keeps whole: the verb revision answers a revision asked by its
|
||||
// number from here, and the current one otherwise.
|
||||
at map[string]map[int64][]meshcatalog.CatalogEntry
|
||||
}
|
||||
|
||||
// journal is a program's journal as the bed hears it: a test awaits a line in it (await) where the line is the only sign
|
||||
@@ -211,6 +218,14 @@ func startBed(t *testing.T, leaveOut string) *bed {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
// The seat mesh-catalog's version-released, kept by age, which the assigner reads whole and follows: a placement's build is
|
||||
// named by the version released at it (design 47 H §750, H-A-99).
|
||||
if _, err := js.CreateStream(ctx, keptStream(meshcatalog.StreamVersionReleased, meshcatalog.SubjectVersionReleased, jetstream.StreamConfig{MaxAge: 90 * 24 * time.Hour})); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := js.CreateOrUpdateConsumer(ctx, meshcatalog.StreamVersionReleased, jetstream.ConsumerConfig{Durable: "n1_mesh-delivery-assigner", AckPolicy: jetstream.AckExplicitPolicy}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// The builder's stream of build ends, kept last per subject (its manifest's `last-per-subject`, design 47 G A-181), which the assigner
|
||||
// reads whole at its start and follows through its durable, as the grants part makes it (from the last of each subject).
|
||||
if _, err := js.CreateStream(ctx, jetstream.StreamConfig{Name: buildsStreamName, Subjects: []string{process.ModuleStreamSubject(builds.BuilderModule, builds.BuildEndedEvent+".>")}, MaxAge: 168 * time.Hour}); err != nil { // kept by age, as the bus keeps it live (2026-11-15): read whole from its first message all the same (A-233)
|
||||
@@ -229,7 +244,7 @@ func startBed(t *testing.T, leaveOut string) *bed {
|
||||
// machineEvent; the grants part's own test holds the derivation).
|
||||
if _, err := js.CreateOrUpdateConsumer(ctx, "EVENTS", jetstream.ConsumerConfig{Durable: "n1_mesh-delivery-assigner",
|
||||
FilterSubjects: []string{enginereads.SubjectPrefix + "*", "mesh.mod." + buckets.IndexerModule + ".event.views.>",
|
||||
"mesh.mod." + buckets.TellerModule + ".event.views.>", meshcatalog.SubjectCatalogRevisionAll}, AckPolicy: jetstream.AckExplicitPolicy}); err != nil {
|
||||
"mesh.mod." + buckets.TellerModule + ".event.views.>", meshcatalog.SubjectCatalogRevisionAll, pipelineEndedSubject}, AckPolicy: jetstream.AckExplicitPolicy}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// The operator-channel seat's stream of conditions, which the assigner says its conditions on.
|
||||
@@ -506,7 +521,7 @@ func (b *bed) place(t *testing.T, node, module string) {
|
||||
}
|
||||
pl := mma.Assignments{Node: node}
|
||||
for _, m := range b.placed[node] {
|
||||
pl.Modules = append(pl.Modules, mma.PlacedModule{Module: m})
|
||||
pl.Modules = append(pl.Modules, mma.PlacedModule{Module: m, Build: b.builds[node][m]})
|
||||
}
|
||||
values, err := mmac.AssignmentsValues(pl)
|
||||
if err != nil {
|
||||
@@ -560,61 +575,131 @@ func (b *bed) get(t *testing.T, bucket, key string) []byte {
|
||||
return nil
|
||||
}
|
||||
|
||||
// 1297/B4 on the bus, 1906/D5: the controller sends ace, g14 and shanks builds while the canary ace does not run F healthy yet.
|
||||
// Started whole, the assigner wants F on the canary and writes no difference at all: there is no send to compare with (ADR 0539
|
||||
// §8). 1945/AC19, AC21: shanks, which runs the older fingerprint (composed and granted) with no want, gets its first want at that
|
||||
// fingerprint, never at F; g14, which runs a build of the old form, gets none, so web is on neither list there and the assigner
|
||||
// raises the condition naming g14, web and the canary rule; once ace runs F healthy, g14's first want names F and the condition is
|
||||
// cleared.
|
||||
// moverAt is one mover of a pipeline the bed's runner says ended: its module, the fingerprint and version it released, its tier.
|
||||
type moverAt struct {
|
||||
module, fp, version string
|
||||
tier int64
|
||||
}
|
||||
|
||||
// ended says the runner's pipeline-ended of the trunk's pipeline at source, with outcome, each mover's required steps passed when
|
||||
// the pipeline passed and its validate step failed when it did not (design 47 H §746, §750).
|
||||
func (b *bed) ended(t *testing.T, source int64, outcome string, movers ...moverAt) string {
|
||||
t.Helper()
|
||||
pipeline := fmt.Sprintf("%s.%d", trunkBranch, source)
|
||||
step := mpr.StepResult{Step: mpr.StepResultStepValidate, Status: mpr.StepResultStatusRequired, Outcome: mpr.StepResultOutcomePassed}
|
||||
if outcome != mpr.PipelineEndedOutcomePassed {
|
||||
step.Outcome = mpr.StepResultOutcomeFailed
|
||||
}
|
||||
e := mpr.PipelineEnded{V: 1, Pipeline: pipeline, Branch: trunkBranch, Source: source, Outcome: outcome}
|
||||
for _, m := range movers {
|
||||
e.Movers = append(e.Movers, mpr.MoverEnded{Module: m.module, Fingerprint: m.fp, Version: m.version, Tier: m.tier, Steps: []mpr.StepResult{step}})
|
||||
}
|
||||
raw, _ := json.Marshal(e)
|
||||
if _, err := b.js.Publish(b.ctx, mpr.SubjectPipelineEnded(trunkBranch, fmt.Sprint(source)), raw); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
return pipeline
|
||||
}
|
||||
|
||||
// readsVersion says node's node-engine reads a want by version (the node-engine seat's manifest-reads-changed, design 47 H §772).
|
||||
func (b *bed) readsVersion(t *testing.T, node string) {
|
||||
t.Helper()
|
||||
body, _ := json.Marshal(nodeengine.ManifestReadsChangedEvent{V: 1, Node: node, ManifestReads: []string{nodeengine.ManifestReadWordWantVersion},
|
||||
At: time.Now().UTC().Format(time.RFC3339Nano), Why: enginereads.ReadsStarted})
|
||||
if _, err := b.js.Publish(b.ctx, enginereads.SubjectPrefix+node, body); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
// runs says node runs module at fp, healthy, as its node-engine writes its have and says `running`.
|
||||
func (b *bed) runs(t *testing.T, node, module, fp string) {
|
||||
t.Helper()
|
||||
have, _ := nodeengineclient.EncodeHave(nodeengine.HaveByNodeModuleValue{Fp: fp, Phase: nodeengineclient.PhaseRunning, Health: nodeengineclient.HealthOK})
|
||||
b.putJSON(t, buckets.Have, node+"."+module, have)
|
||||
}
|
||||
|
||||
// placeBuild names build in the placement of module on node (design 47 H §750, H-A-99).
|
||||
func (b *bed) placeBuild(t *testing.T, node, module, build string) {
|
||||
t.Helper()
|
||||
if b.builds == nil {
|
||||
b.builds = map[string]map[string]string{}
|
||||
}
|
||||
if b.builds[node] == nil {
|
||||
b.builds[node] = map[string]string{}
|
||||
}
|
||||
b.builds[node][module] = build
|
||||
b.place(t, node, module)
|
||||
}
|
||||
|
||||
// versionsOf are the versions the want of module on node named, in the order written, each once.
|
||||
func (b *bed) versionsOf(t *testing.T, node, module string) []string {
|
||||
t.Helper()
|
||||
key, _ := mwc.WantKey(node, module)
|
||||
history, err := b.buckets[buckets.Wants()].History(b.ctx, key)
|
||||
if err != nil {
|
||||
t.Fatalf("the want of %s on %s has no history: %v", module, node, err)
|
||||
}
|
||||
var out []string
|
||||
for _, e := range history {
|
||||
if w, err := mwc.DecodeWant(e.Value()); err == nil && (len(out) == 0 || out[len(out)-1] != w.Version) {
|
||||
out = append(out, w.Version)
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// Design 47 H §750, §751, §772 (acceptance test 113, the assigner's half), started whole on the bus: a want is the newest
|
||||
// released version whose pipeline passed, written tier by tier. A provider (db) and its consumer (app) passed in one pipeline:
|
||||
// db is wanted on ace and g14 naming its version, the pipeline and rank 1, whatever build the acting part (the node-engine
|
||||
// module, whose pipeline never passed) runs, with no grant, no canary and no healthy provider; app's want waits until db runs
|
||||
// on both, then names rank 2, and the pipeline says pipeline-wanted running. A failed pipeline's version is not wanted, and an
|
||||
// older end heard after a newer one writes nothing. g14's placement naming db's first build reverts its want to the version
|
||||
// released at it. A pipeline whose first tier never runs raises tier-late within tier-bound and writes no later tier. shanks,
|
||||
// whose node-engine does not say it reads a want by version, has its want held, awaiting its hand placement. DLV-F5r (ADR 0621
|
||||
// §3, ADR 0631 §2): the assigner's first views wait on the indexer, whose late answer clears the condition naming it.
|
||||
func TestWantsAreWrittenAndNoDifferenceIs(t *testing.T) {
|
||||
// DLV-F5r (ADR 0621 §3): the indexer's runtime starts together with the assigner and answers its first views only
|
||||
// after the assigner asked; within the bound the assigner writes the wants from what they answer.
|
||||
up := make(chan struct{})
|
||||
catalogLate = up
|
||||
// ADR 0631 §2: while the indexer does not answer, past the first-view bound the assigner raises the condition naming
|
||||
// the indexer and graph, and reads nothing of the indexer's state; the answer clears it.
|
||||
firstViewBound, firstViewWait = 300*time.Millisecond, 50*time.Millisecond
|
||||
t.Cleanup(func() { catalogLate, firstViewBound, firstViewWait = nil, 0, 0 })
|
||||
tierBoundUnit = time.Second
|
||||
t.Cleanup(func() { catalogLate, firstViewBound, firstViewWait, tierBoundUnit = nil, 0, 0, time.Minute })
|
||||
for _, name := range append(append([]string{}, readBuckets...), watched()...) {
|
||||
if strings.HasPrefix(name, buckets.IndexerModule+"_") {
|
||||
t.Errorf("the assigner reads the indexer's state %s itself", name)
|
||||
}
|
||||
}
|
||||
b := startBed(t, "")
|
||||
fNew, fOld := meshcatalogclient.SourcePrefix2+strings.Repeat("b", 64), meshcatalogclient.SourcePrefix2+strings.Repeat("a", 64)
|
||||
digest := b.manifest(t, "web", `{"module":"web","version":"1"}`)
|
||||
mod, _ := meshcatalogclient.EncodeModule(meshcatalog.ModulesByModuleValue{Fp2: fNew, Manifest: digest, Repository: "novox/web", Commit: strings.Repeat("1", 40), Path: meshcatalogclient.RootPath})
|
||||
b.putModule(t, "web", mod)
|
||||
built, err := builds.EncodeBuilderBuild(builds.BuilderBuild{State: builds.BuildDone, By: "builder.novox.1", Step: "pushed", Manifest: digest})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
t.Cleanup(func() {
|
||||
if t.Failed() {
|
||||
b.journal.mu.Lock()
|
||||
t.Log(b.journal.text.String())
|
||||
b.journal.mu.Unlock()
|
||||
}
|
||||
})
|
||||
b.settings = map[string]string{"MESH_ASSIGNER_TIER_BOUND_FILE": "3"} // tier-bound 3 s at the test's unit
|
||||
fpOf := func(c byte) string { return meshcatalogclient.SourcePrefix2 + strings.Repeat(string(c), 64) }
|
||||
// The trunk's catalog half names every module at its newest fingerprint; none is built, granted or provided as the old rules
|
||||
// asked. The acting part engine runs an older build on ace, and no pipeline of its newer one passed.
|
||||
for module, fp := range map[string]string{"web": fpOf('b'), "db": fpOf('2'), "app": fpOf('3'), "cache": fpOf('5'), "api": fpOf('6'), "engine": fpOf('e')} {
|
||||
digest := b.manifest(t, module, fmt.Sprintf(`{"module":%q,"version":"1"}`, module))
|
||||
mod, _ := meshcatalogclient.EncodeModule(meshcatalog.ModulesByModuleValue{Fp2: fp, Manifest: digest, Repository: "novox/" + module, Commit: strings.Repeat("1", 40), Path: meshcatalogclient.RootPath})
|
||||
b.putModule(t, module, mod)
|
||||
}
|
||||
bkey, _ := builds.BuilderBuildKey("web", fNew)
|
||||
b.putBuild(t, bkey, built)
|
||||
for _, fp := range []string{fNew, fOld} {
|
||||
gkey, _ := grantsstate.PartGrantKey("web", fp)
|
||||
grant, _ := grantsstate.EncodeGrant(grantsstate.Grant{})
|
||||
b.putJSON(t, buckets.Grants, gkey, grant)
|
||||
}
|
||||
runs := map[string]string{"ace": fOld, "g14": "build-9", "shanks": fOld}
|
||||
for _, node := range []string{"ace", "g14", "shanks"} {
|
||||
b.compose(t, node, 'c')
|
||||
have, _ := nodeengineclient.EncodeHave(nodeengine.HaveByNodeModuleValue{Fp: runs[node], Phase: nodeengineclient.PhaseRunning, Health: nodeengineclient.HealthOK})
|
||||
b.putJSON(t, buckets.Have, node+".web", have)
|
||||
b.place(t, node, "web")
|
||||
}
|
||||
b.compose(t, "shanks", 'a')
|
||||
for _, node := range []string{"ace", "g14"} {
|
||||
b.place(t, node, "db")
|
||||
b.place(t, node, "app")
|
||||
b.readsVersion(t, node)
|
||||
}
|
||||
b.place(t, "ace", "engine")
|
||||
b.runs(t, "ace", "engine", fpOf('d'))
|
||||
b.place(t, "ace", "cache")
|
||||
b.place(t, "ace", "api")
|
||||
b.start(t)
|
||||
// DLV-F5r (ADR 0621 §1-§3, design 25 § 12 on a fresh mesh): the assigner asks nothing of the bus module (its manifest
|
||||
// has no bus-state entry, the bed runs no bus module and holds no binding of one), and while it still waits on the
|
||||
// indexer its runtime of its own answers each first-view tool to the readers its manifest's callers lists name, at
|
||||
// its mark, and refuses every other account, the assigner's own included.
|
||||
firstViewsBeforeAnyNewFormState(t, b, map[string][]string{
|
||||
"assignments": {"n1.mesh-grants", "n1.node-tools", "n1.mesh-delivery-indexer", "n1.mesh-delivery-builder", "n1.mesh-delivery-checker"},
|
||||
"seat-holders": {"n1.node-tools", "n1.mesh-delivery-builder", "n1.mesh-delivery-view", "n1.mesh-delivery-teller", "n1.mesh-delivery-checker", "n1.mesh-delivery-indexer"}, // A-298, A-302: the parts following it
|
||||
"wants": {"n1.mesh-grants"},
|
||||
})
|
||||
// The reader raises the finding of the first view through the module's finding writer (A-26), its id escaped as a key's name.
|
||||
firstViewsBeforeAnyNewFormState(t, b, []string{"assignments", "seat-holders", "wants"})
|
||||
graphKey := views.FindingKey(views.FindingScope, keys.EscapeName(assignment.Module()+"."+meshcatalog.Seat+"."+views.BranchState(meshcatalog.StateCatalogRevisions, trunkBranch)), views.UnansweredKind)
|
||||
graphRaised := func() bool {
|
||||
e, err := b.buckets[assign.FindingsBucket()].Get(b.ctx, graphKey)
|
||||
@@ -631,66 +716,128 @@ func TestWantsAreWrittenAndNoDifferenceIs(t *testing.T) {
|
||||
t.Fatalf("the seat answered, and the condition naming its revision verb stands (finding %s)", graphKey)
|
||||
}
|
||||
}
|
||||
|
||||
wkey, _ := mwc.WantKey("ace", "web")
|
||||
want, err := mwc.DecodeWant(b.get(t, buckets.Wants(), wkey))
|
||||
if err != nil || want.Fp != fNew {
|
||||
t.Fatalf("the canary ace's want = %+v, %v", want, err)
|
||||
nc, err := nats.Connect(b.srv.ClientURL())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if w := b.wantNow(t, "shanks", "web", "shanks' first want at what it runs", func(w mwc.Want) bool { return w.Fp != "" }); w.Fp != fOld || !w.Self {
|
||||
t.Errorf("shanks' want = %+v, want the fingerprint it runs, the node composing it, held back from F", w)
|
||||
t.Cleanup(nc.Close)
|
||||
wanted := make(chan meshwants.PipelineWanted, 8)
|
||||
sub, err := nc.Subscribe("mesh.seat."+meshwants.Seat+".event."+meshwants.EventPipelineWanted+".>", func(m *nats.Msg) {
|
||||
var e meshwants.PipelineWanted
|
||||
_ = json.Unmarshal(m.Data, &e)
|
||||
wanted <- e
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// DLV-O5 (ADR 0615 §5, ADR 0619 §2): each want is said on the assigner's views family, its value whole at its revision,
|
||||
// and the first view at the mark followed by those events holds it as the bucket does; a waiter on put never wakes.
|
||||
b.viewsHold(t, "wants", wkey)
|
||||
var neither oc.Condition
|
||||
for deadline := time.Now().Add(10 * time.Second); time.Now().Before(deadline) && neither.Key == ""; time.Sleep(100 * time.Millisecond) {
|
||||
for k, c := range b.conditionsSaid(t) {
|
||||
if strings.HasSuffix(k, ".neither") && c.State == occ.StateRaised {
|
||||
neither = c
|
||||
t.Cleanup(func() { _ = sub.Unsubscribe() })
|
||||
subscribed(t, nc)
|
||||
pipelineWanted := func(pipeline, outcome string) meshwants.PipelineWanted {
|
||||
t.Helper()
|
||||
for {
|
||||
select {
|
||||
case e := <-wanted:
|
||||
if e.Pipeline == pipeline {
|
||||
if e.Outcome != outcome {
|
||||
t.Fatalf("pipeline-wanted of %s said %+v, want %s", pipeline, e, outcome)
|
||||
}
|
||||
return e
|
||||
}
|
||||
case <-time.After(15 * time.Second):
|
||||
t.Fatalf("no pipeline-wanted of %s", pipeline)
|
||||
}
|
||||
}
|
||||
}
|
||||
if neither.Subject.Machine != "g14" || !strings.HasPrefix(neither.Subject.ID, "g14.web") || neither.Severity != occ.SeverityUrgent || !strings.Contains(neither.Explanation, "canary") {
|
||||
t.Errorf("the condition of web on neither list on g14 = %+v", neither)
|
||||
|
||||
// §772: web passed; ace and g14 are wanted at its version, shanks' want is held awaiting its hand placement.
|
||||
web := b.ended(t, 4, mpr.PipelineEndedOutcomePassed, moverAt{"web", fpOf('b'), "1.0.0", 1})
|
||||
if w := b.wantNow(t, "ace", "web", "web's want at its passed version", func(w mwc.Want) bool { return w.Version == "1.0.0" }); w.Fp != fpOf('b') || w.Pipeline != web || w.Rank != 1 || w.Hold {
|
||||
t.Errorf("ace's want of web = %+v", w)
|
||||
}
|
||||
if w := b.wantNow(t, "shanks", "web", "shanks' want held", func(w mwc.Want) bool { return w.Hold }); w.Words != mwc.HoldAwaitsHandPlacement || w.Version != "1.0.0" {
|
||||
t.Errorf("shanks' want of web = %+v, want held awaiting its hand placement", w)
|
||||
}
|
||||
|
||||
// §750, §751: tier 1 (db) is wanted at once on every placing machine, tier 2 (app) only once db runs on both.
|
||||
first := b.ended(t, 5, mpr.PipelineEndedOutcomePassed, moverAt{"db", fpOf('2'), "1.0.0", 1}, moverAt{"app", fpOf('3'), "1.0.0", 2})
|
||||
for _, node := range []string{"ace", "g14"} {
|
||||
if w := b.wantNow(t, node, "db", "db's want at 1.0.0", func(w mwc.Want) bool { return w.Version == "1.0.0" }); w.Fp != fpOf('2') || w.Pipeline != first || w.Rank != 1 {
|
||||
t.Errorf("%s's want of db = %+v", node, w)
|
||||
}
|
||||
}
|
||||
if b.hasKey(buckets.Wants(), "want.ace.app") || b.hasKey(buckets.Wants(), "want.g14.app") {
|
||||
t.Error("app, the consumer in tier 2, is wanted before its provider runs")
|
||||
}
|
||||
if b.hasKey(buckets.Wants(), "want.ace.engine") {
|
||||
t.Error("the acting part is wanted with no pipeline of it passed")
|
||||
}
|
||||
b.runs(t, "ace", "db", fpOf('2'))
|
||||
b.runs(t, "g14", "db", fpOf('2'))
|
||||
for _, node := range []string{"ace", "g14"} {
|
||||
if w := b.wantNow(t, node, "app", "app's want once db runs", func(w mwc.Want) bool { return w.Version == "1.0.0" }); w.Fp != fpOf('3') || w.Rank != 2 {
|
||||
t.Errorf("%s's want of app = %+v", node, w)
|
||||
}
|
||||
b.runs(t, node, "app", fpOf('3'))
|
||||
}
|
||||
pipelineWanted(first, meshwants.PipelineWantedOutcomeRunning)
|
||||
|
||||
// §750: a failed pipeline's version is not wanted; a newer passed one is, and an older end heard after it writes nothing.
|
||||
b.ended(t, 6, mpr.PipelineEndedOutcomeFailed, moverAt{"db", fpOf('7'), "1.1.0", 1})
|
||||
b.ended(t, 8, mpr.PipelineEndedOutcomePassed, moverAt{"db", fpOf('9'), "1.2.0", 1})
|
||||
b.wantNow(t, "ace", "db", "db's want at 1.2.0", func(w mwc.Want) bool { return w.Version == "1.2.0" })
|
||||
b.ended(t, 7, mpr.PipelineEndedOutcomePassed, moverAt{"db", fpOf('8'), "1.1.5", 1})
|
||||
// §751: cache never runs, so its tier is late within tier-bound and api, tier 2, is never wanted; the late end is also the
|
||||
// barrier after which the older end of db was heard.
|
||||
late := b.ended(t, 10, mpr.PipelineEndedOutcomePassed, moverAt{"cache", fpOf('5'), "1.0.0", 1}, moverAt{"api", fpOf('6'), "1.0.0", 2})
|
||||
b.wantNow(t, "ace", "cache", "cache's want", func(w mwc.Want) bool { return w.Version == "1.0.0" })
|
||||
if e := pipelineWanted(late, meshwants.PipelineWantedOutcomeTierLate); len(e.NotRunning) != 1 || e.NotRunning[0].Module != "cache" || !slices.Equal(e.NotRunning[0].Machines, []string{"ace"}) {
|
||||
t.Errorf("pipeline-wanted tier-late = %+v, want cache on ace not running", e)
|
||||
}
|
||||
lateKey := views.FindingKey(mconds.ScopeDelivery, assign.KeyID(late), kindTierLate)
|
||||
if raw := b.get(t, assign.FindingsBucket(), lateKey); !strings.Contains(string(raw), "cache on ace") {
|
||||
t.Errorf("the finding tier-late = %s", raw)
|
||||
}
|
||||
if b.hasKey(buckets.Wants(), "want.ace.api") {
|
||||
t.Error("api, tier 2 of a late pipeline, is wanted")
|
||||
}
|
||||
for _, node := range []string{"ace", "g14"} {
|
||||
if got := b.versionsOf(t, node, "db"); !slices.Equal(got, []string{"1.0.0", "1.2.0"}) {
|
||||
t.Errorf("%s's want of db named %v, want 1.0.0 then 1.2.0: no failed and no older version", node, got)
|
||||
}
|
||||
}
|
||||
|
||||
// §750, H-A-99: g14's placement names db's first build, which the builder made and the catalog released as 1.0.0: its want
|
||||
// names that build and version, with no pipeline and no rank, while ace stays at 1.2.0.
|
||||
made, _ := json.Marshal(builds.BuildEnded{Module: "db", Fingerprint: fpOf('2'), Outcome: builds.BuildDone, Made: map[string]string{"image": "sha256:d1"}})
|
||||
if _, err := b.js.Publish(b.ctx, process.ModuleStreamSubject(builds.BuilderModule, builds.BuildEndedEventName("db", fpOf('2'))), made); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
rel, _ := json.Marshal(meshcatalog.VersionReleasedEvent{Module: "db", Source: 5, Version: "1.0.0", Artifacts: []meshcatalog.VersionArtifact{{Artifact: "db:image", Digest: "sha256:d1"}}})
|
||||
if _, err := b.js.Publish(b.ctx, meshcatalog.SubjectVersionReleased, rel); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
b.placeBuild(t, "g14", "db", fpOf('2'))
|
||||
if w := b.wantNow(t, "g14", "db", "g14's want back at db's first build", func(w mwc.Want) bool { return w.Fp == fpOf('2') }); w.Version != "1.0.0" || w.Pipeline != "" || w.Rank != 0 {
|
||||
t.Errorf("g14's want of db at its placement's build = %+v", w)
|
||||
}
|
||||
if w := b.wantNow(t, "ace", "db", "ace's want of db", func(mwc.Want) bool { return true }); w.Version != "1.2.0" {
|
||||
t.Errorf("ace's want of db = %+v, want 1.2.0", w)
|
||||
}
|
||||
|
||||
wkey, _ := mwc.WantKey("ace", "web")
|
||||
// DLV-O5 (ADR 0615 §5, ADR 0619 §2): each want is said on the assigner's views family, its value whole at its revision.
|
||||
b.viewsHold(t, "wants", wkey)
|
||||
if keys, err := b.buckets[buckets.Differences()].Keys(b.ctx); err == nil && len(keys) != 0 {
|
||||
t.Errorf("differences were written: %v", keys)
|
||||
}
|
||||
if e, err := b.buckets[buckets.Wants()].Get(b.ctx, "want.g14.web"); err == nil {
|
||||
t.Errorf("g14, which runs an old-form build and is held back by the canary, was given a want: %s", e.Value())
|
||||
}
|
||||
|
||||
// 1945/AC21: once the canary ace runs F healthy, g14's first want names F by the rules as usual, and web leaves neither list
|
||||
// there by itself: the condition is cleared.
|
||||
healthyF, _ := nodeengineclient.EncodeHave(nodeengine.HaveByNodeModuleValue{Fp: fNew, Phase: nodeengineclient.PhaseRunning, Health: nodeengineclient.HealthOK})
|
||||
b.putJSON(t, buckets.Have, "ace.web", healthyF)
|
||||
if w := b.wantNow(t, "g14", "web", "g14's first want at F once the canary runs it healthy", func(w mwc.Want) bool { return w.Fp != "" }); w.Fp != fNew || !w.Self {
|
||||
t.Errorf("g14's want = %+v, want F, the node composing it", w)
|
||||
// Issue 1126 (ADR 0547 §2): placed through the catalogue's assignments, ace composes its own: its own want says so.
|
||||
values, err := mmac.AssignmentsValues(mma.Assignments{Node: "ace", Modules: []mma.PlacedModule{{Module: "web"}}})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
cleared := false
|
||||
for deadline := time.Now().Add(10 * time.Second); time.Now().Before(deadline) && !cleared; time.Sleep(100 * time.Millisecond) {
|
||||
c, ok := b.conditionsSaid(t)[neither.Key]
|
||||
cleared = ok && c.State == occ.StateCleared
|
||||
}
|
||||
if !cleared {
|
||||
t.Errorf("the condition of web on neither list on g14 was not cleared once g14 got its want")
|
||||
}
|
||||
|
||||
// Issue 1126 (ADR 0547 §2): the catalogue's assignments reaches the indexer's state naming web on every node the
|
||||
// assignments name it on. Each node then composes its own: its want names the build alone (Self, no composition), and
|
||||
// its own want says it composes its own, which the node agent reads (mesh-host's TestNats...ComposesAndAppliesItsOwn).
|
||||
for _, node := range []string{"ace", "g14", "shanks"} {
|
||||
values, err := mmac.AssignmentsValues(mma.Assignments{Node: node, Modules: []mma.PlacedModule{{Module: "web"}}})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, k := range slices.Sorted(maps.Keys(values)) {
|
||||
b.putJSON(t, plc.AssignmentsBucket(), k, values[k])
|
||||
}
|
||||
}
|
||||
if w := b.wantNow(t, "ace", "web", "ace's want once placed: the build alone, composed by the node", func(w mwc.Want) bool { return w.Self }); w.Fp != fNew {
|
||||
t.Errorf("ace's want once placed = %+v", w)
|
||||
for _, k := range slices.Sorted(maps.Keys(values)) {
|
||||
b.putJSON(t, plc.AssignmentsBucket(), k, values[k])
|
||||
}
|
||||
nkey, _ := mwc.WantNodeKey("ace")
|
||||
var self bool
|
||||
@@ -704,63 +851,8 @@ func TestWantsAreWrittenAndNoDifferenceIs(t *testing.T) {
|
||||
t.Error("ace's own want does not say it composes its own once placed")
|
||||
}
|
||||
|
||||
// ADR 0603 (L3, D15): one source revision changes a provider (db), its new consumer (app) and a build module (tool, whose
|
||||
// recipe moved: ace runs its first build and the second, under the agreed toolchain, is the one the source revision names).
|
||||
// The keys are written as their writers write them: the indexer's modules and manifests, the builder's builds, the
|
||||
// controller's grants, the assignments seat's assignments and the provisioner's provisions. The build module's want moves at
|
||||
// once and the provider's with it; the consumer's waits for its provision, with the words naming it, and moves once the
|
||||
// provisioner provides it (rule 8, ADR 0570 §4): nothing waits for a turn or an order, only for a key.
|
||||
offer := `"provides":[{"name":"database","scope":"mesh","answered-by":"helper"}]`
|
||||
dbDigest := b.manifest(t, "db", `{"module":"db","version":"1",`+offer+`}`)
|
||||
appDigest := b.manifest(t, "app", `{"module":"app","version":"1","requires":["database"]}`)
|
||||
toolDigest := b.manifest(t, "tool", `{"module":"tool","version":"1"}`)
|
||||
asked := func(state, why string) {
|
||||
raw, err := meshprovisionerclient.Encode(meshprovisionerclient.Provision{V: meshprovisionerclient.Version, Provision: "database", Consumer: meshprovisionerclient.End{Module: "app", Node: "ace"},
|
||||
Provider: meshprovisionerclient.End{Module: "db", Node: "ace"}, State: state, Why: why, At: time.Now()})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
b.putJSON(t, "mesh-provisioner_provisions", "ace.app.database", raw)
|
||||
}
|
||||
// The provisioner keys it from the manifests, as soon as they are known and whether the provider is placed yet or not.
|
||||
asked(meshprovisionerclient.Asked, "the provider's build is not done")
|
||||
fpOf := func(c byte) string { return meshcatalogclient.SourcePrefix2 + strings.Repeat(string(c), 64) }
|
||||
toolOld := fpOf('1')
|
||||
for module, row := range map[string]struct {
|
||||
fp, digest string
|
||||
}{"db": {fpOf('2'), dbDigest}, "app": {fpOf('3'), appDigest}, "tool": {fpOf('4'), toolDigest}} {
|
||||
mod, _ := meshcatalogclient.EncodeModule(meshcatalog.ModulesByModuleValue{Fp2: row.fp, Manifest: row.digest, Repository: "novox/" + module, Commit: strings.Repeat("2", 40), Path: meshcatalogclient.RootPath})
|
||||
b.putModule(t, module, mod)
|
||||
fps := []string{row.fp}
|
||||
if module == "tool" {
|
||||
fps = append(fps, toolOld)
|
||||
}
|
||||
for _, fp := range fps {
|
||||
built, _ := builds.EncodeBuilderBuild(builds.BuilderBuild{State: builds.BuildDone, By: "builder.novox.1", Step: "pushed", Manifest: row.digest})
|
||||
bkey, _ := builds.BuilderBuildKey(module, fp)
|
||||
b.putBuild(t, bkey, built)
|
||||
gkey, _ := grantsstate.PartGrantKey(module, fp)
|
||||
grant, _ := grantsstate.EncodeGrant(grantsstate.Grant{})
|
||||
b.putJSON(t, buckets.Grants, gkey, grant)
|
||||
}
|
||||
b.place(t, "ace", module)
|
||||
}
|
||||
runsOld, _ := nodeengineclient.EncodeHave(nodeengine.HaveByNodeModuleValue{Fp: toolOld, Phase: nodeengineclient.PhaseRunning, Health: nodeengineclient.HealthOK})
|
||||
b.putJSON(t, buckets.Have, "ace.tool", runsOld)
|
||||
if w := b.wantNow(t, "ace", "tool", "the build module's want at the second build", func(w mwc.Want) bool { return w.Fp == fpOf('4') }); w.Fp != fpOf('4') {
|
||||
t.Errorf("tool's want = %+v", w)
|
||||
}
|
||||
b.wantNow(t, "ace", "db", "the provider's want at its fingerprint", func(w mwc.Want) bool { return w.Fp == fpOf('2') })
|
||||
if e, err := b.buckets[buckets.Wants()].Get(b.ctx, "want.ace.app"); err == nil {
|
||||
t.Errorf("app was wanted while its provision was asked: %s", e.Value())
|
||||
}
|
||||
asked(meshprovisionerclient.Provided, "")
|
||||
if w := b.wantNow(t, "ace", "app", "the consumer's want once its provision is provided", func(w mwc.Want) bool { return w.Fp == fpOf('3') }); w.Fp != fpOf('3') {
|
||||
t.Errorf("app's want = %+v", w)
|
||||
}
|
||||
|
||||
// Design 47 H-A-104: ace's engine says manifest-reads-changed; the assigner writes its words and when it said them into
|
||||
// its state engine-reads, asking no verb; g14's engine said nothing, so the state holds no key of it.
|
||||
// Design 47 H-A-104: ace's engine says manifest-reads-changed again; the assigner writes its words and when it said them into
|
||||
// its state engine-reads, asking no verb; shanks' engine said nothing, so the state holds no key of it.
|
||||
watch, err := b.buckets[engineReadsBucket()].Watch(b.ctx, "ace", jetstream.UpdatesOnly())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -780,8 +872,8 @@ func TestWantsAreWrittenAndNoDifferenceIs(t *testing.T) {
|
||||
case <-time.After(15 * time.Second):
|
||||
t.Fatal("the assigner did not write ace's words into its state engine-reads")
|
||||
}
|
||||
if _, err := b.buckets[engineReadsBucket()].Get(b.ctx, "g14"); err == nil {
|
||||
t.Error("the state engine-reads holds a key of g14, whose engine said nothing")
|
||||
if _, err := b.buckets[engineReadsBucket()].Get(b.ctx, "shanks"); err == nil {
|
||||
t.Error("the state engine-reads holds a key of shanks, whose engine said nothing")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -827,11 +919,14 @@ func (b *bed) conditionsSaid(t *testing.T) map[string]oc.Condition {
|
||||
|
||||
// 1906/D8 (scenario D of acceptance test 18, ADR 0539 §19), whole on the bus: the assigner is stopped while it writes the wants
|
||||
// of forty modules and another is started; every module's want is written, and each exactly once, by revision: nothing lost
|
||||
// and nothing written again.
|
||||
// and nothing written again. The wants follow one passed pipeline of the forty, all in tier 1 (design 47 H §750, §751).
|
||||
func TestTheAssignerReplacedResumesWithNothingLostOrRepeated(t *testing.T) {
|
||||
b := startBed(t, "")
|
||||
const modules = 40
|
||||
names := make([]string, modules)
|
||||
var movers []moverAt
|
||||
b.compose(t, "ace", 'c')
|
||||
b.readsVersion(t, "ace")
|
||||
for i := range names {
|
||||
name := fmt.Sprintf("mod%02d", i)
|
||||
names[i] = name
|
||||
@@ -839,18 +934,10 @@ func TestTheAssignerReplacedResumesWithNothingLostOrRepeated(t *testing.T) {
|
||||
digest := b.manifest(t, name, fmt.Sprintf(`{"module":%q,"version":"1"}`, name))
|
||||
mod, _ := meshcatalogclient.EncodeModule(meshcatalog.ModulesByModuleValue{Fp2: fp, Manifest: digest, Repository: "novox/" + name, Commit: strings.Repeat("1", 40), Path: meshcatalogclient.RootPath})
|
||||
b.putModule(t, name, mod)
|
||||
built, err := builds.EncodeBuilderBuild(builds.BuilderBuild{State: builds.BuildDone, By: "builder.novox.1", Step: "pushed", Manifest: digest})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
bkey, _ := builds.BuilderBuildKey(name, fp)
|
||||
b.putBuild(t, bkey, built)
|
||||
gkey, _ := grantsstate.PartGrantKey(name, fp)
|
||||
grant, _ := grantsstate.EncodeGrant(grantsstate.Grant{})
|
||||
b.putJSON(t, buckets.Grants, gkey, grant)
|
||||
b.compose(t, "ace", 'c')
|
||||
b.place(t, "ace", name)
|
||||
movers = append(movers, moverAt{name, fp, "1.0.0", 1})
|
||||
}
|
||||
b.ended(t, 3, mpr.PipelineEndedOutcomePassed, movers...)
|
||||
count := func() int {
|
||||
keys, err := b.buckets[buckets.Wants()].Keys(b.ctx)
|
||||
if err != nil {
|
||||
@@ -971,6 +1058,9 @@ func TestABackupAnswerIsWrittenIntoTheNodesWant(t *testing.T) {
|
||||
b.fixture(t, "web", fNew, `{"module":"web","version":"1"}`)
|
||||
fRun := meshcatalogclient.SourcePrefix2 + strings.Repeat("a", 64) // a held have names the build it keeps running
|
||||
b.compose(t, "ace", 'b')
|
||||
b.readsVersion(t, "ace")
|
||||
// The want follows the passed version (design 47 H §750).
|
||||
b.ended(t, 3, mpr.PipelineEndedOutcomePassed, moverAt{"web", fNew, "1.0.0", 1})
|
||||
b.putWant(t, "ace", "web", mwc.Want{Fp: fNew, Self: true}) // a placed node's want names the build alone
|
||||
held, _ := nodeengineclient.EncodeHave(nodeengine.HaveByNodeModuleValue{Fp: fRun, Phase: nodeengineclient.PhaseHeld, Health: nodeengineclient.HealthWaits, Detail: "no space left"})
|
||||
b.putJSON(t, buckets.Have, "ace.web", held)
|
||||
@@ -1015,10 +1105,11 @@ func TestABackupAnswerIsWrittenIntoTheNodesWant(t *testing.T) {
|
||||
if w2.Words == w1.Words {
|
||||
t.Errorf("the second answer left the want as it was: %+v", w2)
|
||||
}
|
||||
// Issue 1966 note 165 (AC165-1): the move is superseded, the trunk and then the want naming another build; the pass takes
|
||||
// Issue 1966 note 165 (AC165-1): the move is superseded, a newer passed version and then the want naming another build; the pass takes
|
||||
// the backup ask away and clears the condition of the failed backup.
|
||||
fOther := meshcatalogclient.SourcePrefix2 + strings.Repeat("c", 64)
|
||||
b.fixture(t, "web", fOther, `{"module":"web","version":"2"}`) // the trunk moves on: the want follows
|
||||
b.fixture(t, "web", fOther, `{"module":"web","version":"2"}`)
|
||||
b.ended(t, 4, mpr.PipelineEndedOutcomePassed, moverAt{"web", fOther, "2.0.0", 1}) // a newer version passed: the want follows
|
||||
for deadline := time.Now().Add(15 * time.Second); ; time.Sleep(50 * time.Millisecond) {
|
||||
cleared := false
|
||||
for k, c := range b.conditionsSaid(t) {
|
||||
@@ -1488,8 +1579,9 @@ func serveOwner(t *testing.T, b *bed, nc *nats.Conn, owner string, tools map[str
|
||||
|
||||
// firstViewsBeforeAnyNewFormState serves the assigner's first-view tools as its runtime of its own does (the tools bundle's
|
||||
// viewTools over the bed's buckets, the env its manifest's bundle writes, the caller the runtime proves from the subject's
|
||||
// last token), before any new-form state exists, and asks each from every reader granted and from the others.
|
||||
func firstViewsBeforeAnyNewFormState(t *testing.T, b *bed, granted map[string][]string) {
|
||||
// last token), before any new-form state exists, and asks each from every reader: every account is answered (design 47 H §752,
|
||||
// H-A-41: no seat or tool names its callers).
|
||||
func firstViewsBeforeAnyNewFormState(t *testing.T, b *bed, tools []string) {
|
||||
t.Helper()
|
||||
raw, err := os.ReadFile(filepath.Join("..", "..", "module.json"))
|
||||
if err != nil {
|
||||
@@ -1593,19 +1685,16 @@ func firstViewsBeforeAnyNewFormState(t *testing.T, b *bed, granted map[string][]
|
||||
}, tool)(b.ctx, "")
|
||||
}
|
||||
readers := []string{"n1.mesh-grants", "n1.node-tools", "n1.mesh-delivery-indexer", "n1.mesh-delivery-assigner", "n1.mesh-delivery-builder", "n1.mesh-delivery-checker", "n1.mesh-delivery-teller"}
|
||||
for tool, allowed := range granted {
|
||||
for _, tool := range tools {
|
||||
for _, user := range readers {
|
||||
a, err := ask(user, tool)
|
||||
switch {
|
||||
case slices.Contains(allowed, user) && err != nil:
|
||||
if err != nil {
|
||||
t.Errorf("%s's first view of %s before any new-form state: %v", user, tool, err)
|
||||
case slices.Contains(allowed, user):
|
||||
keys, _ := b.buckets[viewedStates()[tool]].Keys(b.ctx)
|
||||
if a.Owner != assignment.Module() || a.State != tool || len(a.Values) != len(keys) {
|
||||
t.Errorf("%s's first view of %s = %+v, the state holds %v", user, tool, a, keys)
|
||||
}
|
||||
case err == nil || !strings.Contains(err.Error(), "refused"):
|
||||
t.Errorf("%s, granted no first view of %s, was answered %+v, %v", user, tool, a, err)
|
||||
continue
|
||||
}
|
||||
keys, _ := b.buckets[viewedStates()[tool]].Keys(b.ctx)
|
||||
if a.Owner != assignment.Module() || a.State != tool || len(a.Values) != len(keys) {
|
||||
t.Errorf("%s's first view of %s = %+v, the state holds %v", user, tool, a, keys)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1679,6 +1768,15 @@ func serveCatalog(t *testing.T, b *bed, nc *nats.Conn) {
|
||||
_ = m.Respond([]byte(`{"result":{"none-yet":true},"node":"n0"}`))
|
||||
return
|
||||
}
|
||||
if kept, ok := b.cat.at[branch][in.Revision]; ok {
|
||||
rev := meshcatalog.CatalogRevision{Kind: "trunk", Branch: in.Branch, Revision: in.Revision}
|
||||
for _, e := range kept {
|
||||
rev.Entries = append(rev.Entries, meshcatalog.EntryRef{Module: e.Module, Digest: e.ManifestDigest})
|
||||
}
|
||||
raw, _ := json.Marshal(map[string]any{"result": meshcatalog.RevisionAnswer{Revision: &rev, Entries: kept}, "node": "n0"})
|
||||
_ = m.Respond(raw)
|
||||
return
|
||||
}
|
||||
rev := meshcatalog.CatalogRevision{Kind: "trunk", Branch: in.Branch, Revision: b.cat.rev[branch]}
|
||||
var entries []meshcatalog.CatalogEntry
|
||||
for _, name := range slices.Sorted(maps.Keys(b.cat.entries[branch])) {
|
||||
|
||||
@@ -300,5 +300,9 @@ func (p *passer) tierDeadline(at time.Time) {
|
||||
// with the content ${config:tier-bound}; zero, its default, for a file missing or empty.
|
||||
func tierBoundSetting(getenv func(string) string) (time.Duration, error) {
|
||||
minutes, err := settingFile(getenv("MESH_ASSIGNER_TIER_BOUND_FILE"))
|
||||
return time.Duration(minutes) * time.Minute, err
|
||||
return time.Duration(minutes) * tierBoundUnit, err
|
||||
}
|
||||
|
||||
// tierBoundUnit is the unit of the setting tier-bound, a minute; the whole test sets a shorter one, so a tier passes its bound
|
||||
// without a test waiting minutes.
|
||||
var tierBoundUnit = time.Minute
|
||||
|
||||
Reference in New Issue
Block a user