H5 (review r2, A-308, A-312): the shadow watches no indexer modules; it reads the entries its wants name and asks the verb module for a module a candidate adds
Builds: design 47 G §421, §628
This commit is contained in:
@@ -1127,6 +1127,34 @@ func TestTheNodeComposesItsWantsFromTheBus(t *testing.T) {
|
||||
"keeper": {Fp2: fp, Manifest: kdigest, Repository: "novox/k", Commit: "c"}}
|
||||
readOnly := &fakeBus{kv: map[string][]byte{buckets.Manifests + "/" + key: man, buckets.Manifests + "/" + kkey: kman}}
|
||||
senv := readOnly.env()
|
||||
// The catalog half: lemurs's entry, which its want names, and keeper's, which a candidate adding it asks by the verb module
|
||||
// (design 47 G §421, A-308, A-312). The shadow watches no modules.
|
||||
kfp := meshcatalogclient.SourcePrefix2 + strings.Repeat("c", 64)
|
||||
entryOfManifest := func(module, fp, body string) meshcatalog.CatalogEntry {
|
||||
var m map[string]any
|
||||
if err := json.Unmarshal([]byte(body), &m); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
return meshcatalog.CatalogEntry{Module: module, Fp: fp, Manifest: m, Repository: "novox/x", Commit: "c", ManifestDigest: meshcatalogclient.ManifestDigest([]byte(body))}
|
||||
}
|
||||
catalogEntries := map[string]meshcatalog.CatalogEntry{fp: entryOfManifest("lemurs", fp, lemurs), kfp: entryOfManifest("keeper", kfp, keeper)}
|
||||
senv.Entry = EntryCall(func(_ context.Context, _, verb string, args any) (json.RawMessage, error) {
|
||||
switch in := args.(type) {
|
||||
case meshcatalog.ModuleInput:
|
||||
for _, e := range catalogEntries {
|
||||
if e.Module == in.Module {
|
||||
return json.Marshal(meshcatalog.ModuleAnswer{Module: meshcatalog.ModuleAnswerModule{Module: e.Module, Repository: e.Repository, Commit: e.Commit, Fp: e.Fp}})
|
||||
}
|
||||
}
|
||||
return nil, fmt.Errorf("the catalog holds no module %s", in.Module)
|
||||
case meshcatalog.EntryInput:
|
||||
if e, ok := catalogEntries[in.Fingerprint]; ok {
|
||||
return json.Marshal(meshcatalog.EntryAnswer{Entry: e})
|
||||
}
|
||||
return nil, errors.New("no entry of fingerprint " + in.Fingerprint + " is kept")
|
||||
}
|
||||
return nil, fmt.Errorf("asked %s of %T", verb, args)
|
||||
})
|
||||
senv.Watch = sb.watch
|
||||
var ownFails atomic.Bool // the vault's own on a bus that does not answer (2026-10-28, ace's answer to seed-7)
|
||||
senv.Own = func(context.Context, map[string]any) (json.RawMessage, error) {
|
||||
@@ -1177,10 +1205,6 @@ func TestTheNodeComposesItsWantsFromTheBus(t *testing.T) {
|
||||
tp := assignedValues(t, trunk)
|
||||
sb.putAssigned(tp, 1)
|
||||
sb.put(buckets.Have, "n1.node", rec, 1)
|
||||
for name, m := range mods {
|
||||
raw, _ := meshcatalogclient.EncodeModule(m)
|
||||
sb.put(buckets.Modules, name, raw, 1)
|
||||
}
|
||||
wantLemurs := meshwants.WantsByWantNodeModuleKey("n1", "lemurs")
|
||||
var lemursDigest string
|
||||
for _, c := range running {
|
||||
@@ -1244,12 +1268,18 @@ func TestTheNodeComposesItsWantsFromTheBus(t *testing.T) {
|
||||
}
|
||||
}
|
||||
waitFor("every group answered", func(a map[string]nodeengine.CandidateAnswer) bool { return len(a) == 6 })
|
||||
// keeper, which the candidate adds and no want names, is asked of the catalog half (its entry by the verb entry after the verb
|
||||
// module): the answer waits for it, and is the same as before the shadow watched no modules once it comes (A-312).
|
||||
waitFor("the added module's entry answered", func(a map[string]nodeengine.CandidateAnswer) bool { return len(a["adds"].Added) == 1 })
|
||||
// Every watch and get the shadow makes is one the node's grant allows (issue 1126, 2026-10-27 09:21).
|
||||
sb.mu.Lock()
|
||||
for _, w := range sb.watches {
|
||||
if !grantAllows(t, "n1", w.bucket, w.pattern) {
|
||||
t.Errorf("the shadow watches %s of %s, which the node's grant does not allow", w.pattern, w.bucket)
|
||||
}
|
||||
if w.bucket == buckets.Modules {
|
||||
t.Errorf("the shadow watches the indexer's modules (%s), which design 47 G A-308 ends", w.pattern)
|
||||
}
|
||||
}
|
||||
sb.mu.Unlock()
|
||||
readOnly.mu.Lock()
|
||||
@@ -1334,8 +1364,7 @@ func TestTheNodeComposesItsWantsFromTheBus(t *testing.T) {
|
||||
lemursHave("its tool lemurs_health: no answer within 10s", 11)
|
||||
lemursHave("its tool lemurs_health: no answer within 20s", 12)
|
||||
sb.putAssigned(tp, 2)
|
||||
lraw, _ := meshcatalogclient.EncodeModule(mods["lemurs"])
|
||||
sb.put(buckets.Modules, "lemurs", lraw, 2)
|
||||
sb.put(buckets.Wants, wantLemurs, wantRaw, 2)
|
||||
drain()
|
||||
if got := answering(); got != settled {
|
||||
t.Errorf("answered %d more time(s) with no candidate revision and no input of the node changed", got-settled)
|
||||
@@ -1393,7 +1422,7 @@ func TestTheNodeComposesItsWantsFromTheBus(t *testing.T) {
|
||||
// Review of L2b, round 2: a watch ends while the link stays; a group's key is deleted before the shadow watches
|
||||
// again. The new run reads afresh, so that group is no longer answered.
|
||||
sb.missing(buckets.ProposalCandidates, true)
|
||||
sb.end(buckets.Modules)
|
||||
sb.end(buckets.Wants)
|
||||
dropsKey := meshmoduleassigner.CandidatesByProposalNodeKey("drops", "n1")
|
||||
sb.del(buckets.ProposalCandidates, dropsKey)
|
||||
time.Sleep(30 * time.Millisecond)
|
||||
@@ -1428,6 +1457,7 @@ func TestTheNodeComposesItsWantsFromTheBus(t *testing.T) {
|
||||
nenv := readOnly.env()
|
||||
nenv.Watch = nb.watch
|
||||
nenv.Running = senv.Running
|
||||
nenv.Entry = senv.Entry
|
||||
var nsaid []string
|
||||
var nmu sync.Mutex
|
||||
nenv.Say = func(l string) { nmu.Lock(); nsaid = append(nsaid, l); nmu.Unlock() }
|
||||
@@ -1439,10 +1469,7 @@ func TestTheNodeComposesItsWantsFromTheBus(t *testing.T) {
|
||||
nb.made(6)
|
||||
nb.putAssigned(tp, 1)
|
||||
nb.put(buckets.Have, "n1.node", rec, 1)
|
||||
for name, m := range mods {
|
||||
raw, _ := meshcatalogclient.EncodeModule(m)
|
||||
nb.put(buckets.Modules, name, raw, 1)
|
||||
}
|
||||
nb.put(buckets.Wants, wantLemurs, wantRaw, 1)
|
||||
sameRaw, _ := bucketstest.Candidate(meshmoduleassigner.CandidatesByProposalNodeValue{Proposal: "same", Assignments: &trunk})
|
||||
sameKey := meshmoduleassigner.CandidatesByProposalNodeKey("same", "n1")
|
||||
nb.put(buckets.ProposalCandidates, sameKey, sameRaw, 3)
|
||||
@@ -1450,7 +1477,7 @@ func TestTheNodeComposesItsWantsFromTheBus(t *testing.T) {
|
||||
oldRaw, _ := bucketstest.Candidate(meshmoduleassigner.CandidatesByProposalNodeValue{Proposal: "older", Assignments: &trunk})
|
||||
oldKey := meshmoduleassigner.CandidatesByProposalNodeKey("older", "n1")
|
||||
nb.put(buckets.ProposalCandidates, oldKey, oldRaw, 2)
|
||||
for _, bucket := range []string{buckets.ProposalCandidates, buckets.Assignments, buckets.Have, buckets.Modules, builds.BuilderBuildsBucket} {
|
||||
for _, bucket := range []string{buckets.ProposalCandidates, buckets.Assignments, buckets.Have, buckets.Wants, builds.BuilderBuildsBucket} {
|
||||
nb.send(bucket, agent.Update{Caught: true})
|
||||
}
|
||||
select {
|
||||
@@ -1825,7 +1852,7 @@ func TestAHaveSaysWhetherItsModuleRunsInsideTheNodesOwn(t *testing.T) {
|
||||
}
|
||||
s := &Shadow{c: c, ran: map[string]string{}}
|
||||
s.takeRan(agent.Update{Key: key, Value: value})
|
||||
if _, got := s.heldToday()["web"]; got != row.heldToday {
|
||||
if _, got := s.heldToday(nil)["web"]; got != row.heldToday {
|
||||
t.Errorf("web held today: %v, want %v", got, row.heldToday)
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user