One build machine built everything, in a queue of one, because the seat was mesh-scoped and a mesh seat has one holder. ADR 0190 makes building a node role: node-build-agent, held on every machine that builds, with the work asked of the role and taken by whichever holder is idle. The work subject of a node-scoped seat carries no node — that token is for a seat's tools, asked of one machine (design 33 §4) — so holders on several machines read one queue; a test now says so. The retired mesh-build-machine row stays while the builder module's registered manifest claims it: a claim to a seat the mesh no longer defines is refused, and the machine holding it would be unresolvable until build-agent replaces it. Removed once no manifest claims it. The installer's genesis template (in the host's repository) still grants the controller the old seat's subjects; its test here says so until that template names node-build-agent.
65 lines
2.2 KiB
Go
65 lines
2.2 KiB
Go
package inventory
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/novox/mesh-controller/internal/catalogue"
|
|
)
|
|
|
|
// The catalogue's one dependency relation (novox/hq ADR 0162): four kinds of edge from one call.
|
|
func TestDependenciesAreOneRelationWithTheirKinds(t *testing.T) {
|
|
entry := func(name, repository string) Entry {
|
|
return Entry{Manifest: catalogue.Manifest{Module: name}, Source: Source{Repository: repository}}
|
|
}
|
|
builder := entry("builder", "http://forge/novox/mesh-catalog.git")
|
|
builder.Manifest.Claims = []catalogue.Claim{{Name: "node-build-agent", Scope: catalogue.ScopeNode}}
|
|
plugin := entry("shop-plugin", "http://forge/novox/mesh-catalog.git")
|
|
plugin.Manifest.Build = &catalogue.Build{On: []catalogue.BuildsOn{{Arg: "BASE", Module: "shop"}}}
|
|
entries := []Entry{
|
|
entry("mesh-tools", "http://forge/novox/mesh-tools.git"),
|
|
entry("shop", "http://forge/novox/mesh-catalog.git"),
|
|
plugin,
|
|
builder,
|
|
entry("mesh-controller", "http://forge/novox/mesh-controller.git"),
|
|
entry("route-proxy", "http://forge/novox/mesh-catalog.git"),
|
|
{Manifest: catalogue.Manifest{Module: "hand-made"}},
|
|
}
|
|
against := map[string][]string{
|
|
"shop": {catalogue.ArtifactStoreScheme + "mesh-tools/runtime@sha256:a"},
|
|
"builder": {catalogue.ArtifactStoreScheme + "mesh-tools/runtime@sha256:a"},
|
|
}
|
|
read := map[string][]ReadRepository{
|
|
"route-proxy": {{Repository: "http://forge/novox/mesh-controller.git", Ref: "main"}},
|
|
}
|
|
got := dependenciesOf(entries, against, read)
|
|
has := func(from, to, kind string) bool {
|
|
for _, e := range got {
|
|
if e == (Edge{From: from, To: to, Kind: kind}) {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
for _, want := range []Edge{
|
|
{"shop", "mesh-tools", EdgeStandsOn},
|
|
{"builder", "mesh-tools", EdgeStandsOn},
|
|
{"shop-plugin", "shop", EdgeDeclared},
|
|
{"route-proxy", "mesh-controller", EdgePackages},
|
|
{"shop", "builder", EdgeBuiltBy},
|
|
{"mesh-controller", "builder", EdgeBuiltBy},
|
|
{"mesh-tools", "builder", EdgeBuiltBy},
|
|
} {
|
|
if !has(want.From, want.To, want.Kind) {
|
|
t.Errorf("missing %+v in %+v", want, got)
|
|
}
|
|
}
|
|
if has("builder", "builder", EdgeBuiltBy) {
|
|
t.Error("the builder is not built by itself")
|
|
}
|
|
for _, e := range got {
|
|
if e.From == "hand-made" {
|
|
t.Errorf("a module with no source depends on nothing: %+v", e)
|
|
}
|
|
}
|
|
}
|