Remove the release-branch judge from the controller, the wire and the build seat (issue 977, part A, ADR 0401)
This commit is contained in:
@@ -365,105 +365,3 @@ func TestTheRecheckVerbAsksMeshDeliveryOnABusOfItsOwn(t *testing.T) {
|
||||
t.Fatalf("mesh-delivery was asked %d times", asked)
|
||||
}
|
||||
}
|
||||
|
||||
// **A delivery group's composed check is judged by the group's own controller** (novox/hq ADR 0239 §14), into a release
|
||||
// branch too: the controller member and the mesh-host member of the pair are consistent only together (the controller
|
||||
// calls what only the node-engine change brings), and both merge into a release branch. The release judge (the
|
||||
// controller of the release branch with the validator of its own) cannot build it; the group's own controller, as
|
||||
// merged, with the node-engine member's validator, can. It drives askGroupCheck and the build seat's Check for real.
|
||||
func TestAGroupsCompositionIntoAReleaseBranchIsJudgedByItsOwnController(t *testing.T) {
|
||||
groupIntoARelease(t, false)
|
||||
}
|
||||
|
||||
// The shape the live check had: the node-engine member is the group's primary, so the composed request is asked with
|
||||
// Judge "validator" (a union of modules that includes mesh-host's) and the release branch set; the release judge then
|
||||
// put this change's validator into the old controller and "judge-with-this-validator" did not build.
|
||||
func TestAGroupsCompositionJudgedWithTheValidatorIntoAReleaseBranchIsJudgedByItsOwnController(t *testing.T) {
|
||||
groupIntoARelease(t, true)
|
||||
}
|
||||
|
||||
func groupIntoARelease(t *testing.T, hostPrimary bool) {
|
||||
if _, err := exec.LookPath("go"); err != nil {
|
||||
t.Skip("no Go toolchain on this machine to build a judge with")
|
||||
}
|
||||
const release = "feat/r"
|
||||
r := theGroupOfIssue867Into(t, release)
|
||||
aForgeWithBranches(t, map[string][]string{"novox/mesh-controller": {release}}, nil)
|
||||
// The pair renames what the validator says: the node-engine change drops Word for Word2, the controller change
|
||||
// calls Word2. The controller of the release branch calls Word, so it does not build with the new validator; the
|
||||
// controller change does not build with the validator it vendors. Only together are they consistent.
|
||||
r867Git(t, r.hostRepo, "checkout", "--quiet", "-b", "swap", release)
|
||||
r.hostHead = r867Commit(t, r.hostRepo, map[string]string{"validate/v.go": "package validate\n\nconst Word2 = \"the new validator\"\n"})
|
||||
r867Git(t, r.hostRepo, "checkout", "--quiet", "main")
|
||||
r867Git(t, r.controllerRepo, "checkout", "--quiet", "-b", "swap", release)
|
||||
swapped := strings.Replace(r867Controller("the controller", "")["cmd/mesh-controller/main.go"], "validate.Word)", "validate.Word2)", 1)
|
||||
r.controllerHead = r867Commit(t, r.controllerRepo, map[string]string{"cmd/mesh-controller/main.go": swapped})
|
||||
r867Git(t, r.controllerRepo, "checkout", "--quiet", "main")
|
||||
js, _ := aBuildQueue(t)
|
||||
servingBus.Store(js)
|
||||
t.Cleanup(func() { servingBus.Store(nil) })
|
||||
members := []orderMember{
|
||||
{ID: "novox/mesh-controller@" + r.controllerHead[:12], Repository: "novox/mesh-controller", Base: release,
|
||||
Head: r.controllerHead, Number: 346, Paths: []string{"lock.txt", "cmd/mesh-controller/main.go"}, ModuleDirsSaid: true},
|
||||
{ID: "novox/mesh-host@" + r.hostHead[:12], Repository: "novox/mesh-host", Base: release, Head: r.hostHead, Number: 114,
|
||||
Paths: []string{"validate/v.go"}, ModuleDirsSaid: true}}
|
||||
if hostPrimary {
|
||||
members[0], members[1] = members[1], members[0]
|
||||
}
|
||||
if _, err := askGroupCheck(t.Context(), r.open, "feat/867", members); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
q, err := link.ReadQueue(t.Context(), js, link.TheBuildMachine)
|
||||
if err != nil || len(q.Asks) == 0 {
|
||||
t.Fatalf("nothing was asked of the build seat: %v", err)
|
||||
}
|
||||
request := q.Asks[len(q.Asks)-1].Request
|
||||
if request.Check.Release != release || request.Check.Group != "feat/867" || len(request.Check.Members) != 1 || len(request.Check.Modules) == 0 {
|
||||
t.Fatalf("the composed check is asked as release %q, group %q, %d other head(s)", request.Check.Release,
|
||||
request.Check.Group, len(request.Check.Members))
|
||||
}
|
||||
if hostPrimary {
|
||||
if request.Check.Repo != "mesh-host" {
|
||||
t.Fatalf("the primary is %s, not the node-engine", request.Check.Repo)
|
||||
}
|
||||
// As the live ask had it (the mesh-host module among the union's): the node-engine's validator judges.
|
||||
request.Check.Judge = link.JudgeValidator
|
||||
}
|
||||
// What the build seat makes of the ask.
|
||||
var wire map[string]json.RawMessage
|
||||
body, _ := json.Marshal(request.Check)
|
||||
_ = json.Unmarshal(body, &wire)
|
||||
delete(wire, "group")
|
||||
delete(wire, "members")
|
||||
body, _ = json.Marshal(wire)
|
||||
var spec builder.CheckSpec
|
||||
if err := json.Unmarshal(body, &spec); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, m := range request.Check.Members {
|
||||
spec.Group = append(spec.Group, builder.GroupHead{Owner: m.Owner, Repo: m.Repo, Repository: m.Repository, Ref: m.Ref,
|
||||
Paths: m.Paths, Base: m.Base})
|
||||
}
|
||||
spec.ID, spec.Repository, spec.Ref = request.ID, request.Repository, request.Ref
|
||||
spec.Toolchain, spec.JudgeCache = "golang", r.judgeCache
|
||||
v, err := builder.Check(t.Context(), builder.Command, spec, t.TempDir(), r.registry, builder.GitCredential{}, nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if v.Gate == nil || v.Gate.Verdict != "pass" {
|
||||
t.Fatalf("the group's composition into %s was not judged by its own controller: %+v\n%s", release, v.Gate, v.Report)
|
||||
}
|
||||
if mark := "[release " + release + ", judged by the group's controller " + v.JudgedBy + "] "; !strings.HasPrefix(v.Gate.Summary, mark) ||
|
||||
!strings.Contains(v.Report, "by the group's controller at "+v.JudgedBy) {
|
||||
t.Fatalf("the statuses and the report do not say the group's controller judged:\n%s\n%s", v.Gate.Summary, v.Report)
|
||||
}
|
||||
if !strings.Contains(v.Gate.Summary, "the new validator") {
|
||||
t.Fatalf("the gate was judged by %q, not by the group's controller with the node-engine member's validator", v.Gate.Summary)
|
||||
}
|
||||
if !strings.HasPrefix(v.JudgeFrom, "the group's own controller") || !strings.Contains(v.Validator, "the group's mesh-host merge") {
|
||||
t.Fatalf("the verdict does not say where the judge and the validator came from: %q / %q", v.JudgeFrom, v.Validator)
|
||||
}
|
||||
if v.Release != release || v.JudgedBy == "" {
|
||||
t.Fatalf("the verdict names release %q judged by %q", v.Release, v.JudgedBy)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user