Check the tool runtime's own code before it merges, every test on a bus of its own (hq ADR 0237)

A merge-check.sh, the repository's layer of the mesh's merge check (mesh/repo-check):
format, vet, and node-tools' suite under the race detector. The tests shared one bus and
had to run one package at a time; like the controller's (#97), each now starts a server
of its own at the release go.mod pins, held to the catalogue's bus image by a test. What
cannot run in the check — bundles that need @novox/mesh-sdk — is said as not tested.
This commit is contained in:
jochen
2026-10-06 22:04:46 +02:00
parent c2a0683115
commit 14bff5dfd7
5 changed files with 180 additions and 7 deletions
@@ -0,0 +1,75 @@
package meshtest
import (
"encoding/json"
"os"
"path/filepath"
"regexp"
"strings"
"testing"
)
// **The bus the tests run is the bus the mesh runs** (novox/hq ADR 0227 rule 9, ADR 0237): the server linked
// into the tests is held to the release the catalogue's bus image is — read from beside this checkout, as
// the build seat clones it for a merge check — and, given the facts snapshot, to the release the mesh's bus
// server says it runs. A bus upgrade moves the catalogue's pin; this then fails until go.mod's moves with it.
func TestTheBusTheTestsRunIsTheBusTheMeshRuns(t *testing.T) {
beside := os.Getenv("MESH_CHECK_BESIDE")
if beside == "" {
beside = filepath.Join("..", "..", "..", "..")
}
dockerfile := filepath.Join(beside, "mesh-catalog", "modules", "nats", "Dockerfile")
raw, err := os.ReadFile(dockerfile)
switch {
case err == nil:
pinned := regexp.MustCompile(`upstream: nats ([0-9.]+)-alpine`).FindSubmatch(raw)
if pinned == nil {
t.Fatalf("%s says no release its digest is", dockerfile)
}
if string(pinned[1]) != Version {
t.Errorf("the tests run bus %s and the catalogue's bus image is %s: move go.mod's nats-server pin with the image",
Version, pinned[1])
}
case os.IsNotExist(err):
t.Logf("the catalogue is not beside this checkout, so its bus image is not compared")
default:
t.Fatal(err)
}
path := os.Getenv("MESH_FACTS")
if path == "" {
t.Logf("no MESH_FACTS: the bus the mesh runs is compared in a merge check, which has it")
return
}
body, err := os.ReadFile(path)
if err != nil {
t.Fatal(err)
}
var f struct {
Taken string `json:"taken"`
Versions struct {
Bus string `json:"bus"`
} `json:"versions"`
}
if err := json.Unmarshal(body, &f); err != nil {
t.Fatal(err)
}
if f.Versions.Bus != "" && strings.TrimPrefix(f.Versions.Bus, "v") != Version {
t.Errorf("the tests run bus %s and the mesh's bus runs %s (facts of %s)", Version, f.Versions.Bus, f.Taken)
}
}
// Each test is given a bus of its own, and the same one at every ask.
func TestEachTestHasABusOfItsOwn(t *testing.T) {
var first string
t.Run("one", func(t *testing.T) {
first = URL(t)
if URL(t) != first {
t.Fatal("two buses for one test")
}
})
t.Run("two", func(t *testing.T) {
if URL(t) == first {
t.Fatal("two tests were given one bus")
}
})
}