A-471: a build toolchain is agreed by its language version, not its patch #248
@@ -20,7 +20,7 @@ func tcs(language, version string, nodes ...string) []buildstep.NodeToolchain {
|
||||
}
|
||||
|
||||
func chooseTakesTheAgreedNodesWithFewestRunningStepsTiesByName(t *testing.T) { // 1607/AC4, ADR 0478 clause 3
|
||||
entries := tcs("go", "go1.27.1", "novox", "ace", "g14", "shanks")
|
||||
entries := tcs("go", "go1.27", "novox", "ace", "g14", "shanks")
|
||||
nodes, tc, err := ChooseNodes("go", entries, placesRunning(map[string]int{"novox": 3, "ace": 1, "g14": 1, "shanks": 0}), nil, 2)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -28,13 +28,13 @@ func chooseTakesTheAgreedNodesWithFewestRunningStepsTiesByName(t *testing.T) { /
|
||||
if len(nodes) != 2 || nodes[0] != "shanks" || nodes[1] != "ace" {
|
||||
t.Errorf("nodes = %v, want [shanks ace]: fewest steps first, a tie by name", nodes)
|
||||
}
|
||||
if tc.Version != "go1.27.1" || tc.Recipe != "1" || tc.Language != "go" {
|
||||
if tc.Version != "go1.27" || tc.Recipe != "1" || tc.Language != "go" {
|
||||
t.Errorf("toolchain = %+v", tc)
|
||||
}
|
||||
}
|
||||
|
||||
func chooseWithOneNodeAnswersOneNode(t *testing.T) { // 1607/AC4
|
||||
nodes, _, err := ChooseNodes("go", tcs("go", "go1.27.1", "novox"), nil, nil, 2)
|
||||
nodes, _, err := ChooseNodes("go", tcs("go", "go1.27", "novox"), nil, nil, 2)
|
||||
if err != nil || len(nodes) != 1 || nodes[0] != "novox" {
|
||||
t.Errorf("nodes = %v, err %v, want [novox]", nodes, err)
|
||||
}
|
||||
@@ -45,9 +45,9 @@ func chooseFailsNamingTheLanguageAndTheVersionsWhenNoNodeQualifies(t *testing.T)
|
||||
if err == nil || !strings.Contains(err.Error(), "typescript") || !strings.Contains(err.Error(), buildstep.ToolchainNoReport) {
|
||||
t.Errorf("no report: error = %v, want it to name typescript and %q", err, buildstep.ToolchainNoReport)
|
||||
}
|
||||
entries := append(tcs("go", "go1.27.1", "novox"), tcs("go", "go1.26.0", "ace")...)
|
||||
entries := append(tcs("go", "go1.27", "novox"), tcs("go", "go1.26.0", "ace")...)
|
||||
_, _, err = ChooseNodes("go", entries, nil, nil, 2)
|
||||
if err == nil || !strings.Contains(err.Error(), "go1.27.1") || !strings.Contains(err.Error(), "go1.26.0") || !strings.Contains(err.Error(), "go") {
|
||||
if err == nil || !strings.Contains(err.Error(), "go1.27") || !strings.Contains(err.Error(), "go1.26") || !strings.Contains(err.Error(), "go") {
|
||||
t.Errorf("disagreeing nodes: error = %v, want both versions named", err)
|
||||
}
|
||||
}
|
||||
@@ -67,17 +67,17 @@ func agreeNeedsEqualDigestsAndNamesBothNodesWhenTheyDiffer(t *testing.T) { // 16
|
||||
}
|
||||
|
||||
func chooseSkipsNodesThatAreNotOnlineAndFailsNamingThemWhenNoneIs(t *testing.T) { // 1607 review 3, ADR 0478 clause 3
|
||||
entries := tcs("go", "go1.27.1", "ace", "g14", "novox")
|
||||
entries := tcs("go", "go1.27", "ace", "g14", "novox")
|
||||
online := func(n string) bool { return n != "g14" } // a sleeping laptop
|
||||
nodes, tc, err := ChooseNodes("go", entries, placesRunning(map[string]int{"novox": 5}), online, 2)
|
||||
if err != nil || len(nodes) != 2 || nodes[0] != "ace" || nodes[1] != "novox" || tc.Version != "go1.27.1" {
|
||||
if err != nil || len(nodes) != 2 || nodes[0] != "ace" || nodes[1] != "novox" || tc.Version != "go1.27" {
|
||||
t.Errorf("nodes = %v, toolchain %+v, err %v, want [ace novox] with g14 left out although it runs nothing", nodes, tc, err)
|
||||
}
|
||||
_, tc, err = ChooseNodes("go", entries, nil, func(string) bool { return false }, 2)
|
||||
if err == nil || !strings.Contains(err.Error(), "online") || !strings.Contains(err.Error(), "g14") || !strings.Contains(err.Error(), "go") {
|
||||
t.Errorf("none online: error = %v, want it to name the nodes that report and that none is online", err)
|
||||
}
|
||||
if tc.Version != "go1.27.1" {
|
||||
if tc.Version != "go1.27" {
|
||||
t.Errorf("none online: the agreed toolchain %+v is still answered", tc)
|
||||
}
|
||||
}
|
||||
@@ -88,7 +88,7 @@ func placesRunning(running map[string]int) *Places {
|
||||
}
|
||||
|
||||
func choosePrefersNodesBelowTheirCapacity(t *testing.T) { // round 3
|
||||
entries := tcs("go", "go1.27.1", "ace", "novox", "shanks")
|
||||
entries := tcs("go", "go1.27", "ace", "novox", "shanks")
|
||||
// shanks has capacity 3 with 2 running: room; ace has the default 1 with 1 running: none; novox has none running.
|
||||
p := placesRunning(map[string]int{"shanks": 2, "ace": 1})
|
||||
p.Capacity = map[string]int{"shanks": 3}
|
||||
|
||||
@@ -58,7 +58,7 @@ func TestToolchainGate(t *testing.T) {
|
||||
|
||||
t.Run("not placed on ace: its report is no builder's", func(t *testing.T) {
|
||||
gate, set, said := start(t, true)
|
||||
key, value := gateReport(t, "ace", "v26.12.0", old)
|
||||
key, value := gateReport(t, "ace", "v26.11.0", old)
|
||||
gate.Toolchain(testNode, key, value, false)
|
||||
if a := buildstep.ToolchainAgreement(set.Entries("typescript")); len(a.SittingOut) != 1 || a.SittingOut[0].Node != "ace" { // ADR 0584: the majority is agreed, ace's report counts as the one that sits out
|
||||
t.Fatalf("before the assignments is settled every report counts; got %+v", a)
|
||||
@@ -68,7 +68,7 @@ func TestToolchainGate(t *testing.T) {
|
||||
if !gate.Settled() {
|
||||
t.Fatal("settling left ace's report out, so what was passed on changed")
|
||||
}
|
||||
if v, none := agreedOf(set); v != "v26.12.1" || none != "" {
|
||||
if v, none := agreedOf(set); v != "v26.12" || none != "" {
|
||||
t.Fatalf("the placed nodes agree on v26.12.1; got %q, %q", v, none)
|
||||
}
|
||||
if len(*said) != 1 || !strings.Contains((*said)[0], "does not place mesh-build-node on ace") {
|
||||
@@ -80,14 +80,14 @@ func TestToolchainGate(t *testing.T) {
|
||||
// Placed on ace with a report written since: it counts, and the builders really disagree.
|
||||
k, v = placing(t, "ace", testGo, testNode)
|
||||
gate.Assignments(k, v, false, old.Add(-time.Minute))
|
||||
if a := buildstep.ToolchainAgreement(set.Entries("typescript")); a.Toolchain.Version != "v26.12.1" || len(a.SittingOut) != 1 || a.SittingOut[0].Version != "v26.12.0" {
|
||||
if a := buildstep.ToolchainAgreement(set.Entries("typescript")); a.Toolchain.Version != "v26.12" || len(a.SittingOut) != 1 || a.SittingOut[0].Version != "v26.11" {
|
||||
t.Fatalf("builders that run different versions: the majority is agreed and ace sits out; got %+v", a)
|
||||
}
|
||||
// Taken off ace again (its key deleted): its report goes again.
|
||||
if !gate.Assignments(k, nil, true, placed) {
|
||||
t.Fatal("taking ace's assignments away passed nothing on")
|
||||
}
|
||||
if v, none := agreedOf(set); v != "v26.12.1" || none != "" {
|
||||
if v, none := agreedOf(set); v != "v26.12" || none != "" {
|
||||
t.Fatalf("got %q, %q", v, none)
|
||||
}
|
||||
// A report deleted from the bucket goes whether its node is placed or not.
|
||||
@@ -131,7 +131,7 @@ func TestToolchainGate(t *testing.T) {
|
||||
if gate.Assignments(k, v, false, placed) {
|
||||
t.Fatal("assignments with no report passed something on")
|
||||
}
|
||||
key, value := gateReport(t, "ace", "v26.12.0", c.at)
|
||||
key, value := gateReport(t, "ace", "v26.11.0", c.at)
|
||||
if got := gate.Toolchain(testNode, key, value, false); got != c.counts {
|
||||
t.Fatalf("ace's report passed on: %v, want %v", got, c.counts)
|
||||
}
|
||||
@@ -143,7 +143,7 @@ func TestToolchainGate(t *testing.T) {
|
||||
if c.counts {
|
||||
return
|
||||
}
|
||||
if v, none := agreedOf(set); v != "v26.12.1" || none != "" {
|
||||
if v, none := agreedOf(set); v != "v26.12" || none != "" {
|
||||
t.Fatalf("ace's left report is no builder's; got %q, %q", v, none)
|
||||
}
|
||||
if len(*said) != 1 || !strings.Contains((*said)[0], "before mesh-build-node was placed on ace at 2026-10-25T19:56:45Z") {
|
||||
@@ -158,7 +158,7 @@ func TestToolchainGate(t *testing.T) {
|
||||
|
||||
t.Run("no assignments held: every report counts", func(t *testing.T) {
|
||||
gate, set, _ := start(t, false)
|
||||
key, value := gateReport(t, "ace", "v26.12.0", old)
|
||||
key, value := gateReport(t, "ace", "v26.11.0", old)
|
||||
gate.Toolchain(testNode, key, value, false)
|
||||
gate.Settled()
|
||||
if n := len(set.Entries("typescript")); n != 4 {
|
||||
@@ -183,7 +183,7 @@ func TestToolchainGate(t *testing.T) {
|
||||
for _, node := range append([]string{"ace"}, three...) {
|
||||
key, value := gateReport(t, node, "v26.12.1", placed.Add(time.Minute))
|
||||
if node == "ace" {
|
||||
key, value = gateReport(t, node, "v26.12.0", old)
|
||||
key, value = gateReport(t, node, "v26.11.0", old)
|
||||
}
|
||||
gate.Toolchain(testNode, key, value, false)
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ type AgreedDigest struct {
|
||||
func Digests(entries []buildstep.NodeToolchain, agreed buildstep.Toolchain) []AgreedDigest {
|
||||
by := map[string][]string{}
|
||||
for _, e := range entries {
|
||||
if e.Version == agreed.Version && e.Recipe == agreed.Recipe && e.Digest != "" {
|
||||
if buildstep.LanguageVersion(e.Version) == agreed.Version && e.Recipe == agreed.Recipe && e.Digest != "" {
|
||||
by[e.Digest] = append(by[e.Digest], e.Node)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ func TestDigestsOfTheAgreedVersion(t *testing.T) {
|
||||
{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", ""))
|
||||
got := Digests(entries, buildstep.ToolchainAgreement(entries[:4]).Toolchain)
|
||||
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)
|
||||
|
||||
@@ -369,7 +369,7 @@ func (b *bed) module(t *testing.T, name, fixture, path string) string {
|
||||
}
|
||||
|
||||
// bothToolchains are the toolchains the bed's nodes report, as a module's fingerprint names them.
|
||||
var bothToolchains = map[string]builds.ToolchainUsed{"go": {Version: "go1.27.1", Recipe: "1"}, "typescript": {Version: "tsc5", Recipe: "1"}}
|
||||
var bothToolchains = map[string]builds.ToolchainUsed{"go": {Version: "go1.27", Recipe: "1"}, "typescript": {Version: "tsc5", Recipe: "1"}}
|
||||
|
||||
// moduleWith is module with the toolchains its fingerprint was computed with.
|
||||
func (b *bed) moduleWith(t *testing.T, name, fixture, path string, toolchains map[string]builds.ToolchainUsed) string {
|
||||
@@ -546,7 +546,7 @@ func TestBuilderMakesADoneKeyWithTheDigests(t *testing.T) { // 1607/AC7
|
||||
t.Errorf("artifact = %+v, want the digest every node built and the reference its push answered (ADR 0498 clause 1)", a)
|
||||
}
|
||||
}
|
||||
if v.Toolchains["go"].Version != "go1.27.1" || v.Toolchains["typescript"].Version != "tsc5" {
|
||||
if v.Toolchains["go"].Version != "go1.27" || v.Toolchains["typescript"].Version != "tsc5" {
|
||||
t.Errorf("toolchains = %+v", v.Toolchains)
|
||||
}
|
||||
// A-115: the builder's process answers the seat mesh-builds' verb reserved over the bus; the reservation of a module it never
|
||||
@@ -750,7 +750,7 @@ func TestAFailedKeyIsBuiltAgainAsANewRevisionFromANewModulesValueWithTheSameFing
|
||||
}
|
||||
}
|
||||
|
||||
// TestAToolchainChangeDoesNotBuildTheOldFingerprint: the fingerprint names go1.27.1, the nodes then agree on go1.27.2 (a
|
||||
// TestAToolchainChangeDoesNotBuildTheOldFingerprint: the fingerprint names go1.27.1, the nodes then agree on go1.28.0 (a
|
||||
// report of both nodes), and the builder writes no key for the old fingerprint although it was woken by the report; a
|
||||
// module value naming go1.27.2 (the new fingerprint, computed by the indexer) is built.
|
||||
func TestAToolchainChangeDoesNotBuildTheOldFingerprint(t *testing.T) { // 1615/AC4
|
||||
@@ -765,15 +765,15 @@ func TestAToolchainChangeDoesNotBuildTheOldFingerprint(t *testing.T) { // 1615/A
|
||||
if err := st.Purge(b.ctx, jetstream.WithPurgeSubject("mesh.seat.node-build-go.event.toolchain-reported.>")); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
b.report(t, "mesh-build-go", "n1", "go", "go1.27.2", "1")
|
||||
b.report(t, "mesh-build-go", "n2", "go", "go1.27.2", "1")
|
||||
b.module(t, "netcheck", "catalogue-a67f0196-netcheck.module.json", "modules/netcheck") // names go1.27.1
|
||||
b.report(t, "mesh-build-go", "n1", "go", "go1.28.0", "1")
|
||||
b.report(t, "mesh-build-go", "n2", "go", "go1.28.0", "1")
|
||||
b.module(t, "netcheck", "catalogue-a67f0196-netcheck.module.json", "modules/netcheck") // names go1.27
|
||||
b.start(t, "n1", nil)
|
||||
// Another module, whose fingerprint names the new toolchain, is built; by then the old one has been looked at.
|
||||
b.moduleCommit(t, "netcheck2", "catalogue-a67f0196-netcheck.module.json", "modules/netcheck",
|
||||
map[string]builds.ToolchainUsed{"go": {Version: "go1.27.2", Recipe: "1"}, "typescript": {Version: "tsc5", Recipe: "1"}}, commit)
|
||||
map[string]builds.ToolchainUsed{"go": {Version: "go1.28", Recipe: "1"}, "typescript": {Version: "tsc5", Recipe: "1"}}, commit)
|
||||
b.await(t, "netcheck2", isState(builds.BuildDone))
|
||||
// The builder never agreed on go1.27.1, not for a moment: that is what would build the old fingerprint.
|
||||
// The builder never agreed on go1.27, not for a moment: that is what would build the old fingerprint.
|
||||
info, err := st.Info(b.ctx)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -786,12 +786,12 @@ func TestAToolchainChangeDoesNotBuildTheOldFingerprint(t *testing.T) { // 1615/A
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if strings.HasSuffix(m.Subject, ".toolchain-agreed") && strings.Contains(string(m.Data), `"version":"go1.27.1"`) {
|
||||
t.Errorf("the builder said the nodes agree on go1.27.1: %s", m.Data)
|
||||
if strings.HasSuffix(m.Subject, ".toolchain-agreed") && strings.Contains(string(m.Data), `"version":"go1.27"`) {
|
||||
t.Errorf("the builder said the nodes agree on go1.27: %s", m.Data)
|
||||
}
|
||||
}
|
||||
if _, err := b.builds.Get(b.ctx, mustKey(t, "netcheck")); err == nil {
|
||||
t.Error("the old fingerprint, naming go1.27.1, was built with go1.27.2; the log: " + b.out.String())
|
||||
t.Error("the old fingerprint, naming go1.27, was built with go1.28.0; the log: " + b.out.String())
|
||||
}
|
||||
if n := b.fake.count("mesh-build-go.build_go_build"); n != 1 {
|
||||
t.Errorf("build_go_build was called %d times, want 1 (the new fingerprint on one node only)", n)
|
||||
|
||||
@@ -111,7 +111,7 @@ func TestTheBuilderKeepsTheToolchainsItHeardAndForgetsThemOnStopped(t *testing.T
|
||||
if len(keys) != 3 || keys[0] != "ace.go" {
|
||||
t.Fatalf("the state holds %v, want the three nodes' keys <node>.go", keys)
|
||||
}
|
||||
if len(r.said) != 1 || r.said[0].Version != "1.26.0" || r.said[0].Language != "go" {
|
||||
if len(r.said) != 1 || r.said[0].Version != "1.26" || r.said[0].Language != "go" {
|
||||
t.Fatalf("toolchain-agreed said %+v, want one for go 1.26.0 (said only when the version changes)", r.said)
|
||||
}
|
||||
// The first report agreed it with one digest; a later digest of the same version is not said again.
|
||||
@@ -120,13 +120,13 @@ func TestTheBuilderKeepsTheToolchainsItHeardAndForgetsThemOnStopped(t *testing.T
|
||||
}
|
||||
// A restarted builder reads the keys back and agrees the same version with no new report; the digests it says are all three nodes'.
|
||||
again := newHeardRig(t, state)
|
||||
if len(again.said) != 1 || again.said[0].Version != "1.26.0" || len(again.said[0].Digests) != 2 || again.said[0].Digests[0].Nodes[1] != "g14" {
|
||||
if len(again.said) != 1 || again.said[0].Version != "1.26" || len(again.said[0].Digests) != 2 || again.said[0].Digests[0].Nodes[1] != "g14" {
|
||||
t.Fatalf("a restarted builder said %+v, want go 1.26.0 with the digests of its three nodes", again.said)
|
||||
}
|
||||
// A version change is said; the stopped build module of ace takes ace's key out, a placement taking nothing.
|
||||
again.report(t, "node-build-go", "ace", "go", "1.27.0", da)
|
||||
again.report(t, "node-build-go", "g14", "go", "1.27.0", da)
|
||||
if len(again.said) != 2 || again.said[1].Version != "1.27.0" {
|
||||
if len(again.said) != 2 || again.said[1].Version != "1.27" {
|
||||
t.Fatalf("a changed agreed version was not said: %+v", again.said)
|
||||
}
|
||||
at := time.Now()
|
||||
|
||||
@@ -197,7 +197,7 @@ func newRig(t *testing.T, artifacts ...catalogue.Artifact) *rig {
|
||||
}
|
||||
|
||||
// agreedToolchains are what the rig's nodes report, and so what a fingerprint computed now names.
|
||||
var agreedToolchains = map[string]builds.ToolchainUsed{"go": {Version: "go1.27.1", Recipe: "1"}, "typescript": {Version: "tsc5", Recipe: "1"}}
|
||||
var agreedToolchains = map[string]builds.ToolchainUsed{"go": {Version: "go1.27", Recipe: "1"}, "typescript": {Version: "tsc5", Recipe: "1"}}
|
||||
|
||||
func moduleValue(t *testing.T, path string) []byte { return moduleValueWith(t, path, agreedToolchains) }
|
||||
|
||||
@@ -301,7 +301,7 @@ func TestABundleAndAnArchiveAreBuiltOnOneNodeAndDone(t *testing.T) { // 1607/AC7
|
||||
if !slices.Equal(v.Needs, []string{"form:artifact-store"}) || v.Artifacts[0].References != nil {
|
||||
t.Errorf("needs = %v, references = %v", v.Needs, v.Artifacts[0].References)
|
||||
}
|
||||
if got := v.Toolchains["go"]; got.Version != "go1.27.1" || got.Recipe != "1" {
|
||||
if got := v.Toolchains["go"]; got.Version != "go1.27" || got.Recipe != "1" {
|
||||
t.Errorf("toolchains = %+v, want go and typescript named", v.Toolchains)
|
||||
}
|
||||
if got := v.Toolchains["typescript"]; got.Version != "tsc5" {
|
||||
@@ -684,32 +684,32 @@ func (d *seatDrops) get() []string {
|
||||
|
||||
func TestAKeyIsBuiltOnlyWithTheToolchainItsFingerprintNamesAndNothingIsWrittenOtherwise(t *testing.T) { // 1615/AC4
|
||||
r := newRig(t, goBundle)
|
||||
old := map[string]builds.ToolchainUsed{"go": {Version: "go1.26.0", Recipe: "1"}}
|
||||
old := map[string]builds.ToolchainUsed{"go": {Version: "go1.26", Recipe: "1"}}
|
||||
r.b.Module(context.Background(), "m", moduleValueWith(t, "modules/m", old))
|
||||
r.b.Wait()
|
||||
if len(r.st.vals) != 0 || len(r.bm.calls) != 0 {
|
||||
t.Run("a recipe that moves builds the module again under its new fingerprint", aRecipeThatMovesBuildsTheModuleAgainUnderItsNewFingerprint)
|
||||
t.Errorf("keys %v and %d calls for a fingerprint of go1.26.0 while the nodes agree on go1.27.1, want neither", r.st.vals, len(r.bm.calls))
|
||||
t.Errorf("keys %v and %d calls for a fingerprint of go1.26 while the nodes agree on go1.27, want neither", r.st.vals, len(r.bm.calls))
|
||||
}
|
||||
// A recipe that differs is a different toolchain too, and a value that names none (written before) is not built.
|
||||
r.b.Module(context.Background(), "m", moduleValueWith(t, "modules/m", map[string]builds.ToolchainUsed{"go": {Version: "go1.27.1", Recipe: "0"}}))
|
||||
r.b.Module(context.Background(), "m", moduleValueWith(t, "modules/m", map[string]builds.ToolchainUsed{"go": {Version: "go1.27", Recipe: "0"}}))
|
||||
r.b.Module(context.Background(), "m", moduleValueWith(t, "modules/m", nil))
|
||||
r.b.Wait()
|
||||
if len(r.st.vals) != 0 || len(r.bm.calls) != 0 {
|
||||
t.Errorf("keys %v and %d calls for a recipe that differs or a value that names no toolchain", r.st.vals, len(r.bm.calls))
|
||||
}
|
||||
// The toolchain moves under a key that is not built yet: the old fingerprint stays unbuilt, the new one builds.
|
||||
r.tools.Set("ace", tcOf("go", "go1.27.2"))
|
||||
r.tools.Set("novox", tcOf("go", "go1.27.2"))
|
||||
r.tools.Set("ace", tcOf("go", "go1.28.0"))
|
||||
r.tools.Set("novox", tcOf("go", "go1.28.0"))
|
||||
r.b.Reconsider(context.Background())
|
||||
r.b.Wait()
|
||||
if len(r.st.vals) != 0 {
|
||||
t.Errorf("keys %v: the old fingerprint was built with the new toolchain", r.st.vals)
|
||||
}
|
||||
r.b.Module(context.Background(), "m", moduleValueWith(t, "modules/m", map[string]builds.ToolchainUsed{"go": {Version: "go1.27.2", Recipe: "1"}}))
|
||||
r.b.Module(context.Background(), "m", moduleValueWith(t, "modules/m", map[string]builds.ToolchainUsed{"go": {Version: "go1.28", Recipe: "1"}}))
|
||||
r.b.Wait()
|
||||
if v := valueOf(t, r.st, r.key); v.State != builds.BuildDone || v.Toolchains["go"].Version != "go1.27.2" {
|
||||
t.Errorf("build = %+v, want done with go1.27.2", v)
|
||||
if v := valueOf(t, r.st, r.key); v.State != builds.BuildDone || v.Toolchains["go"].Version != "go1.28" {
|
||||
t.Errorf("build = %+v, want done with go1.28", v)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -730,7 +730,7 @@ func aRecipeThatMovesBuildsTheModuleAgainUnderItsNewFingerprint(t *testing.T) {
|
||||
t.Errorf("%d calls, was %d: the first fingerprint was built again for the new recipe", len(r.bm.calls), calls)
|
||||
}
|
||||
data, err := meshcatalogclient.EncodeModule(meshcatalog.ModulesByModuleValue{Repository: "novox/mesh-catalog", Commit: "7a74cee83f88e6585a5511c3cc53bdf0f5303d20", Fp: "src1:" + hex64('f'), Fp2: fp2,
|
||||
Manifest: mdigest('a'), Path: "modules/m", Toolchains: CatalogToolchains(map[string]builds.ToolchainUsed{"go": {Version: "go1.27.1", Recipe: "2"}})})
|
||||
Manifest: mdigest('a'), Path: "modules/m", Toolchains: CatalogToolchains(map[string]builds.ToolchainUsed{"go": {Version: "go1.27", Recipe: "2"}})})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ func (w *memWaits) End(_ context.Context, module, fp, how string) bool {
|
||||
// built and ended `ran` when the agreed toolchain moves to that version; and one held is built with the running build
|
||||
// module by Release and ended `released`.
|
||||
func TestAnEntryWhoseFingerprintNamesAnotherToolchainWaitsAndIsBuiltWhenItIsAgreedOrReleased(t *testing.T) {
|
||||
old := map[string]builds.ToolchainUsed{"go": {Version: "go1.26.0", Recipe: "1"}}
|
||||
old := map[string]builds.ToolchainUsed{"go": {Version: "go1.26", Recipe: "1"}}
|
||||
t.Run("ran", func(t *testing.T) {
|
||||
r := newRig(t, goBundle)
|
||||
w := &memWaits{}
|
||||
@@ -52,7 +52,7 @@ func TestAnEntryWhoseFingerprintNamesAnotherToolchainWaitsAndIsBuiltWhenItIsAgre
|
||||
t.Fatalf("held %v, keys %v: want one wait and nothing written", w.held, r.st.vals)
|
||||
}
|
||||
for _, h := range w.held {
|
||||
if h.On() != "toolchain:go@go1.26.0" {
|
||||
if h.On() != "toolchain:go@go1.26" {
|
||||
t.Errorf("the wait is on %s", h.On())
|
||||
}
|
||||
}
|
||||
@@ -75,7 +75,7 @@ func TestAnEntryWhoseFingerprintNamesAnotherToolchainWaitsAndIsBuiltWhenItIsAgre
|
||||
t.Fatalf("release refused: %s", why)
|
||||
}
|
||||
r.b.Wait()
|
||||
if got := valueOf(t, r.st, r.key); got.State != builds.BuildDone || got.Toolchains["go"].Version != "go1.27.1" || len(w.ended) != 1 || w.ended[0] != WaitReleased {
|
||||
if got := valueOf(t, r.st, r.key); got.State != builds.BuildDone || got.Toolchains["go"].Version != "go1.27" || len(w.ended) != 1 || w.ended[0] != WaitReleased {
|
||||
t.Errorf("build %+v, ended %v: want done with the running toolchain and a wait ended released", got, w.ended)
|
||||
}
|
||||
if why := r.b.Release(context.Background(), "m", fp1, "again", "operator"); why == "" {
|
||||
|
||||
@@ -555,8 +555,8 @@ func TestOnlyThePackageWithoutAKeptVerdictRuns(t *testing.T) { // 1288/AC1
|
||||
t.Fatalf("verdict %+v, asks %+v: want a pass of three asks, the first naming no need", out.Verdict, asks)
|
||||
}
|
||||
for _, a := range asks { // ADR 0584: every check ask names the agreed toolchain, so a node off it declines
|
||||
if a.Check.Toolchain == nil || a.Check.Toolchain.Version != "go1.27.1" || a.Check.Toolchain.Recipe != "7" {
|
||||
t.Errorf("a check ask names toolchain %+v, want go1.27.1 recipe 7", a.Check.Toolchain)
|
||||
if a.Check.Toolchain == nil || a.Check.Toolchain.Version != "go1.27" || a.Check.Toolchain.Recipe != "7" {
|
||||
t.Errorf("a check ask names toolchain %+v, want go1.27 recipe 7", a.Check.Toolchain)
|
||||
}
|
||||
}
|
||||
for _, a := range asks[1:] {
|
||||
@@ -1191,7 +1191,7 @@ func TestACheckIsOneAskAndAReJudgeGoesOnTheRecheckStream(t *testing.T) {
|
||||
t.Fatalf("the job = %+v", asks[0].Check)
|
||||
}
|
||||
// B2g: the job carries the toolchain the checker agreed (ADR 0584), with its language, so a node on another declines it.
|
||||
if tc := asks[0].Check.Toolchain; tc == nil || *tc != (buildstep.ToolchainUsed{Language: "go", Version: "go1.27.1", Recipe: "7"}) {
|
||||
if tc := asks[0].Check.Toolchain; tc == nil || *tc != (buildstep.ToolchainUsed{Language: "go", Version: "go1.27", Recipe: "7"}) {
|
||||
t.Errorf("the job's toolchain = %+v, want the agreed go toolchain", tc)
|
||||
}
|
||||
cs := caseOf(t, pullOf(repoA, 7, head1))
|
||||
|
||||
@@ -941,7 +941,7 @@ func TestTakeIn(t *testing.T) { // 1585/T3-T13 (ADR 0633)
|
||||
x := b.ix.dry().ix
|
||||
for _, node := range []string{"novox", "ace"} {
|
||||
key, _ := ToolchainKey(node, "go")
|
||||
x.PutToolchain("mesh-build-go", key, toolchainValue(t, "go", "go1.27.2", "1"), false)
|
||||
x.PutToolchain("mesh-build-go", key, toolchainValue(t, "go", "go1.28.0", "1"), false)
|
||||
}
|
||||
ready, _, _, _ := b.ix.loadNewest(ctx, WaitsOf(entries).Ready)
|
||||
next, _, err := x.computeOver(ctx, ready)
|
||||
@@ -951,11 +951,11 @@ func TestTakeIn(t *testing.T) { // 1585/T3-T13 (ADR 0633)
|
||||
b.ix.ownMu.Lock()
|
||||
b.ix.ownFP = next
|
||||
b.ix.ownMu.Unlock()
|
||||
reportToolchain(t, b.ix, "mesh-build-go", "novox", "go", "go1.27.2")
|
||||
reportToolchain(t, b.ix, "mesh-build-go", "novox", "go", "go1.28.0")
|
||||
if len(b.keys()) != 1 {
|
||||
t.Fatalf("one node's report: pending %v, want the revision still held (the nodes disagree)", b.keys())
|
||||
}
|
||||
reportToolchain(t, b.ix, "mesh-build-go", "ace", "go", "go1.27.2")
|
||||
reportToolchain(t, b.ix, "mesh-build-go", "ace", "go", "go1.28.0")
|
||||
if len(b.keys()) != 0 || b.commit(t, "avahi") != sha('c') {
|
||||
t.Errorf("after the toolchain report: pending %v, avahi at %s: want the revision taken in", b.keys(), b.commit(t, "avahi"))
|
||||
}
|
||||
|
||||
+2
-2
@@ -7,14 +7,14 @@
|
||||
},
|
||||
"candidate": {
|
||||
"base": 5,
|
||||
"fpset": "01c840ec276b",
|
||||
"fpset": "6ed3e0bd2a45",
|
||||
"group": "feat/x",
|
||||
"heads": "dfe9fb8f79e8",
|
||||
"pulls": [
|
||||
{
|
||||
"fps": {
|
||||
"avahi": {
|
||||
"fp2": "src2:e8d595aea1b13f1f5578ef1f245dab0d28a351c28079ecdcd2276c63a932d7be",
|
||||
"fp2": "src2:fc14d6ab7e13fd81e12df0ca9fcdcc536691cb4ea31d7efc24a25b5401efaf67",
|
||||
"manifest": "8a3856b6c0566d76f2556fc4f46c5251dc7935517bb6bd15809ded7e5546a0d8"
|
||||
}
|
||||
},
|
||||
|
||||
@@ -170,13 +170,13 @@ func TestAgreedToolchainChangesAGoModulesReasonWithNoMerge(t *testing.T) { // 14
|
||||
reportToolchain(t, ix, "mesh-build-go", "ace", "go", "go1.27.1")
|
||||
m, _ := moduleOf(t, mods, "avahi")
|
||||
// L3 (ADR 0603 §2, §3): the agreement moving rewrites the module's toolchain edge, and again when it moves on.
|
||||
if g := graphOf(t, ix, "avahi"); g.FP != m.Fp2 || g.Toolchains["go"].Version != "go1.27.1" || g.Toolchains["go"].Module != "mesh-build-go" {
|
||||
t.Errorf("after: graph.avahi = %+v, want the toolchain edge of go1.27.1", g)
|
||||
if g := graphOf(t, ix, "avahi"); g.FP != m.Fp2 || g.Toolchains["go"].Version != "go1.27" || g.Toolchains["go"].Module != "mesh-build-go" {
|
||||
t.Errorf("after: graph.avahi = %+v, want the toolchain edge of go1.27", g)
|
||||
}
|
||||
reportToolchain(t, ix, "mesh-build-go", "novox", "go", "go1.28.0")
|
||||
reportToolchain(t, ix, "mesh-build-go", "ace", "go", "go1.28.0")
|
||||
if g := graphOf(t, ix, "avahi"); g.Toolchains["go"].Version != "go1.28.0" {
|
||||
t.Errorf("moved on: graph.avahi = %+v, want the toolchain edge of go1.28.0", g)
|
||||
if g := graphOf(t, ix, "avahi"); g.Toolchains["go"].Version != "go1.28" {
|
||||
t.Errorf("moved on: graph.avahi = %+v, want the toolchain edge of go1.28", g)
|
||||
}
|
||||
reportToolchain(t, ix, "mesh-build-go", "novox", "go", "go1.27.1")
|
||||
reportToolchain(t, ix, "mesh-build-go", "ace", "go", "go1.27.1")
|
||||
@@ -283,7 +283,7 @@ func TestNodesReportingDifferentVersionsLeaveTheReasonNamingBoth(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
m, _ := moduleOf(t, mods, "avahi")
|
||||
if !strings.Contains(m.None2, "builders disagree") || !strings.Contains(m.None2, "go1.27.1") || !strings.Contains(m.None2, "go1.26.0") {
|
||||
if !strings.Contains(m.None2, "builders disagree") || !strings.Contains(m.None2, "go1.27") || !strings.Contains(m.None2, "go1.26") {
|
||||
t.Errorf("none2 = %q, want 'builders disagree' naming both versions", m.None2)
|
||||
}
|
||||
}
|
||||
@@ -304,7 +304,7 @@ func goInputs(t *testing.T, ix *Indexer, mods *memStore, module, builder string,
|
||||
t.Helper()
|
||||
return fingerprint.Inputs{Module: module, Tree: "tree-" + module, Builder: builder, Bases: bases,
|
||||
Locks: map[string]string{"tools": avahiGoSum},
|
||||
Toolchains: map[string]meshcatalogclient.Toolchain2{"tools": {Language: "go", Version: "go1.27.1", Recipe: "1"}}}
|
||||
Toolchains: map[string]meshcatalogclient.Toolchain2{"tools": {Language: "go", Version: "go1.27", Recipe: "1"}}}
|
||||
}
|
||||
|
||||
func fp2(t *testing.T, in fingerprint.Inputs) string {
|
||||
@@ -333,7 +333,7 @@ func TestBasesAreComputedFirstAndNoFingerprintTakesTheBuilder(t *testing.T) { //
|
||||
t.Errorf("other: fp2 = %q none2 = %q, want none2 naming the base ts-base", m.Fp2, m.None2)
|
||||
}
|
||||
// L3 (ADR 0603 §2): the module graph holds each module's edges as this recompute computed them.
|
||||
goTool := map[string]graph.Toolchain{"go": {Module: "mesh-build-go", Version: "go1.27.1", Recipe: "1"}}
|
||||
goTool := map[string]graph.Toolchain{"go": {Module: "mesh-build-go", Version: "go1.27", Recipe: "1"}}
|
||||
if g := graphOf(t, ix, "avahi"); g.FP != want["avahi"] || !reflect.DeepEqual(g.Bases, []string{"mesh-tools"}) ||
|
||||
!reflect.DeepEqual(g.Toolchains, goTool) || g.Repository != catalogueRepo || g.Path != "modules/avahi" {
|
||||
t.Errorf("graph.avahi = %+v", g)
|
||||
@@ -359,7 +359,7 @@ func TestBasesAreComputedFirstAndNoFingerprintTakesTheBuilder(t *testing.T) { //
|
||||
t.Errorf("the indexer's main = %q (%v), want cmd/mesh-delivery-indexer", MainOf(m), err)
|
||||
}
|
||||
if e := entries["avahi"]; e.Fp != want["avahi"] || e.Commit == "" || e.ManifestDigest == "" || !reflect.DeepEqual(e.Bases, []string{"mesh-tools"}) ||
|
||||
e.Toolchains["go"] != (meshcatalog.BuildEdge{Module: "mesh-build-go", Version: "go1.27.1", Recipe: "1"}) {
|
||||
e.Toolchains["go"] != (meshcatalog.BuildEdge{Module: "mesh-build-go", Version: "go1.27", Recipe: "1"}) {
|
||||
t.Errorf("the catalog entry of avahi = %+v", e)
|
||||
}
|
||||
// W3.1's inputs (the lead's ruling on finding 1): an entry carries what the next revision is computed from (the
|
||||
@@ -372,7 +372,7 @@ func TestBasesAreComputedFirstAndNoFingerprintTakesTheBuilder(t *testing.T) { //
|
||||
t.Errorf("%s read back from its entry = %+v, want %+v", name, back, m)
|
||||
}
|
||||
}
|
||||
if e := entries["avahi"]; e.Inputs == nil || e.Inputs.From == nil || e.Inputs.Toolchains["go"].Version != "go1.27.1" {
|
||||
if e := entries["avahi"]; e.Inputs == nil || e.Inputs.From == nil || e.Inputs.Toolchains["go"].Version != "go1.27" {
|
||||
t.Errorf("the catalog entry of avahi carries inputs %+v, want what its fingerprint is computed from", e.Inputs)
|
||||
}
|
||||
rev, objects, err := CatalogRevisionOf(meshcatalog.CatalogRevision{Revision: 1, Kind: "trunk", Source: 7}, entries)
|
||||
@@ -799,7 +799,7 @@ func TestAModuleKeepsTheToolchainsItsFingerprintWasComputedWith(t *testing.T) {
|
||||
}
|
||||
reportToolchain(t, ix, "mesh-build-go", "novox", "go", "go1.27.1")
|
||||
m, _ := moduleOf(t, mods, "avahi")
|
||||
want := map[string]meshcatalog.ToolchainUsed{"go": {Version: "go1.27.1", Recipe: "1"}}
|
||||
want := map[string]meshcatalog.ToolchainUsed{"go": {Version: "go1.27", Recipe: "1"}}
|
||||
if m.Fp2 == "" || !reflect.DeepEqual(m.Toolchains, want) {
|
||||
t.Fatalf("avahi: fp2 %q toolchains %+v, want %+v", m.Fp2, m.Toolchains, want)
|
||||
}
|
||||
@@ -807,9 +807,9 @@ func TestAModuleKeepsTheToolchainsItsFingerprintWasComputedWith(t *testing.T) {
|
||||
t.Errorf("a module with no fingerprint carries toolchains %+v", o.Toolchains)
|
||||
}
|
||||
// An upgrade moves the fingerprint and the toolchains together, with no merge.
|
||||
reportToolchain(t, ix, "mesh-build-go", "novox", "go", "go1.27.2")
|
||||
reportToolchain(t, ix, "mesh-build-go", "novox", "go", "go1.28.0")
|
||||
n, _ := moduleOf(t, mods, "avahi")
|
||||
if n.Fp2 == m.Fp2 || n.Toolchains["go"].Version != "go1.27.2" {
|
||||
if n.Fp2 == m.Fp2 || n.Toolchains["go"].Version != "go1.28" {
|
||||
t.Errorf("after the upgrade: fp2 %q (was %q) toolchains %+v, want the new version with the new fingerprint", n.Fp2, m.Fp2, n.Toolchains)
|
||||
}
|
||||
// Issue 1585 (ADR 0573 §2): a module whose go.sum names mesh-sdk takes mesh-sdk's latest published version into its
|
||||
@@ -863,7 +863,7 @@ func TestAModuleKeepsTheToolchainsItsFingerprintWasComputedWith(t *testing.T) {
|
||||
t.Errorf("a new tree while nodes disagree: fp2 %q toolchains %+v none2 %q, want no fingerprint and the disagreement", d.Fp2, d.Toolchains, d.None2)
|
||||
}
|
||||
// They agree again: the new tree gets its fingerprint.
|
||||
reportToolchain(t, ix, "mesh-build-go", "ace", "go", "go1.27.2")
|
||||
reportToolchain(t, ix, "mesh-build-go", "ace", "go", "go1.28.0")
|
||||
if a, _ := moduleOf(t, mods, "avahi"); a.Fp2 == "" || a.Fp2 == n.Fp2 {
|
||||
t.Errorf("agreed again: fp2 %q (was %q), want a new fingerprint", a.Fp2, n.Fp2)
|
||||
}
|
||||
|
||||
@@ -13,6 +13,35 @@ import (
|
||||
// ToolchainNoReport is the reason AgreedToolchain gives when no node has reported a language's toolchain.
|
||||
const ToolchainNoReport = "toolchain not yet reported"
|
||||
|
||||
// LanguageVersion is the version of a language a toolchain is agreed, reported and named by (design 47 G, A-471): its
|
||||
// major.minor, so "go1.27.4-X:nodwarf5" and "go1.27.3" are "go1.27" and "v26.13.1" is "v26.13". A text before the first
|
||||
// digit (go, v) is kept. A version with no major.minor is returned as it is.
|
||||
func LanguageVersion(version string) string {
|
||||
start := strings.IndexAny(version, "0123456789")
|
||||
if start < 0 {
|
||||
return version
|
||||
}
|
||||
end, dots := start, 0
|
||||
for end < len(version) {
|
||||
c := version[end]
|
||||
if c >= '0' && c <= '9' {
|
||||
end++
|
||||
} else if c == '.' && dots == 0 && end+1 < len(version) && version[end+1] >= '0' && version[end+1] <= '9' {
|
||||
dots++
|
||||
end++
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
if dots == 0 {
|
||||
return version
|
||||
}
|
||||
return version[:end]
|
||||
}
|
||||
|
||||
// SameToolchainVersion is whether two installed versions are one language version (LanguageVersion).
|
||||
func SameToolchainVersion(a, b string) bool { return LanguageVersion(a) == LanguageVersion(b) }
|
||||
|
||||
// NodeToolchain is one node's entry of a language, as read from a build seat's state toolchains (the entry is Toolchain).
|
||||
type NodeToolchain struct {
|
||||
Node string
|
||||
@@ -38,7 +67,7 @@ type Agreement struct {
|
||||
Wait string
|
||||
}
|
||||
|
||||
// ToolchainAgreement is the agreed toolchain of a language: the version and recipe a strict majority of the reporting
|
||||
// ToolchainAgreement is the agreed toolchain of a language: the language version (LanguageVersion: the patch is not counted, A-471) and recipe a strict majority of the reporting
|
||||
// nodes report (novox/hq ADR 0584 clause 1). With no strict majority (two against two) or no entry it gives no toolchain
|
||||
// and says why in Wait. The answer does not depend on the entries' order. The entries must all be of one language.
|
||||
func ToolchainAgreement(entries []NodeToolchain) Agreement {
|
||||
@@ -48,15 +77,15 @@ func ToolchainAgreement(entries []NodeToolchain) Agreement {
|
||||
type identity struct{ Language, Version, Recipe string }
|
||||
groups := map[identity][]string{}
|
||||
for _, e := range entries {
|
||||
k := identity{e.Language, e.Version, e.Recipe}
|
||||
k := identity{e.Language, LanguageVersion(e.Version), e.Recipe}
|
||||
groups[k] = append(groups[k], e.Node)
|
||||
}
|
||||
for k, nodes := range groups {
|
||||
if 2*len(nodes) > len(entries) {
|
||||
a := Agreement{Toolchain: Toolchain{Language: k.Language, Version: k.Version, Recipe: k.Recipe}}
|
||||
for _, e := range entries {
|
||||
if e.Version != k.Version || e.Recipe != k.Recipe {
|
||||
a.SittingOut = append(a.SittingOut, SittingOut{Node: e.Node, Version: e.Version, Recipe: e.Recipe})
|
||||
if LanguageVersion(e.Version) != k.Version || e.Recipe != k.Recipe {
|
||||
a.SittingOut = append(a.SittingOut, SittingOut{Node: e.Node, Version: LanguageVersion(e.Version), Recipe: e.Recipe})
|
||||
}
|
||||
}
|
||||
sort.Slice(a.SittingOut, func(i, j int) bool { return a.SittingOut[i].Node < a.SittingOut[j].Node })
|
||||
|
||||
@@ -19,12 +19,14 @@ func TestToolchainAgreement(t *testing.T) {
|
||||
out []SittingOut
|
||||
wait []string // "" wait means agreed
|
||||
}{
|
||||
{"all agree", []NodeToolchain{e("ace", "go", "1.26.1", "3"), e("novox", "go", "1.26.1", "3")}, "1.26.1", nil, nil},
|
||||
{"all agree", []NodeToolchain{e("ace", "go", "1.26.1", "3"), e("novox", "go", "1.26.1", "3")}, "1.26", nil, nil},
|
||||
{"patches differ", []NodeToolchain{e("g14", "go", "go1.27.4-X:nodwarf5", "3"), e("ace", "go", "go1.27.3", "3"), e("novox", "go", "go1.27.3", "3")}, "go1.27", nil, nil},
|
||||
{"recipes differ", []NodeToolchain{e("shanks", "typescript", "v26.13.0", "f2"), e("ace", "typescript", "v26.13.0", "f5"), e("novox", "typescript", "v26.13.0", "f5"), e("g14", "typescript", "v26.13.1", "f5")}, "v26.13", []SittingOut{{"shanks", "v26.13", "f2"}}, nil},
|
||||
{"three against one", []NodeToolchain{e("ace", "typescript", "26.12.1", "3"), e("g14", "typescript", "26.13.0", "3"), e("novox", "typescript", "26.13.0", "3"), e("shanks", "typescript", "26.13.0", "3")},
|
||||
"26.13.0", []SittingOut{{"ace", "26.12.1", "3"}}, nil},
|
||||
{"two against two", []NodeToolchain{e("ace", "go", "1.26.1", "3"), e("novox", "go", "1.26.2", "3"), e("g14", "go", "1.26.1", "3"), e("shanks", "go", "1.26.2", "3")},
|
||||
"", nil, []string{"builders disagree", "1.26.1 recipe 3 on ace, g14", "1.26.2 recipe 3 on novox, shanks"}},
|
||||
{"one node alone", []NodeToolchain{e("ace", "go", "1.26.1", "3")}, "1.26.1", nil, nil},
|
||||
"26.13", []SittingOut{{"ace", "26.12", "3"}}, nil},
|
||||
{"two against two", []NodeToolchain{e("ace", "go", "1.26.1", "3"), e("novox", "go", "1.27.2", "3"), e("g14", "go", "1.26.1", "3"), e("shanks", "go", "1.27.2", "3")},
|
||||
"", nil, []string{"builders disagree", "1.26 recipe 3 on ace, g14", "1.27 recipe 3 on novox, shanks"}},
|
||||
{"one node alone", []NodeToolchain{e("ace", "go", "1.26.1", "3")}, "1.26", nil, nil},
|
||||
{"no report", nil, "", nil, []string{ToolchainNoReport}},
|
||||
} {
|
||||
a := ToolchainAgreement(c.in)
|
||||
@@ -71,3 +73,18 @@ func TestToolchainKeyParsesBack(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// A-471: a toolchain is named by its language version, Go's and Node's major.minor, the patch and the build's suffix not counted.
|
||||
func TestLanguageVersion(t *testing.T) {
|
||||
for in, want := range map[string]string{
|
||||
"go1.27.4-X:nodwarf5": "go1.27", "go1.27.3": "go1.27", "go1.27": "go1.27", "1.26.1": "1.26",
|
||||
"v26.13.0": "v26.13", "v26.13.1": "v26.13", "v26": "v26", "go": "go", "": "",
|
||||
} {
|
||||
if got := LanguageVersion(in); got != want {
|
||||
t.Errorf("LanguageVersion(%q) = %q, want %q", in, got, want)
|
||||
}
|
||||
}
|
||||
if !SameToolchainVersion("go1.27.3", "go1.27.4-X:nodwarf5") || SameToolchainVersion("go1.27.3", "go1.28.0") {
|
||||
t.Error("SameToolchainVersion does not compare the language version")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,11 +159,12 @@ func (s AskSteps) onToolchain(ctx context.Context, want *sdkstep.ToolchainUsed)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if tc.Version != want.Version || tc.Recipe != want.Recipe {
|
||||
return nil, &Declining{Lacks: []string{fmt.Sprintf("the agreed toolchain %s (recipe %s)", want.Version, want.Recipe)},
|
||||
if !sdkstep.SameToolchainVersion(tc.Version, want.Version) || tc.Recipe != want.Recipe {
|
||||
return nil, &Declining{Lacks: []string{fmt.Sprintf("the agreed toolchain %s (recipe %s)", sdkstep.LanguageVersion(want.Version), want.Recipe)},
|
||||
Text: fmt.Sprintf("the ask is for %s (recipe %s) and this node builds with %s (recipe %s): it sits out, and the ask is left to a node on the agreed toolchain",
|
||||
want.Version, want.Recipe, tc.Version, tc.Recipe)}
|
||||
sdkstep.LanguageVersion(want.Version), want.Recipe, sdkstep.LanguageVersion(tc.Version), tc.Recipe)}
|
||||
}
|
||||
tc.Version = sdkstep.LanguageVersion(tc.Version) // named by its language version, the patch not counted (A-471)
|
||||
return &tc, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -141,6 +141,24 @@ func TestRunAskRefusesAnotherToolchain(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// A-471: a node whose installed patch differs from the ask's takes it: the ask names go1.27, the node builds with
|
||||
// go1.27.4-X:nodwarf5, and its answer names the language version.
|
||||
func TestRunAskTakesAnotherPatchOfTheLanguageVersion(t *testing.T) {
|
||||
r := &recorder{fetch: map[string]any{"workspace": "/w"}}
|
||||
s := r.steps()
|
||||
s.Toolchain = func(context.Context) (sdkstep.ToolchainUsed, error) {
|
||||
return sdkstep.ToolchainUsed{Version: "go1.27.4-X:nodwarf5", Recipe: "3"}, nil
|
||||
}
|
||||
out, err := RunAsk(context.Background(), s, ask(sdkstep.BuildJob{Module: "m", Path: ".", Fetch: &sdkstep.Fetch{Repository: "novox/x", Commit: runCommit},
|
||||
Artifacts: []sdkstep.AskArtifact{{Artifact: "bundle"}}, Toolchain: &sdkstep.ToolchainUsed{Version: "go1.27", Recipe: "3"}}))
|
||||
if err != nil {
|
||||
t.Fatalf("err %v", err)
|
||||
}
|
||||
if tc := out.(sdkstep.BuildAnswer).Toolchain; tc == nil || tc.Version != "go1.27" {
|
||||
t.Errorf("the answer names %+v, want go1.27", tc)
|
||||
}
|
||||
}
|
||||
|
||||
// 1887/A3, A5a: a check ask runs the levels of one check after one fetch: it digests the unit level, takes the kept
|
||||
// verdicts, tests the packages whose tests changed first and then the others, also after one of them failed, and runs
|
||||
// every level, also after one that did not pass, so one check names every failure (the operator, 2026-11-02).
|
||||
|
||||
@@ -37,16 +37,16 @@ func (g Guard) Check(ctx context.Context) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
raw, err := sdkstep.EncodeToolchain(sdkstep.Toolchain{Language: g.Language, Version: installed, Recipe: g.Recipe, At: now().UTC()})
|
||||
raw, err := sdkstep.EncodeToolchain(sdkstep.Toolchain{Language: g.Language, Version: sdkstep.LanguageVersion(installed), Recipe: g.Recipe, At: now().UTC()})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if _, err := g.Put(key, json.RawMessage(raw)); err != nil {
|
||||
return fmt.Errorf("steprun: writing the toolchain %s: %w", key, err)
|
||||
}
|
||||
if installed != g.Want {
|
||||
return &Refusal{Text: fmt.Sprintf("%s %s installed, the recipe builds with %s %s", g.Language, installed, g.Language, g.Want),
|
||||
Want: g.Want, Have: installed}
|
||||
if !sdkstep.SameToolchainVersion(installed, g.Want) {
|
||||
return &Refusal{Text: fmt.Sprintf("%s %s installed, the recipe builds with %s %s", g.Language, sdkstep.LanguageVersion(installed), g.Language, sdkstep.LanguageVersion(g.Want)),
|
||||
Want: sdkstep.LanguageVersion(g.Want), Have: sdkstep.LanguageVersion(installed)}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -33,24 +33,36 @@ func TestCheckPassesAndWritesTheToolchain(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
tc, ok := k["ace.go"]
|
||||
if !ok || tc.Version != "1.27.0" || tc.Recipe != "r7" || tc.Language != "go" || tc.At.IsZero() {
|
||||
if !ok || tc.Version != "1.27" || tc.Recipe != "r7" || tc.Language != "go" || tc.At.IsZero() {
|
||||
t.Errorf("keys = %+v", k)
|
||||
}
|
||||
}
|
||||
|
||||
// A-471: the patch is not counted: a node on another patch of the recipe's language version passes, and its key holds the
|
||||
// language version alone.
|
||||
func TestCheckPassesAnotherPatchAndWritesTheLanguageVersion(t *testing.T) {
|
||||
k := toolchainKeys{}
|
||||
if err := guardFor(k, "1.27.4-X:nodwarf5", nil).Check(context.Background()); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if v := k["ace.go"].Version; v != "1.27" {
|
||||
t.Errorf("the key holds %q, want 1.27", v)
|
||||
}
|
||||
}
|
||||
|
||||
// 1473/AC2: another version: a Refusal naming both, and the key holds the installed version.
|
||||
func TestCheckRefusesAnotherVersionAndWritesTheInstalledOne(t *testing.T) {
|
||||
k := toolchainKeys{}
|
||||
err := guardFor(k, "1.27.1", nil).Check(context.Background())
|
||||
err := guardFor(k, "1.28.1", nil).Check(context.Background())
|
||||
var ref *Refusal
|
||||
if !errors.As(err, &ref) {
|
||||
t.Fatalf("Check = %v, want a Refusal", err)
|
||||
}
|
||||
if ref.Text != "go 1.27.1 installed, the recipe builds with go 1.27.0" || ref.Want != "1.27.0" || ref.Have != "1.27.1" {
|
||||
if ref.Text != "go 1.28 installed, the recipe builds with go 1.27" || ref.Want != "1.27" || ref.Have != "1.28" {
|
||||
t.Errorf("refusal = %+v", ref)
|
||||
}
|
||||
if k["ace.go"].Version != "1.27.1" {
|
||||
t.Errorf("the key holds %q, want the installed 1.27.1", k["ace.go"].Version)
|
||||
if k["ace.go"].Version != "1.28" {
|
||||
t.Errorf("the key holds %q, want the installed 1.28", k["ace.go"].Version)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user