Rows for the composer's composition of today: the same inputs give the running digest, a changed input another, a build it cannot compose none (ADR 0601 §1; review round 1, finding 2)

This commit is contained in:
2026-11-03 14:02:01 +01:00
parent 7da4deb3f1
commit 2239fb253d
+25
View File
@@ -268,6 +268,31 @@ func TestTheNodeComposesItsWantsFromTheBus(t *testing.T) {
b.mu.Unlock()
t.Fatalf("handed %v, want %s and %s", got, lemursKey, nodeKey)
}
// ADR 0601 §1: the module composed today at the build it runs, as the agent compares it with what runs. The same inputs give
// the digest handed; a changed input (here its manifest's service, as a changed setting would change a file) another; a
// build that cannot be composed (no done build or manifest of it: held) gives none.
c.mu.Lock()
handedDig := c.handed[lemursKey]
c.mu.Unlock()
if dig, ok := c.ComposedToday(ctx, "lemurs", fp); !ok || dig != handedDig {
t.Errorf("composed today at the build it runs: %s %v, want %s", dig, ok, handedDig)
}
if dig, ok := c.ComposedToday(ctx, "lemurs", delivery.SourcePrefix2+strings.Repeat("9", 64)); ok {
t.Errorf("a build that cannot be composed was composed today: %s", dig)
}
chgJSON := strings.Replace(lemurs, `"state":"running"`, `"state":"stopped"`, 1)
chgDigest := delivery.ManifestDigest([]byte(chgJSON))
chgMan, _ := delivery.EncodeManifest(delivery.Manifest{Module: "lemurs", JSON: chgJSON})
chgKey, _ := delivery.ManifestsKey(chgDigest)
b.mu.Lock()
b.kv[delivery.ManifestsBucket+"/"+chgKey] = chgMan
b.mu.Unlock()
chgMod, _ := delivery.EncodeModule(delivery.Module{FP2: fp, Manifest: chgDigest, Repository: "novox/x", Commit: "c"})
c.takeModule(agent.Update{Key: "lemurs", Value: chgMod})
if dig, ok := c.ComposedToday(ctx, "lemurs", fp); !ok || dig == handedDig {
t.Errorf("composed today with a changed input: %s %v, want another digest than %s", dig, ok, handedDig)
}
c.takeModule(agent.Update{Key: "lemurs", Value: mod})
// Issue 1126, the switch made safe: a bus not answering for a moment (a reload of its accounts) is tried again and
// refuses nothing; a pass whose run ended refuses nothing either.