With no plan left to name a build or a send to keep the plans, a want names what a collection must keep, and the composition is where the provisioner's plans are composed for the assignments mirror (ADR 0539 clauses 1 and 5); the assignments no longer name a node's build, so the controller replaced is the newest earlier build of it.
38 lines
1.6 KiB
Go
38 lines
1.6 KiB
Go
package inventory
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
// 1945 (dev-r6-controller's finding, for ADR 0539 clause 1): with no plan left to name a build, the builds of every
|
|
// fingerprint a want names are kept: a collection never lets go of what a node is told to run. A build of a
|
|
// fingerprint no want names, one of another module at that fingerprint, and a failed one keep nothing this way.
|
|
func TestTheBuildsOfAWantedFingerprintAreKept(t *testing.T) {
|
|
fp := "src2:" + strings.Repeat("a", 64)
|
|
other := "src2:" + strings.Repeat("b", 64)
|
|
at := time.Date(2026, 10, 1, 0, 0, 0, 0, time.UTC)
|
|
made := func(id, module, fingerprint, reference string) Build {
|
|
return Build{ID: id, Module: module, SourceFingerprint: fingerprint, At: at,
|
|
Made: []Artifact{{Name: "files", Kind: "archive", Reference: reference}}}
|
|
}
|
|
const (
|
|
wanted = "artifact-store://route-proxy/files/blobs/sha256:a1"
|
|
unwanted = "artifact-store://route-proxy/files/blobs/sha256:b2"
|
|
elsewise = "artifact-store://mesh-mail/files/blobs/sha256:c3"
|
|
)
|
|
builds := []Build{made("key-a-1", "route-proxy", fp, wanted), made("key-b-1", "route-proxy", other, unwanted),
|
|
made("key-c-1", "mesh-mail", fp, elsewise),
|
|
{ID: "failed", Module: "route-proxy", SourceFingerprint: fp, Failed: "no", Made: []Artifact{{Reference: "artifact-store://f@sha256:ff"}}}}
|
|
kept := keptByWants(builds, map[string]bool{"route-proxy " + fp: true})
|
|
if !has(kept[wanted], KeptByWant) {
|
|
t.Errorf("the archive of a wanted fingerprint is not kept: %v", kept)
|
|
}
|
|
for _, r := range []string{unwanted, elsewise, "artifact-store://f@sha256:ff"} {
|
|
if len(kept[r]) > 0 {
|
|
t.Errorf("%s is kept as wanted: %v", r, kept[r])
|
|
}
|
|
}
|
|
}
|