From 7f6d418205f0bfe4d5c795a2e68697fe9d38ffc4 Mon Sep 17 00:00:00 2001 From: jochen Date: Thu, 22 Oct 2026 18:03:14 +0200 Subject: [PATCH] Mark the walks the integration tests drive around the one ask left as the builder's own, and expect no ask of a moved module (issue 1851, A5, A6) --- .../key_takein_integration_test.go | 6 ++-- .../one_group_one_plan_test.go | 17 ++++------ cmd/mesh-controller/queue_test.go | 1 + .../replays_integration_test.go | 32 ------------------- 4 files changed, 11 insertions(+), 45 deletions(-) diff --git a/cmd/mesh-controller/key_takein_integration_test.go b/cmd/mesh-controller/key_takein_integration_test.go index 24ba2d98..1b68c58d 100644 --- a/cmd/mesh-controller/key_takein_integration_test.go +++ b/cmd/mesh-controller/key_takein_integration_test.go @@ -66,10 +66,12 @@ func TestADoneKeyOfTheTrunkRegistersUnderTheSameRules(t *testing.T) { t.Fatalf("0501 §1: sudo is %q", shelf["sudo"].Version) } got, found, err := inv.BuildByID(ctx, kept.ID) - if err != nil || !found || len(got.Made) != 1 || got.Made[0].Reference != kept.Made[0].Reference || - got.SourceFingerprint != fpOf('a') { + if err != nil || !found || len(got.Made) != 1 || got.Made[0].Reference != kept.Made[0].Reference { t.Fatalf("0498 §8: the recorded build is %+v (%v)", got, err) } + if fps, err := inv.BuildSourceFingerprints(ctx, "sudo"); err != nil || fps["c0ffee0123456789"] != fpOf('a') { + t.Fatalf("0498 §8: the recorded build's fingerprint is %v (%v), not the key's", fps, err) + } // Recording the same key again is one record. if _, _, err := takeInKey(ctx, inv, keys, keyTake{Module: "sudo", Trunk: trunk, Ask: registrationAsk{Merge: trunk.Commit}}); err != nil { t.Fatal(err) diff --git a/cmd/mesh-controller/one_group_one_plan_test.go b/cmd/mesh-controller/one_group_one_plan_test.go index 14c7647a..60fd5201 100644 --- a/cmd/mesh-controller/one_group_one_plan_test.go +++ b/cmd/mesh-controller/one_group_one_plan_test.go @@ -109,8 +109,8 @@ func TestAFeatureWithANewSeatVerbIsOneBatchAndOnePlanInOrderWithNoAfterLine(t *t } // Issue 1049: a move delivered half before its second merge. The controller adds a module the catalogue removes, in one -// group: the merges are one batch and one plan in either order, the module is built once and from the controller's -// repository, and the catalogue's removal does not forget it. +// group: the merges are one batch and one plan in either order, no build of the module is asked (it is registered from +// the builder's key, ADR 0501 §6), and the catalogue's removal does not forget it. func TestAMoveOfAModuleAcrossTwoRepositoriesIsOnePlanAndBuildsItOnceFromTheNewOne(t *testing.T) { for name, controllerFirst := range map[string]bool{"controller_first": true, "catalogue_first": false} { t.Run(name, func(t *testing.T) { @@ -149,17 +149,12 @@ func TestAMoveOfAModuleAcrossTwoRepositoriesIsOnePlanAndBuildsItOnceFromTheNewOn if len(ws) != 1 || len(bs) != 0 { t.Fatalf("a move: %d walk(s), %d batch(es); want exactly one plan", len(ws), len(bs)) } - var fromController int + // **No build of it is asked from either repository** (ADR 0501 §6, issue 1851): the move is registered from the + // builder's done key of route-proxy in the controller's repository, on the operator's Approve of the group. for _, a := range *asked { - if strings.Contains(a[0], "mesh-controller") && a[1] == "modules/route-proxy" { - fromController++ + if a[1] == "modules/route-proxy" { + t.Errorf("a build of route-proxy was asked: %v", a) } - if strings.Contains(a[0], "mesh-catalog") && a[1] == "modules/route-proxy" { - t.Errorf("route-proxy was built from the repository it left: %v", a) - } - } - if fromController != 1 { - t.Fatalf("route-proxy was built %d time(s) from the controller's repository: %v", fromController, *asked) } entries, err := open.inventory.Catalogued(ctx) if err != nil { diff --git a/cmd/mesh-controller/queue_test.go b/cmd/mesh-controller/queue_test.go index eb997872..43219812 100644 --- a/cmd/mesh-controller/queue_test.go +++ b/cmd/mesh-controller/queue_test.go @@ -24,6 +24,7 @@ import ( // asksRecorded makes every ask a plan makes return the next id in a row, and says which were asked. func asksRecorded(t *testing.T) *[]string { t.Helper() + asksOfEveryModule(t) // the one ask left is the builder's own (ADR 0453 §5): these tests are of what a walk does around it var asked []string was := askABuild askABuild = func(_ context.Context, source buildSource, path, ref string) (string, error) { diff --git a/cmd/mesh-controller/replays_integration_test.go b/cmd/mesh-controller/replays_integration_test.go index deb14f0b..37a4531d 100644 --- a/cmd/mesh-controller/replays_integration_test.go +++ b/cmd/mesh-controller/replays_integration_test.go @@ -418,38 +418,6 @@ func TestReplay299AHolderOfASeatWhoseVerbsAreAllOptionalIsNotSilent(t *testing.T } } -func TestReplay300AMergeAddingAModuleAsksForItsBuild(t *testing.T) { - open := aMesh(t) - ctx := t.Context() - inv := open.inventory - var asked [][3]string - asksOfEveryModule(t) // the one ask left is the builder's own (ADR 0453 §5): this test is of what a walk does around it - was := askABuild - askABuild = func(_ context.Context, source buildSource, path, ref string) (string, error) { - asked = append(asked, [3]string{source.Repository, path, ref}) - return "build-" + path, nil - } - t.Cleanup(func() { askABuild = was }) - if err := inv.RegisterModule(ctx, catalogue.Manifest{Module: "networkmanager", Version: "1"}, - inventory.Source{Repository: "novox/mesh-catalog", Seat: "git", Path: "modules/networkmanager", Ref: "main", - BuiltFrom: "c0", Head: "c0"}); err != nil { - t.Fatal(err) - } - m := link.SourceMoved{Owner: "novox", Repo: "mesh-catalog", Base: "main", Commit: "3da80a4b00", - Paths: []string{"modules/systemd-resolved/module.json", "modules/systemd-resolved/cmd/main.go"}, - ModuleDirs: []string{"modules/systemd-resolved"}, ModuleDirsSaid: true} - if err := (following{open: open}).SourceMoved(ctx, m); err != nil { - t.Fatal(err) - } - want := [3]string{"novox/mesh-catalog", "modules/systemd-resolved", "main"} - if len(asked) != 1 || asked[0] != want { - t.Fatalf("the merge adding modules/systemd-resolved asked the build seat for %v, not %v", asked, want) - } - if plans, err := inv.OpenPlans(ctx); err != nil || len(plans) != 0 { - t.Fatalf("a merge moving nothing the mesh holds opened a plan: %+v %v", plans, err) - } -} - func TestReplay301APersonsPushOfAHeldRecordedBuildIsNoRepair(t *testing.T) { open := aMesh(t) ctx := t.Context()