84 lines
3.7 KiB
Go
84 lines
3.7 KiB
Go
package build
|
|
|
|
import (
|
|
"context"
|
|
"strings"
|
|
"testing"
|
|
|
|
"git.novox.be/novox/mesh-sdk/go/delivery"
|
|
)
|
|
|
|
// 1664: a done key built on one node is not built again, over and over, while the second node's build keeps failing.
|
|
func TestASecondNodeBuildThatFailsIsNotRetriedUntilTheNodesChange(t *testing.T) { // issue 1664
|
|
r := newRig(t, goBundle)
|
|
r.pres.Put("ace", presenceValue(t, false), false) // only novox qualifies
|
|
first := r.consider(t, "modules/m")
|
|
r.bm.fails["ace/build_go_fetch"] = "ace is out of disk"
|
|
r.pres.Put("ace", presenceValue(t, true), false)
|
|
r.b.NodesChanged(context.Background()) // ace came online: one more try
|
|
r.b.Wait()
|
|
tries := len(r.bm.callsOf("build_go_fetch"))
|
|
if tries < 2 {
|
|
t.Fatalf("%d fetches: the second node was never tried", tries)
|
|
}
|
|
if v := valueOf(t, r.st, r.key); !delivery.SameBuilderBuild(v, first) {
|
|
t.Fatalf("the done key changed: %+v", v)
|
|
}
|
|
// Nothing about the nodes changed: a modules value, a Reconsider and a start of looking again build nothing.
|
|
for i := 0; i < 3; i++ {
|
|
r.b.Module(context.Background(), "m", moduleValue(t, "modules/m"))
|
|
r.b.Reconsider(context.Background())
|
|
r.b.Wait()
|
|
}
|
|
if n := len(r.bm.callsOf("build_go_fetch")); n != tries {
|
|
t.Errorf("%d fetches after looking again, was %d: the failed second build was retried in a loop", n, tries)
|
|
}
|
|
// A node changing (ace goes and comes back) is a reason to try again, and ace now builds.
|
|
delete(r.bm.fails, "ace/build_go_fetch")
|
|
r.pres.Put("ace", presenceValue(t, false), false)
|
|
r.b.NodesChanged(context.Background())
|
|
r.pres.Put("ace", presenceValue(t, true), false)
|
|
r.b.NodesChanged(context.Background())
|
|
r.b.Wait()
|
|
if v := valueOf(t, r.st, r.key); v.State != delivery.BuildDone || strings.HasPrefix(v.Step, OneNodePrefix) || !strings.Contains(v.Step, "ace and novox") {
|
|
t.Errorf("build = %+v, want it built on both nodes once ace could", v)
|
|
}
|
|
}
|
|
|
|
// 1660: at start the builder closes a key left building for a fingerprint the module no longer has.
|
|
func TestAKeyLeftBuildingForAFingerprintTheModuleNoLongerHasIsClosedAtStart(t *testing.T) { // issue 1660
|
|
r := newRig(t, goBundle)
|
|
stale := seed(t, r.st, delivery.BuilderBuild{State: delivery.BuildBuilding, By: "ace.builder", Manifest: manifestD}) // m at fp1
|
|
other, _ := delivery.BuilderBuildKey("gone", fp1)
|
|
data, _ := delivery.EncodeBuilderBuild(delivery.BuilderBuild{State: delivery.BuildBuilding, By: "ace.builder", Manifest: manifestD})
|
|
r.st.put(other, data)
|
|
// The module m has moved on to another fingerprint.
|
|
moved := delivery.Module{Repository: "novox/mesh-catalog", Commit: "7a74cee83f88e6585a5511c3cc53bdf0f5303d20", FP: "src1:" + hex64('f'),
|
|
FP2: "src2:" + hex64('7'), Manifest: manifestD, Path: "modules/m", Toolchains: agreedToolchains}
|
|
enc, _ := delivery.EncodeModule(moved)
|
|
r.b.Module(context.Background(), "m", enc)
|
|
r.b.Wait()
|
|
if err := r.b.Sweep(context.Background()); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
for _, k := range []string{stale, other} {
|
|
v := valueOf(t, r.st, k)
|
|
if v.State != delivery.BuildFailed || !strings.Contains(v.Error, "no longer") || !strings.Contains(v.Error, "ace.builder") {
|
|
t.Errorf("%s = %+v, want it closed as failed, naming why and who left it", k, v)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestSweepLeavesAKeyOfTheModulesCurrentFingerprintForTheBuildToTakeOver(t *testing.T) { // issue 1660
|
|
r := newRig(t, goBundle)
|
|
seed(t, r.st, delivery.BuilderBuild{State: delivery.BuildBuilding, By: "ace.builder", Manifest: manifestD})
|
|
r.b.Module(context.Background(), "m", moduleValue(t, "modules/m")) // takes it over and builds it
|
|
r.b.Wait()
|
|
if err := r.b.Sweep(context.Background()); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if v := valueOf(t, r.st, r.key); v.State != delivery.BuildDone || v.By != "novox.builder" {
|
|
t.Errorf("build = %+v, want done by novox.builder", v)
|
|
}
|
|
}
|