Files
mesh-host/internal/compose/resolution/toolchain_manifests_test.go
T
jschoubben d581acdeda
mesh/delivery merged: source.main moved to novox/mesh-host@783a2d22073f
mesh/delivery-group group fix/1966-call-made-once merged: every member is merged
mesh/check checking d581acdedae3 on 783a2d22073f | novox/mesh-host#222 in group fix/1966-call-made-once
H4: the builder machine of the toolchain tests has the tool runner's seat-settle-delay (issue 1966; mesh-catalog's issue 1748, ADR 0664 §5)
Since mesh-catalog 6b8e7fc6 the build modules ask the capability seat-settle-delay of the machine, so on
the stand-in builder without it mesh-build-go and mesh-build-node were left out as unhostable and both
toolchain tests failed against the catalogue's main, on mesh-host's trunk as on this group's head.

Claude-Session: https://claude.ai/code/session_01JG73KEq4zoDfM9WtYpcQgZ
2026-11-10 05:57:04 +01:00

79 lines
2.9 KiB
Go

package resolution
import (
"strings"
"testing"
mcat "git.novox.be/novox/mesh-sdk/go/catalogue"
)
// builderNode is a machine that can run a build module: the package manager and user namespaces it asks of
// the machine, and the forge account (mesh-scope, provided by the forge) and the artifact store the build
// modules publish to (ADR 0513, provided by distribution) stood in for, and node-tools, the tool runner they pull their
// asks through (mesh-catalog issue 1911; mesh-tools' module, not in the catalogue), with the tool runner's
// seat-settle-delay the build modules ask of it since issue 1748 (ADR 0664 §5).
func builderNode() mcat.Node {
return mcat.Node{Name: "builder", Site: "house",
Capabilities: map[string]bool{"package-manager": true, "user-namespaces": true, "seat-settle-delay": true}}
}
func toolchainShelf(t *testing.T) map[string]mcat.Manifest {
t.Helper()
// The stand-in offers by name what the catalogue's forge offers, so a registry the forge gains is offered
// here too and never has to be added by hand, plus the two it stands in for that the forge does not offer.
offers := []mcat.Offer{{Name: "artifact-store"}, {Name: "node-tools"}}
for _, o := range catalogueManifest(t, "gitea").Provides {
offers = append(offers, mcat.Offer{Name: o.Name})
}
m := map[string]mcat.Manifest{
"forge": {Module: "forge", Version: "1", Provides: offers},
}
for _, name := range []string{"go", "nodejs", "mesh-build-go", "mesh-build-node", "dev-tools"} {
m[name] = catalogueManifest(t, name)
}
return m
}
func TestAModuleNeedingAToolchainIsRefusedOnANodeWithoutIt(t *testing.T) {
for _, c := range []struct{ module, provision string }{
{"mesh-build-go", "go-toolchain"},
{"mesh-build-node", "node-toolchain"},
{"dev-tools", "go-toolchain"},
} {
_, err := Resolve(toolchainShelf(t), []string{"forge", c.module}, builderNode(), mcat.World{})
if err == nil {
t.Fatalf("%s composed on a node with no toolchain module", c.module)
}
for _, want := range []string{`"` + c.provision + `" is wanted by ` + c.module,
"usable only on the machine that provides it"} {
if !strings.Contains(err.Error(), want) {
t.Errorf("%s: the refusal does not say %q:\n%v", c.module, want, err)
}
}
}
}
func TestAModuleNeedingAToolchainComposesOnANodeWithIt(t *testing.T) {
for _, c := range []struct{ module, owner string }{
{"mesh-build-go", "go"},
{"mesh-build-node", "nodejs"},
{"dev-tools", "go"},
} {
assigned := []string{"forge", c.owner, c.module}
if c.module == "dev-tools" {
assigned = append(assigned, "nodejs")
}
got, err := Resolve(toolchainShelf(t), assigned, builderNode(), mcat.World{})
if err != nil {
t.Fatalf("%s with %s did not compose: %v", c.module, c.owner, err)
}
in := map[string]bool{}
for _, n := range names(got) {
in[n] = true
}
if !in[c.module] || !in[c.owner] {
t.Errorf("%s with %s composed %v", c.module, c.owner, names(got))
}
}
}