Files
mesh-delivery/modules/mesh-delivery-builder/buildrun/toolchains_test.go
T
jschoubben 18f978e852 BL8: the builder hears the build seats' toolchain-reported, keeps them in toolchains-heard and says toolchain-agreed with digests
The builder agrees a language's toolchain from the three build seats'
toolchain-reported, kept in its state toolchains-heard (read back at its start),
forgets a node's on the node-engine seat's running with no fingerprint (stopped)
and never on a placement, says toolchain-agreed with its digests list only when
the agreed version changes; builder_toolchains and builder_toolchains_drop;
the manifest's reads of the build modules' toolchains are gone. The gate over
the assignments is now PlacedNodes, which only counts nodes.

Builds: design 47 G §492, §604, §546, §472, §574
Claude-Session: https://claude.ai/code/session_01JG73KEq4zoDfM9WtYpcQgZ
2026-11-11 20:49:02 +01:00

50 lines
2.0 KiB
Go

package buildrun
import (
"reflect"
"testing"
"git.novox.be/novox/mesh-delivery/sdk/buildstep"
)
func tc(language, version, digest string) buildstep.Toolchain {
return buildstep.Toolchain{Language: language, Version: version, Recipe: "1", Digest: digest}
}
func TestToolchainSetKeepsEachNodesEntryByLanguageAndSaysWhenOneChanged(t *testing.T) { // 1607/AC6, design 47 G §604
var s ToolchainSet
if !s.Set("novox", tc("go", "go1.27.1", "sha256:a")) {
t.Error("a first entry did not count as a change")
}
if s.Set("novox", tc("go", "go1.27.1", "sha256:a")) {
t.Error("the same entry again counted as a change")
}
if !s.Set("novox", tc("go", "go1.27.1", "sha256:b")) {
t.Error("a new digest at one version did not count as a change")
}
s.Set("ace", tc("go", "go1.27.1", "sha256:b"))
s.Set("ace", tc("typescript", "tsc5", ""))
if got := s.Entries("go"); len(got) != 2 {
t.Errorf("go entries = %+v, want two", got)
}
if got := s.Entries("typescript"); len(got) != 1 || got[0].Node != "ace" || got[0].Version != "tsc5" {
t.Errorf("typescript entries = %+v", got)
}
if !s.Delete("ace", "go") || len(s.Entries("go")) != 1 || s.Delete("ace", "go") {
t.Error("a delete did not remove the node's entry once")
}
}
// Design 47 G §472, §574: the digests are those the nodes reporting the agreed version report, sorted, with their nodes.
func TestDigestsOfTheAgreedVersion(t *testing.T) {
entries := []buildstep.NodeToolchain{
{Node: "novox", Toolchain: tc("go", "1.26.0", "sha256:b")}, {Node: "ace", Toolchain: tc("go", "1.26.0", "sha256:a")},
{Node: "g14", Toolchain: tc("go", "1.26.0", "sha256:a")}, {Node: "shanks", Toolchain: tc("go", "1.25.0", "sha256:c")},
{Node: "old", Toolchain: tc("go", "1.26.0", "")}}
got := Digests(entries, tc("go", "1.26.0", ""))
want := []AgreedDigest{{Digest: "sha256:a", Nodes: []string{"ace", "g14"}}, {Digest: "sha256:b", Nodes: []string{"novox"}}}
if !reflect.DeepEqual(got, want) {
t.Errorf("digests = %+v, want %+v", got, want)
}
}