MH-5: the whole test of the apply order against a real bus
A want of rank 2 whose composition is made first is held in a wait of step placing on the module of rank 1 of its pipeline; rank 1 is applied first, rank 2 after it, and the wait ends. Builds: design 47 H §771, §774; H-A-59 Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy
This commit is contained in:
@@ -357,6 +357,95 @@ func TestNatsANodeTheAssignmentsNameComposesAndAppliesItsOwn(t *testing.T) {
|
||||
h8back(t, b, assignment, resolved, candidates, hkey)
|
||||
}
|
||||
|
||||
// Design 47 H §771 (acceptance test 113, the node-engine's half): against a real bus, a want of rank 2 whose composition is made first
|
||||
// is held, in its have, in a wait of step placing on the module of rank 1 of its pipeline, and the node-engine applies the module of
|
||||
// rank 1 first and the module of rank 2 after it; the wait ends with the apply. The read apply-order answers the order meanwhile.
|
||||
func TestNatsAWantOfAHigherRankWaitsForTheLowerRankOfItsPipeline(t *testing.T) {
|
||||
b := newItBed(t)
|
||||
kvOf := func(bucket string) nats.KeyValue {
|
||||
kv, err := b.js.CreateKeyValue(&nats.KeyValueConfig{Bucket: bucket, History: 5})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
return kv
|
||||
}
|
||||
assignment, manifests := kvOf(buckets.Assignments), kvOf(buckets.Manifests)
|
||||
kvOf(selfcompose.ResolvedBucket)
|
||||
kvOf(buckets.ProposalCandidates)
|
||||
kvOf(link.PackagesBucket)
|
||||
manifest := func(module string) string {
|
||||
return `{"module":"` + module + `","version":"1","resources":[{"id":"conf","type":"file","path":"` +
|
||||
filepath.Join(b.dir, module+".conf") + `","mode":"0644","content":"` + module + `\n"}]}`
|
||||
}
|
||||
rec, _ := nec.EncodeHaveNode(nodeengine.HaveByNodeNodeValue{Record: &nodeengine.NodeRecord{Node: itNode, Capabilities: []string{"service-manager", "package-manager"}}})
|
||||
hkey, _ := nec.HaveNodeKey(itNode)
|
||||
if _, err := b.haves.Put(hkey, rec); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
pipeline := "main.7"
|
||||
fps := map[string]string{"first": fpIt("a"), "second": fpIt("b")}
|
||||
ranks := map[string]int64{"first": 1, "second": 2}
|
||||
for module, fp := range fps {
|
||||
man := manifest(module)
|
||||
mraw, _ := meshcatalogclient.EncodeManifest(meshcatalog.ManifestsByDigestValue{Module: module, Manifest: man})
|
||||
mkey, _ := meshcatalogclient.ManifestsKey(meshcatalogclient.ManifestDigest([]byte(man)))
|
||||
if _, err := manifests.Put(mkey, mraw); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
raw, err := bucketstest.Want(meshwants.WantsByWantNodeModuleValue{Fp: fp, Self: true, Pipeline: pipeline, Rank: ranks[module]})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := b.wants.Put(meshwants.WantsByWantNodeModuleKey(itNode, module), raw); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
// Only the entry of the module of rank 2 is held: its composition is made first.
|
||||
b.registerEntry("second", fps["second"], manifest("second"))
|
||||
places, _ := meshmoduleassignerclient.AssignmentsValues(meshmoduleassigner.Assignments{Node: itNode,
|
||||
Modules: []meshmoduleassigner.PlacedModule{{Module: "first"}, {Module: "second"}}})
|
||||
stop := b.start()
|
||||
defer stop()
|
||||
for key, value := range places {
|
||||
if _, err := assignment.Put(key, value); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
within(t, 10*time.Second, "the module of rank 2 is not held in a wait of step placing on the module of rank 1", func() bool {
|
||||
h := b.have("second")
|
||||
return h.Phase == nec.PhaseHeld && h.Wait != nil && h.Wait.Step == nodeengine.WaitStepPlacing && h.Wait.On == "first"
|
||||
})
|
||||
if b.file("second") != "" {
|
||||
t.Fatal("the module of rank 2 was applied before the module of rank 1")
|
||||
}
|
||||
b.registerEntry("first", fps["first"], manifest("first"))
|
||||
if err := composerNow.Load().EntryAgain(context.Background(), fps["first"]); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
within(t, 10*time.Second, "the modules of both ranks are not applied", func() bool { return b.file("first") != "" && b.file("second") != "" })
|
||||
within(t, 5*time.Second, "the wait of the module of rank 2 does not end", func() bool {
|
||||
h := b.have("second")
|
||||
return h.Phase == nec.PhaseRunning && h.Wait == nil
|
||||
})
|
||||
// The first have saying a module runs is the order of the applies: the stream's sequence is the bus's own.
|
||||
runningAt := func(module string) uint64 {
|
||||
key, _ := nec.HaveKey(itNode, module)
|
||||
history, err := b.haves.History(key)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, e := range history {
|
||||
if h, err := nec.DecodeHave(e.Value()); err == nil && h.Phase == nec.PhaseRunning && h.Fp == fps[module] {
|
||||
return e.Revision()
|
||||
}
|
||||
}
|
||||
return 0
|
||||
}
|
||||
if first, second := runningAt("first"), runningAt("second"); first == 0 || second == 0 || first > second {
|
||||
t.Fatalf("the first have saying a module runs is at %d for rank 1 and %d for rank 2: rank 1 is applied first", first, second)
|
||||
}
|
||||
}
|
||||
|
||||
// h8once is issue 1126, 2026-10-28 (shanks answered probe/1126-seed-7 at revision 84 every 13-17 s, its bus flooded):
|
||||
// a candidate revision is answered once. The node's own answer written, a module's have whose health words alone move
|
||||
// (each look rewrites them) and a config value written again with the value it held answer nothing again; the
|
||||
|
||||
Reference in New Issue
Block a user