49 lines
2.2 KiB
Go
49 lines
2.2 KiB
Go
package build
|
|
|
|
import (
|
|
"context"
|
|
"strings"
|
|
"testing"
|
|
|
|
"git.novox.be/novox/mesh-delivery/contracts/go/clients/meshcatalogclient"
|
|
"git.novox.be/novox/mesh-delivery/contracts/go/seats/meshcatalog"
|
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-builder/builds"
|
|
)
|
|
|
|
// 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, builds.BuilderBuild{State: builds.BuildBuilding, By: "ace.builder", Manifest: manifestD}) // m at fp1
|
|
other, _ := builds.BuilderBuildKey("gone", fp1)
|
|
data, _ := builds.EncodeBuilderBuild(builds.BuilderBuild{State: builds.BuildBuilding, By: "ace.builder", Manifest: manifestD})
|
|
r.st.put(other, data)
|
|
// The module m has moved on to another fingerprint.
|
|
moved := meshcatalog.ModulesByModuleValue{Repository: "novox/mesh-catalog", Commit: "7a74cee83f88e6585a5511c3cc53bdf0f5303d20", Fp: "src1:" + hex64('f'),
|
|
Fp2: "src2:" + hex64('7'), Manifest: manifestD, Path: "modules/m", Toolchains: CatalogToolchains(agreedToolchains)}
|
|
enc, _ := meshcatalogclient.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 != builds.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, builds.BuilderBuild{State: builds.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 != builds.BuildDone || v.By != "novox.builder" {
|
|
t.Errorf("build = %+v, want done by novox.builder", v)
|
|
}
|
|
}
|