From aab65b81f65c3a2984e0c3b8dd7af1219d2650e5 Mon Sep 17 00:00:00 2001 From: jochen Date: Sun, 18 Oct 2026 19:28:07 +0200 Subject: [PATCH] Read the build agent's manifest from the controller's repository beside the check, where it moved (issue 1151) --- internal/bootstrap/builder_test.go | 41 ++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/internal/bootstrap/builder_test.go b/internal/bootstrap/builder_test.go index f4158f1..6127d47 100644 --- a/internal/bootstrap/builder_test.go +++ b/internal/bootstrap/builder_test.go @@ -148,21 +148,26 @@ func TestAForgeManifestTheCatalogueDoesNotHaveIsNamed(t *testing.T) { } } -// theCataloguesModule is the catalogue's own manifest of a module, never a copy: the clone beside a merge -// check (MESH_CHECK_BESIDE), where it must be; else a checkout beside this one; else the test skips aloud. +// theCataloguesModule is a module's own manifest, never a copy: the clone beside a merge check (MESH_CHECK_BESIDE), where it +// must be; else a checkout beside this one; else the test skips aloud. The catalogue holds it, but for the build agent, +// which moved whole into the controller's repository (ADR 0420, issue 1019, issue 1151) and is read from there. func theCataloguesModule(t *testing.T, module string) []byte { t.Helper() - inside := filepath.Join("mesh-catalog", "modules", module, "module.json") + repository := "mesh-catalog" + if module == BuilderModule { + repository = "mesh-controller" + } + inside := filepath.Join(repository, "modules", module, "module.json") if root := os.Getenv("MESH_CHECK_BESIDE"); root != "" { raw, err := os.ReadFile(filepath.Join(root, inside)) if err != nil { - t.Fatalf("the catalogue beside this check (MESH_CHECK_BESIDE=%s) has no %s: %v", root, inside, err) + t.Fatalf("%s beside this check (MESH_CHECK_BESIDE=%s) has no %s: %v", repository, root, inside, err) } return raw } raw, err := os.ReadFile(filepath.Join("..", "..", "..", inside)) if err != nil { - t.Skipf("NOT JUDGED: no catalogue beside this checkout and no MESH_CHECK_BESIDE; the merge check judges it") + t.Skipf("NOT JUDGED: no %s beside this checkout and no MESH_CHECK_BESIDE; the merge check judges it", repository) } return raw } @@ -217,3 +222,29 @@ func TestABuildAgentManifestWithNowhereForTheCarriedBuilderIsRefused(t *testing. t.Fatalf("a manifest with no image artifact was pinned: %v", err) } } + +// 1151: the build agent's manifest lives in the controller's repository now (ADR 0420, issue 1019), and a merge check of +// this repository has the controller cloned beside it, so a tree shaped like that check's, whose catalogue no longer holds +// the build agent, is read from the controller. +func TestTheBuildAgentsManifestIsReadFromTheControllerBesideTheCheck(t *testing.T) { + beside := t.TempDir() + for path, body := range map[string]string{ + "mesh-catalog/modules/nats/module.json": `{"module":"nats"}`, + "mesh-controller/modules/build-agent/module.json": `{"module":"build-agent"}`, + } { + full := filepath.Join(beside, path) + if err := os.MkdirAll(filepath.Dir(full), 0o755); err != nil { + t.Fatal(err) + } + if err := os.WriteFile(full, []byte(body), 0o644); err != nil { + t.Fatal(err) + } + } + t.Setenv("MESH_CHECK_BESIDE", beside) + if got := string(theCataloguesModule(t, BuilderModule)); got != `{"module":"build-agent"}` { + t.Errorf("read %s", got) + } + if got := string(theCataloguesModule(t, "nats")); got != `{"module":"nats"}` { + t.Errorf("a module the catalogue holds was read as %s", got) + } +}