Judge the SDK conformance fixtures against the SDK the controller pins, never a desktop's checkout (issue 449)
A check clones mesh-sdk beside the controller at the commit go.mod pins; elsewhere the test reads a copy captured at that commit, held to go.mod. A missing clone fails instead of skipping.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// Package beside is where a test finds another repository of the mesh it reads: the catalogue's manifests,
|
||||
// the node-engine's genesis template (novox/hq issue 432).
|
||||
// the node-engine's genesis template (novox/hq issue 432), the SDK's conformance fixtures (issue 449).
|
||||
//
|
||||
// A test used to read the checkout beside this one, `../../../mesh-catalog`, so its verdict depended on
|
||||
// whatever sat on the machine running it: a stale or dirty checkout failed it on a desktop, and where none
|
||||
@@ -10,7 +10,8 @@
|
||||
// test judges against those clones, so agreement with the other repository is checked where
|
||||
// `mesh/repo-check` runs; a repository missing there fails the test, never skips it. Which clones a
|
||||
// check gets is chosen from the inventory: mesh-catalog by the source of the `nats` module, mesh-host
|
||||
// by the source of `mesh-host`. In a mesh where either module has no source repository nothing is
|
||||
// by the source of `mesh-host`, and mesh-sdk as the controller's sibling at the commit the controller's
|
||||
// go.mod pins. In a mesh where either module has no source repository nothing is
|
||||
// cloned, and these tests fail loudly with "not beside this check": a cause in the setup, not in the
|
||||
// change. And in a delivery group that holds a mesh-catalog pull request, these tests read the
|
||||
// catalogue's main, not the group's head.
|
||||
|
||||
@@ -5,15 +5,21 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/novox/mesh-controller/internal/beside"
|
||||
)
|
||||
|
||||
// The Go implementation, held to the shared fixtures (novox/hq ADR 0074, design 19).
|
||||
//
|
||||
// **Read from the sdk's conformance directory by sibling path**, the way the lab finds its
|
||||
// siblings — deliberately not copied here. A fixture copied into each implementation is two
|
||||
// fixtures, and two fixtures drift, which is the exact failure the suite exists to prevent.
|
||||
// **Read from the SDK's own conformance directory, never copied by hand**: a fixture written into each
|
||||
// implementation is two fixtures, and two fixtures drift, which is the failure the suite exists to prevent.
|
||||
// Which SDK is read is named, never the one a desktop happens to hold beside this checkout (novox/hq issue
|
||||
// 449): in a merge check the SDK the build seat clones beside it, at the commit this controller's go.mod
|
||||
// pins, and a missing clone fails the test; elsewhere the copy captured in testdata/beside at that same
|
||||
// commit (internal/beside, testdata/beside/CAPTURED), held to go.mod by TestTheCapturedSDKIsTheOneGoModPins.
|
||||
type fixture struct {
|
||||
Name string `json:"name"`
|
||||
Given struct {
|
||||
@@ -32,10 +38,11 @@ type fixture struct {
|
||||
|
||||
func loadFixture(t *testing.T, name string) fixture {
|
||||
t.Helper()
|
||||
path := filepath.Join("..", "..", "..", "mesh-sdk", "conformance", name)
|
||||
path := filepath.Join(beside.Dir(t, "mesh-sdk"), "conformance", name)
|
||||
raw, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
t.Skipf("the sdk's conformance fixtures are not beside this checkout: %v", err)
|
||||
// Failed, never skipped: a skip here passed the suite with nothing judged.
|
||||
t.Fatalf("the SDK's conformance fixture %s: %v", name, err)
|
||||
}
|
||||
var f fixture
|
||||
if err := json.Unmarshal(raw, &f); err != nil {
|
||||
@@ -44,6 +51,33 @@ func loadFixture(t *testing.T, name string) fixture {
|
||||
return f
|
||||
}
|
||||
|
||||
// The captured SDK is the one this controller is built against: when go.mod moves the SDK, the copy moves
|
||||
// with it, or the tests away from a merge check judge an SDK the controller no longer uses (novox/hq issue
|
||||
// 449).
|
||||
func TestTheCapturedSDKIsTheOneGoModPins(t *testing.T) {
|
||||
mod, err := os.ReadFile(filepath.Join("..", "..", "go.mod"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
pinned := regexp.MustCompile(`(?m)^\s*git\.novox\.be/novox/mesh-sdk/go v\S+-([0-9a-f]{12})$`).FindSubmatch(mod)
|
||||
if pinned == nil {
|
||||
t.Fatal("go.mod pins no commit of git.novox.be/novox/mesh-sdk/go as a pseudo-version; say here how a " +
|
||||
"release's tag is matched against testdata/beside/CAPTURED")
|
||||
}
|
||||
captured, err := os.ReadFile(filepath.Join(beside.Captured(), "CAPTURED"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
at := regexp.MustCompile(`(?m)^mesh-sdk\s+([0-9a-f]{40})\s`).FindSubmatch(captured)
|
||||
if at == nil {
|
||||
t.Fatal("testdata/beside/CAPTURED names no commit for mesh-sdk")
|
||||
}
|
||||
if !strings.HasPrefix(string(at[1]), string(pinned[1])) {
|
||||
t.Errorf("the SDK is captured at %s but go.mod pins %s: capture it again at the pinned commit, as "+
|
||||
"testdata/beside/CAPTURED says", at[1], pinned[1])
|
||||
}
|
||||
}
|
||||
|
||||
// Every header the fixture requires is one this implementation actually sets.
|
||||
func TestTheGoEmitterSetsEveryRequiredHeader(t *testing.T) {
|
||||
f := loadFixture(t, "events/module-event.json")
|
||||
|
||||
Reference in New Issue
Block a user