mesh/delivery closed: a newer head of the same pull request
mesh/check checking 851e8782d569 on da29f77b1081 | novox/mesh-catalog#505 in group feat/1126-nodes-compose
One commit for the branch feat/1126-nodes-compose of mesh-catalog: its 15 commits squashed so its history does not carry two compiled programs committed by mistake and removed later, mesh-config (5.5 MB) and checks/placement (6.2 MB) (issue 1577). The tree equals the former head 2db56067. The operator allowed this rewrite of the feature branch on 2026-10-26.
56 lines
1.9 KiB
Go
56 lines
1.9 KiB
Go
package main
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// The catalogue's placement files as the merge check reads them (ADR 0549 §1, ADR 0555): the real tree holds every
|
|
// rule, and a tree that breaks them is refused with every finding named at once.
|
|
func TestPlacementFiles(t *testing.T) {
|
|
found, err := Check("../..")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
for _, f := range found {
|
|
t.Errorf("%s (novox/hq ADR 0549 §1)", f)
|
|
}
|
|
|
|
root := t.TempDir()
|
|
write := func(name, body string) {
|
|
t.Helper()
|
|
if err := os.MkdirAll(filepath.Join(root, "placement"), 0o755); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := os.WriteFile(filepath.Join(root, "placement", name), []byte(body), 0o644); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
if found, err := Check(root); err != nil || len(found) != 0 {
|
|
t.Fatalf("a catalogue with no placement directory: %v, %v", found, err)
|
|
}
|
|
write("ace.json", `{"v":1,"node":"ace","decided":{"hub":true,"address":"10.77.0.1"},"modules":[{"module":"a","ports":{"80":8080}},{"module":"b","ports":{"81":8080}}]}`)
|
|
write("g14.json", `{"v":1,"node":"g14","decided":{"hub":true,"address":"10.77.0.1"},"modules":[{"module":"c","bindings":{"pg":{"node":"ace","module":"pg"}}}]}`)
|
|
write("novox.json", `{"v":1,"node":"shanks","modules":[]}`)
|
|
write("bad.json", `{"v":1,"node":"bad","modules":{}}`)
|
|
write("dated.json", `{"v":1,"node":"dated","revision":"abc","modules":[]}`)
|
|
write("notes.md", "x")
|
|
found, err = Check(root)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
for _, want := range []string{"a and b are both published on host port 8080", "bound to ace/pg", "both have the address 10.77.0.1",
|
|
"ace, g14 are each placed as it", "placement file of novox names the node", "bad.json does not read", "dated.json names a revision",
|
|
"notes.md is not a placement file"} {
|
|
hit := false
|
|
for _, f := range found {
|
|
hit = hit || strings.Contains(f, want)
|
|
}
|
|
if !hit {
|
|
t.Errorf("no finding says %q; found %v", want, found)
|
|
}
|
|
}
|
|
}
|