From 4d2003d77b0935ff6d7c323b00e35964d3e61fcd Mon Sep 17 00:00:00 2001 From: jochen Date: Tue, 29 Sep 2026 11:49:22 +0200 Subject: [PATCH] Run the real catalogue through the real manifest gate A test that reads every manifest in a catalogue checkout and parses it with the control plane's own parser, rather than asserting against a fixture: whether the manifests as written are accepted is the question, and a copy of one proves nothing about the other seventy-one. Skipped unless MESH_CATALOGUE names a checkout, so it costs nothing in ordinary runs and is there when the catalogue changes shape. It also refuses to pass if no endpoint is named, because a run that validated nothing would otherwise read as success. --- internal/catalogue/catalogue_check_test.go | 47 ++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 internal/catalogue/catalogue_check_test.go diff --git a/internal/catalogue/catalogue_check_test.go b/internal/catalogue/catalogue_check_test.go new file mode 100644 index 0000000..03b55db --- /dev/null +++ b/internal/catalogue/catalogue_check_test.go @@ -0,0 +1,47 @@ +package catalogue + +import ( + "os" + "path/filepath" + "testing" +) + +// TestEveryCatalogueManifestParses runs the real catalogue through the real gate. +// +// Not a fixture: the point is whether the manifests as written are accepted by the control plane that +// will read them, and a copy of one manifest proves nothing about the other seventy-one. +func TestEveryCatalogueManifestParses(t *testing.T) { + root := os.Getenv("MESH_CATALOGUE") + if root == "" { + t.Skip("set MESH_CATALOGUE to a catalogue checkout to run this") + } + found, err := filepath.Glob(filepath.Join(root, "modules", "*", "module.json")) + if err != nil || len(found) == 0 { + t.Fatalf("no manifests under %s: %v", root, err) + } + named, routed := 0, 0 + for _, p := range found { + raw, err := os.ReadFile(p) + if err != nil { + t.Fatalf("%s: %v", p, err) + } + m, err := ParseManifest(raw) + if err != nil { + t.Errorf("%s: %v", filepath.Base(filepath.Dir(p)), err) + continue + } + for _, l := range m.Listens { + if l.Name != "" { + named++ + } + } + for port := range RoutedPorts(m) { + _ = port + routed++ + } + } + t.Logf("%d manifests, %d named endpoints, %d routed endpoints resolved", len(found), named, routed) + if named == 0 { + t.Fatal("no endpoint in the catalogue is named, so this proved nothing") + } +}