Compare commits
34
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6a30dcb372 | ||
|
|
72ea2988be | ||
|
|
9294defef8 | ||
|
|
f024be6e04 | ||
|
|
b053dc66bf | ||
|
|
c0b1225f6d | ||
|
|
5ba88c69fa | ||
|
|
8635560993 | ||
|
|
f9be71b9ad | ||
|
|
307dd23d6d | ||
|
|
dcaf843b8a | ||
|
|
7ed7da1398 | ||
|
|
1316a405a6 | ||
|
|
a0754ab06d | ||
|
|
adaf525a88 | ||
|
|
a8d86bb10b | ||
|
|
9deefc6370 | ||
|
|
d7098c4b27 | ||
|
|
d21949c041 | ||
|
|
7806a42c45 | ||
|
|
f71250c3dd | ||
|
|
ba2806b985 | ||
|
|
9497dda929 | ||
|
|
3b4ba29bec | ||
|
|
3eb48c949f | ||
|
|
5f13bf0aff | ||
|
|
73800225c3 | ||
|
|
becff66e0a | ||
|
|
2aebf8f40e | ||
|
|
0ca7a83e0b | ||
|
|
d16c3db9d2 | ||
|
|
39ec294853 | ||
|
|
6ba65a12f2 | ||
|
|
ea24e7890f |
@@ -3,8 +3,10 @@ package asks
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"html"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"regexp"
|
||||
"strings"
|
||||
"sync"
|
||||
"testing"
|
||||
@@ -100,6 +102,11 @@ func (f *fakeTelegram) serve(w http.ResponseWriter, r *http.Request) {
|
||||
case "sendMessage", "editMessageText":
|
||||
chat := int64(num(body["chat_id"]))
|
||||
text, _ := body["text"].(string)
|
||||
if mode, _ := body["parse_mode"].(string); mode == "HTML" {
|
||||
// What a message shows, and what a tap on it carries back, is its text with the markup read: tags gone,
|
||||
// entities unescaped — as the service gives it (novox/hq issue 692).
|
||||
text = shownOfHTML(text)
|
||||
}
|
||||
m := tgMessage{Chat: chat, Text: text, Buttons: buttonsOf(body["reply_markup"]), At: time.Now()}
|
||||
f.mu.Lock()
|
||||
if method == "sendMessage" {
|
||||
@@ -324,3 +331,21 @@ func firstLine(s string) string {
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
var htmlTag = regexp.MustCompile(`</?[a-zA-Z][^>]*>`)
|
||||
|
||||
// shownOfHTML is a text sent in Telegram's HTML as the service shows it and gives it back: its tags read and taken
|
||||
// out, its entities written as the characters they stand for.
|
||||
func shownOfHTML(text string) string {
|
||||
return html.UnescapeString(htmlTag.ReplaceAllString(text, ""))
|
||||
}
|
||||
|
||||
// The fake phone shows a message sent in HTML as Telegram does (novox/hq issue 692): the words without their
|
||||
// markup, so a tap carries back what the channel digests, as on the real service.
|
||||
func TestTheFakePhoneShowsHTMLAsTelegramDoes(t *testing.T) {
|
||||
in := "<b>Flip the lab's switch?</b>\nA <b> & c\n<code>+ k: v</code>\n\n<blockquote expandable>Asked by lab-asker.</blockquote>"
|
||||
want := "Flip the lab's switch?\nA <b> & c\n+ k: v\n\nAsked by lab-asker."
|
||||
if got := shownOfHTML(in); got != want {
|
||||
t.Errorf("%q, want %q", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ sh -n live-acceptance.sh
|
||||
go vet ./...
|
||||
out=$(mktemp)
|
||||
status=0
|
||||
go test -count=1 -timeout 25m -v -run '^TestTheOperatorsAnswerEndToEnd$' . >"$out" 2>&1 || status=$?
|
||||
go test -count=1 -timeout 25m -v -run '^(TestTheOperatorsAnswerEndToEnd|TestTheFakePhoneShowsHTMLAsTelegramDoes)$' . >"$out" 2>&1 || status=$?
|
||||
grep -E '^(--- | --- |ok|FAIL|PASS)' "$out" || true
|
||||
if grep -q 'NOT RUN' "$out"; then
|
||||
echo "NOT RUN: THE PROOF OF THE OPERATOR'S ANSWERS DID NOT RUN HERE:"
|
||||
|
||||
+2
-1
@@ -109,6 +109,7 @@ func (d *Docker) RemoveNetwork(ctx context.Context, id string) {
|
||||
type Run struct {
|
||||
Image string
|
||||
Cmd []string
|
||||
Env []string
|
||||
Binds []string
|
||||
Network string
|
||||
DNS []string
|
||||
@@ -138,7 +139,7 @@ func (d *Docker) Start(ctx context.Context, r Run) (string, string, error) {
|
||||
path += "?name=" + url.QueryEscape(r.Name)
|
||||
}
|
||||
if err := d.call(ctx, http.MethodPost, path, map[string]any{"Image": r.Image, "Cmd": r.Cmd,
|
||||
"Labels": labels, "HostConfig": host}, &made); err != nil {
|
||||
"Env": r.Env, "Labels": labels, "HostConfig": host}, &made); err != nil {
|
||||
return "", "", err
|
||||
}
|
||||
if err := d.call(ctx, http.MethodPost, "/containers/"+made.ID+"/start", nil, nil); err != nil {
|
||||
|
||||
@@ -498,6 +498,166 @@ var Register = []Replay{
|
||||
"whose module does not declare the seat's paths is refused naming each",
|
||||
Package: "./internal/catalogue", Test: "TestReplay412", Files: []string{"internal/catalogue/replay412_test.go"},
|
||||
Home: "mesh-controller", HomeRef: "3bdab29a5a0ed0f15cbfdb4738a321f968ac9467"},
|
||||
// A verb set what every agent session obeys (2026-10-09): the agent's module keeps the managed settings and tool
|
||||
// servers every Claude Code session on a node obeys in a mergeable file, and the settings verb took any key for it
|
||||
// from any caller, so an agent could plant a SessionStart hook in the operator's sessions on every node; an
|
||||
// identity provider's empty runtime configuration took a url of the caller's the same way. The fix's own tests
|
||||
// read what the fix added, so the replay is a test of its own in the controller, written with only what it had
|
||||
// before — a mesh, a registered manifest, an assignment, the settings verb run as a verb and as the terminal runs
|
||||
// it, the inventory's layer — laid over the commit before. Needs a store: MESH_TEST_POSTGRES. Fix is the merge of
|
||||
// its pull request (mesh-controller #172); Home is the commit that added the replay, reachable once its pull
|
||||
// request merges.
|
||||
{ID: "R340", Issue: 340, Kind: InRepository, Repository: "mesh-controller", Fix: "4d60628f37530c23c072011a697e6014de14b3f6",
|
||||
What: "the settings verb took a SessionStart hook in the agent module's managed settings, a tool server of the " +
|
||||
"caller's, and a url for an identity provider's empty runtime configuration, from any caller of the mesh's verbs",
|
||||
Asserts: "through a verb, any change to the layer of a module with a mergeable file not marked trusted: false is " +
|
||||
"refused as the controller's terminal's and leaves the layer as it was; at the terminal it is taken",
|
||||
Package: "./cmd/mesh-controller", Test: "TestReplay340", Files: []string{"cmd/mesh-controller/replay340_test.go"},
|
||||
Home: "mesh-controller", HomeRef: "e44c726a38125ade30a6d70cee9873a4e2ea6ac2"},
|
||||
// A merge acted on late superseded the merge after it (2026-10-09): two catalogue merges were acted on in reverse
|
||||
// order. The later one, a security fix to the forge's module, was planned first; the earlier one, handed over late,
|
||||
// was planned after it, superseded its plan at tier 0 and planned the fixed module again at the commit without the
|
||||
// fix, because a plan's age was read from when it was made, never from the branch's order. The fix (mesh-controller
|
||||
// #179) ordered a branch's plans by their merge times and planned a late merge at the newer commit; ADR 0276
|
||||
// (mesh-controller #197) later replaced that with batches, and the replay holds the outcome under both. A test of its
|
||||
// own in the controller, written with only what it had before — a mesh, registered modules, following.SourceMoved,
|
||||
// the plans the inventory keeps — laid over the commit before. Needs a store: MESH_TEST_POSTGRES. Fix is the merge of
|
||||
// its pull request; Home is the commit that added the replay, reachable once its pull request merges.
|
||||
{ID: "R349", Issue: 349, Kind: InRepository, Repository: "mesh-controller", Fix: "9ca7952d5e0a5ed1e23bdcf5aea36fe967e62d14",
|
||||
What: "a merge handed over late superseded the plan of the merge made after it, and planned the module that " +
|
||||
"merge fixed again at the earlier commit, without the fix",
|
||||
Asserts: "with the later merge acted on first and the earlier one after it, every plan left standing that plans " +
|
||||
"the fixed module plans it at the later merge's commit, and one does",
|
||||
Package: "./cmd/mesh-controller", Test: "TestReplay349", Files: []string{"cmd/mesh-controller/replay349_test.go"},
|
||||
Home: "mesh-controller", HomeRef: "5740874ce3b99b47c27403f33e6c6d2a334ad3d7"},
|
||||
// A resolver that stopped answering ran on unnoticed, and builds sent after it were blamed for it (2026-10-09):
|
||||
// the control node's resolver refused every question on its private address from 10:57:57 UTC and the machine's
|
||||
// network condition was raised at 10:58:45. The controller and the node-engine sent at 10:59:34 failed their gate
|
||||
// with "raised since it was sent", because the restarted engine's first, undecided statement cleared the condition
|
||||
// and its next look raised it anew after the send. A test of its own in the controller, written with only what it
|
||||
// had before — a mesh, stateHealth, the keeper's open conditions, aboutTheMachine — laid over the commit before.
|
||||
// Needs a store: MESH_TEST_POSTGRES. Fix is the merge of its pull request (mesh-controller #179); Home is the
|
||||
// commit that added the replay, reachable once its pull request merges. The resolver's own half — it binds each
|
||||
// address once and its watch asks it a real question and restarts it (mesh-catalog #161, 105cc7c0) — has no
|
||||
// replay here: the module had no Go before that fix, and the binding's loss was never reproduced past the burst
|
||||
// that caused it (hq issue 348's diagnosis); dnsmasq's own tests and the controller's manifest test hold it.
|
||||
{ID: "R348", Issue: 348, Kind: InRepository, Repository: "mesh-controller", Fix: "9ca7952d5e0a5ed1e23bdcf5aea36fe967e62d14",
|
||||
What: "a network fault raised before a send was cleared by a restarted node-engine's undecided statement and " +
|
||||
"raised again after it, and the gate put back the builds sent after the fault began",
|
||||
Asserts: "a build sent while the machine's network condition is open, which flaps after the send, is not held " +
|
||||
"for it, and an undecided statement does not clear the condition",
|
||||
Package: "./cmd/mesh-controller", Test: "TestReplay348AFaultFromBeforeTheSendFailsNoGate",
|
||||
Files: []string{"cmd/mesh-controller/replay348_test.go"},
|
||||
Home: "mesh-controller", HomeRef: "6eea92c323f4862d4162f9d977c8783d8a62efc3"},
|
||||
// A credential only a person can give was made anyway (found provisioning the media machine, re-checked
|
||||
// 2026-10-08): a Servarr app's API key, an indexer's key and a downloader's password are held by the provider's
|
||||
// software, and for each consumer of them the send made a random pair credential, sealed it to both ends and
|
||||
// placed it; the provider refused it, and a consumer retrying it could be banned (ADR 0337: such a credential is
|
||||
// never made). A test of its own in the controller, written with only what it had before the fix — register,
|
||||
// assign, planFor, declarationFor, AcceptSecretForPair, SecretsOf — laid over the commit before. Needs a store:
|
||||
// MESH_TEST_POSTGRES. Fix is the merge of its pull request (mesh-controller #298), which also added the replay.
|
||||
{ID: "R164", Issue: 164, Kind: InRepository, Repository: "mesh-controller", Fix: "584aa2d7d7a5a68b5087970feb93d0b1f1d4f503",
|
||||
What: "the send made a random pair credential for a provision whose credential only a person can give, and " +
|
||||
"placed it: the provider refused it",
|
||||
Asserts: "for a provision whose offer says its credential is issued outside the mesh, the send makes no value " +
|
||||
"and places none, the consumer's machine still composes, and a value a person gave for the pair is placed",
|
||||
Package: "./cmd/mesh-controller", Test: "TestReplay164", Files: []string{"cmd/mesh-controller/replay164_test.go"}},
|
||||
// A README-only merge made a new digest of an unchanged Go program (2026-10-13): a module built from its
|
||||
// repository's root is compiled with the clone's .git in view, and Go stamped the commit into the binary — the
|
||||
// node-engine on the laptop carried vcs.revision=7a41e120… — so a rebuild of an unchanged build source was a new
|
||||
// program (novox/hq ADR 0267 rule 6). The builder run whole, Build to the packed bundle, at two commits differing
|
||||
// only in README.md, with the toolchain's command run on this machine; written with only what the builder had
|
||||
// before. Fix is the merge of its pull request (mesh-controller #292); Home is the commit that added the replay,
|
||||
// reachable once its pull request merges.
|
||||
{ID: "R363", Issue: 363, Kind: InRepository, Repository: "mesh-controller", Fix: "cd6757f1e3c818bc6043178bfb4edb42b8f3c63d",
|
||||
What: "two builds of a Go module built from its repository's root, at commits differing only in its README, " +
|
||||
"made two digests: the commit was stamped into the binary",
|
||||
Asserts: "two builds of one Go module whose sources differ only outside its build source give one digest",
|
||||
Package: "./internal/builder", Test: "TestReplay363", Files: []string{"internal/builder/replay363_test.go"},
|
||||
Home: "mesh-controller", HomeRef: "94c928b1f5af099c328eb6950550b6380df24b31"},
|
||||
// A module's name was taken over by another repository (2026-10-04): the photo app's module was registered from
|
||||
// the app's own repository, and rebuilding it "to main" built the catalogue's stub of the same name instead. The
|
||||
// controller registered the outcome, recorded the catalogue as the module's source, and the next push replaced the
|
||||
// app with the stub: two sites' containers and five routes went. The fix (mesh-controller #174, hq ADR 0266 §7)
|
||||
// registers an outcome only from the repository the module is registered from, unless asked at the controller's
|
||||
// terminal. A test of its own in the controller, written with only what it had before — a mesh, RegisterModule,
|
||||
// SourceOf, a kept build request, takeIn — laid over the commit before. Needs a store: MESH_TEST_POSTGRES. Fix is
|
||||
// the merge of its pull request; Home is the commit that added the replay, reachable once its pull request merges.
|
||||
{ID: "R239", Issue: 239, Kind: InRepository, Repository: "mesh-controller", Fix: "eb7a15808641f2075d9fd1660fa0e949b9cd7230",
|
||||
What: "a build of a module's name from another repository was registered over the module's own, and the next " +
|
||||
"push replaced the photo app with the catalogue's stub",
|
||||
Asserts: "a build asked through a verb, of a module's name from a repository other than the one it is registered " +
|
||||
"from, is refused naming both sources, and the module keeps its source and version",
|
||||
Package: "./cmd/mesh-controller", Test: "TestReplay239AModuleNameIsNotTakenOverByAnotherRepository",
|
||||
Files: []string{"cmd/mesh-controller/replay239_test.go"},
|
||||
Home: "mesh-controller", HomeRef: "95556b8def3f3f21e3d037617d73f97606e6ea1f"},
|
||||
// A new SDK rebuilt neither its toolchain nor the bundles compiled in it (2026-10-13): mesh-sdk 0.1.14 planned
|
||||
// "builds mesh-sdk, sent nowhere". A built manifest is registered without its `build`, so mesh-tools' `build.on`
|
||||
// naming the SDK's package and every bundle's toolchain were edges only before a module's first build — the
|
||||
// fixes of issues 211 and 212 lost once modules were built. The fix (mesh-controller #296) reads them from what is
|
||||
// kept: the package's name@version a build stood on, and the bundles' languages. A test of its own in the
|
||||
// controller, written with only what it had before — RegisterModule, RecordBuild, theGraph, pullScope, reasoned
|
||||
// as `delivery-plan` reasons — laid over main, where it plans [[mesh-sdk]]. Needs a store: MESH_TEST_POSTGRES.
|
||||
// Fix is the merge of its pull request.
|
||||
{ID: "R614", Issue: 614, Kind: InRepository, Repository: "mesh-controller",
|
||||
Fix: "404b4409e70ed7365bb8a53862e4b197deb0bdc6",
|
||||
What: "a new SDK was planned alone: neither the toolchain built on its package nor the TypeScript bundles " +
|
||||
"compiled in that toolchain were rebuilt, so the SDK's fix reached no machine",
|
||||
Asserts: "a change to the SDK plans the SDK, then the toolchain, then every bundle compiled in it, from modules " +
|
||||
"registered as built and builds recorded with what they stood on",
|
||||
Package: "./cmd/mesh-controller", Test: "TestReplay614ANewSDKPlansTheToolchainAndThenItsBundles",
|
||||
Files: []string{"cmd/mesh-controller/replay614_test.go"}},
|
||||
// A mesh-host change and a mesh-controller change of one delivery group that need each other could not both pass
|
||||
// their own merge checks (2026-10-16, issue 867): each was read beside the other's repository at the commit the mesh
|
||||
// runs, which holds neither change. The fix (mesh-controller #348, hq ADR 0382) asks mesh-delivery's groups once per
|
||||
// check and reads each sibling's repository at its merge. TestReplay867 runs the whole path — the forge's
|
||||
// announcement, the controller's ask, the build seat's check with a container runtime that runs on this machine —
|
||||
// for the pair, written with only what the controller and the build seat had before. Needs a store:
|
||||
// MESH_TEST_POSTGRES. R-issue867-recheck, R-issue867-recheck-verb and R-issue867-release-group are the three defects found live in the same fix, each with its own merge.
|
||||
{ID: "R867", Issue: 867, Kind: InRepository, Repository: "mesh-controller",
|
||||
Fix: "a47976be4e699c35681be87c48ecfedd793374cd",
|
||||
What: "a mesh-host change and a mesh-controller change of one delivery group, each needing the other, could not " +
|
||||
"both pass their own merge check: each was read beside the other at the commit the mesh runs",
|
||||
Asserts: "each member of a delivery group passes its own merge check, read beside the other member's head " +
|
||||
"merged onto its base",
|
||||
Package: "./cmd/mesh-controller", Test: "TestReplay867", Files: []string{"cmd/mesh-controller/replay867_test.go"}},
|
||||
// A recheck announces the pull request without its head branch, so its group was not found and the verdict said
|
||||
// nothing of its siblings (mesh-controller #350): the group is found by repository and number.
|
||||
{ID: "R-issue867-recheck", Issue: 867, Kind: InRepository, Repository: "mesh-controller",
|
||||
Fix: "af60d2719c0c6c2f1ff44347037280d6ba5e72b4",
|
||||
What: "a recheck of a group member read no siblings: it carries no head branch name, and the group was found by it",
|
||||
Asserts: "a pull request announced as a recheck is, without its head branch, found in its group by repository " +
|
||||
"and number, and passes beside its sibling",
|
||||
Package: "./cmd/mesh-controller", Test: "TestReplay867Recheck", Files: []string{"cmd/mesh-controller/replay867_test.go"}},
|
||||
// `delivery check` runs as a command of its own, where the controller is not the serving one: it asked mesh-delivery
|
||||
// on no bus ("this controller is not on the bus") and read no siblings (mesh-controller #351).
|
||||
{ID: "R-issue867-recheck-verb", Issue: 867, Kind: InRepository, Repository: "mesh-controller",
|
||||
Fix: "a07dd78c3e90335bbe06970799e9b36a142f68c9",
|
||||
What: "the recheck verb asked mesh-delivery for the group on no bus connection and read no siblings",
|
||||
Asserts: "`delivery check` with one member, on a test bus with a mesh-delivery answering groups, learns the " +
|
||||
"sibling, asking once",
|
||||
Package: "./cmd/mesh-controller", Test: "TestTheRecheckVerbAsksMeshDeliveryOnABusOfItsOwn",
|
||||
Files: []string{"cmd/mesh-controller/replay867_test.go"}},
|
||||
// A release-branch group's composed check took the release judge, which cannot build a pair consistent only
|
||||
// together (mesh-controller #352, hq ADR 0239 §14): the group's own controller judges, with the host member's
|
||||
// validator. Both tests: the controller member primary, and the node-engine member primary with Judge validator.
|
||||
{ID: "R-issue867-release-group", Issue: 867, Kind: InRepository, Repository: "mesh-controller",
|
||||
Fix: "d70bb1f38867fad3595c96c7f7f2deb0b3ff501a",
|
||||
What: "the composed check of a delivery group into a release branch was judged by the release branch's " +
|
||||
"controller, which does not build with the pair's validator",
|
||||
Asserts: "a group's composed check into a release branch is judged by the group's own controller with the " +
|
||||
"mesh-host member's validator, and passes",
|
||||
Package: "./cmd/mesh-controller", Test: "TestAGroupsComposition",
|
||||
Files: []string{"cmd/mesh-controller/replay867_test.go"}},
|
||||
// mesh-config refused to propose mesh-issues' owners as carrying a secret: the SDK's CheckSecret judged a
|
||||
// lowercase name with a digit (modules/asus-zephyrus-g14) whole and took it for random (mesh-sdk #52).
|
||||
{ID: "R1439", Issue: 1439, Kind: InRepository, Repository: "mesh-sdk",
|
||||
Fix: "7bf4a8053a497bdd33746d181b6fa11b211c0f94",
|
||||
What: "a list of module names with digits in them was refused as a secret, so no owner could be proposed",
|
||||
Asserts: "CheckSecret lets lowercase names with digits through, and the catalogue's owners list with them",
|
||||
Module: "go", Package: "./outward", Test: "TestReplay1439",
|
||||
Files: []string{"go/outward/replay1439_test.go", "go/outward/replay1439_owners.json"},
|
||||
Home: "mesh-sdk", HomeRef: "ef76b9f2eac0cbbf94b1d4dcadb7a383723cd7a6"},
|
||||
}
|
||||
|
||||
// Find is the replay of that id, or of that issue.
|
||||
|
||||
@@ -0,0 +1,133 @@
|
||||
package replays
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
// THE STORE GENESIS RAISES INITIALISES WHERE THE POSTGRES MODULE KEEPS IT (novox/hq ADR 0338 §5, issue 609).
|
||||
//
|
||||
// Genesis raises the store as the catalogue's postgres module declares its server: the module's image, its
|
||||
// data in a directory made before the store starts and owned 999:70 as the module declares it, and its
|
||||
// superuser password read from a file. The measurement the decision names: the module's image, started on
|
||||
// such a directory, empty, initialises a store that answers with that password. The image is read from the
|
||||
// catalogue's manifest, so the measurement moves with the module's pin.
|
||||
//
|
||||
// Needs a container runtime (its socket) and the catalogue (MESH_REPLAY_CATALOGUE, or the checkout beside
|
||||
// the lab); skipped aloud without either.
|
||||
func TestTheStoreGenesisRaisesInitialisesOnTheDirectoryGenesisMakes(t *testing.T) {
|
||||
catalogue := os.Getenv("MESH_REPLAY_CATALOGUE")
|
||||
if catalogue == "" {
|
||||
catalogue = filepath.Join("..", "..", "mesh-catalog")
|
||||
}
|
||||
raw, err := os.ReadFile(filepath.Join(catalogue, "modules", "postgres", "module.json"))
|
||||
if err != nil {
|
||||
t.Skipf("no catalogue to read the store's image from (%v); MESH_REPLAY_CATALOGUE names one", err)
|
||||
}
|
||||
docker, ok := DockerFromEnv()
|
||||
if !ok {
|
||||
t.Skip("no container runtime: the store runs in a container")
|
||||
}
|
||||
var m struct {
|
||||
Resources []struct {
|
||||
ID, Type, Path, Owner, Mode, Image string
|
||||
Env map[string]string
|
||||
} `json:"resources"`
|
||||
}
|
||||
if err := json.Unmarshal(raw, &m); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var image, pgdata, owner, mode string
|
||||
for _, r := range m.Resources {
|
||||
switch {
|
||||
case r.Type == "container" && r.ID == "server":
|
||||
image, pgdata = r.Image, r.Env["PGDATA"]
|
||||
case r.Type == "directory" && r.ID == "store-data":
|
||||
owner, mode = r.Owner, r.Mode
|
||||
}
|
||||
}
|
||||
if image == "" || pgdata == "" || owner == "" {
|
||||
t.Fatalf("the postgres module names no server image (%q), PGDATA (%q) or data directory owner (%q)", image, pgdata, owner)
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Minute)
|
||||
defer cancel()
|
||||
// Under the working directory: a check's workspace is mounted into its containers at the same path,
|
||||
// so the runtime binds what this test made.
|
||||
here, err := os.Getwd()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
dir, err := os.MkdirTemp(here, "store-measure-")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, img := range []string{"alpine:3.20", image} {
|
||||
if err := docker.Pull(ctx, img); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
// The directory as genesis makes it, and the password file as genesis writes it: as root, a helper
|
||||
// container doing what the node-engine does on the machine.
|
||||
prep, _, err := docker.Start(ctx, Run{Image: "alpine:3.20", Binds: []string{dir + ":/w"}, Cmd: []string{"sh", "-c",
|
||||
"mkdir -p /w/store /w/state && chown " + owner + " /w/store && chmod " + orMode(mode) + " /w/store && " +
|
||||
"printf measured-pw > /w/state/superuser.secret && chmod 0600 /w/state/superuser.secret"}})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if code, said, err := docker.Wait(ctx, prep); err != nil || code != 0 {
|
||||
t.Fatalf("the directory could not be made as genesis makes it: %v %d %s", err, code, said)
|
||||
}
|
||||
docker.Remove(ctx, prep)
|
||||
t.Cleanup(func() {
|
||||
clean, _, err := docker.Start(context.Background(), Run{Image: "alpine:3.20", Binds: []string{dir + ":/w"},
|
||||
Cmd: []string{"sh", "-c", "rm -rf /w/store /w/state"}})
|
||||
if err == nil {
|
||||
_, _, _ = docker.Wait(context.Background(), clean)
|
||||
docker.Remove(context.Background(), clean)
|
||||
}
|
||||
_ = os.RemoveAll(dir)
|
||||
})
|
||||
|
||||
store, _, err := docker.Start(ctx, Run{Image: image,
|
||||
Env: []string{"POSTGRES_PASSWORD_FILE=/run/secrets/superuser", "PGDATA=" + pgdata},
|
||||
Binds: []string{dir + "/store:/var/lib/postgresql/data", dir + "/state/superuser.secret:/run/secrets/superuser:ro"}})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer docker.Remove(context.Background(), store)
|
||||
answered := false
|
||||
for i := 0; i < 90 && !answered; i++ {
|
||||
// Over TCP, and with the password: the temporary server initdb runs listens on the socket only.
|
||||
code, err := docker.Exec(ctx, store, "sh", "-c",
|
||||
"PGPASSWORD=measured-pw psql -h 127.0.0.1 -U postgres -tAc 'select 1' | grep -qx 1")
|
||||
answered = err == nil && code == 0
|
||||
if !answered {
|
||||
time.Sleep(2 * time.Second)
|
||||
}
|
||||
}
|
||||
if !answered {
|
||||
t.Fatalf("%s did not initialise a store that answers on a directory made %s %s, as genesis makes it:\n%s",
|
||||
image, owner, orMode(mode), lastLinesOf(docker.Logs(ctx, store), 15))
|
||||
}
|
||||
}
|
||||
|
||||
func orMode(m string) string {
|
||||
if m == "" {
|
||||
return "0700"
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
||||
func lastLinesOf(s string, n int) string {
|
||||
lines := strings.Split(strings.TrimRight(s, "\n"), "\n")
|
||||
if len(lines) > n {
|
||||
lines = lines[len(lines)-n:]
|
||||
}
|
||||
return strings.Join(lines, "\n")
|
||||
}
|
||||
+19
-3
@@ -24,6 +24,7 @@ import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
||||
import { homedir } from "node:os";
|
||||
import { dirname, join } from "node:path";
|
||||
|
||||
import type { Outcome, Skip } from "./outcomes.ts";
|
||||
import { repositories } from "./repos.ts";
|
||||
|
||||
/** What a run was taken against, per repository. */
|
||||
@@ -38,6 +39,11 @@ export interface Receipt {
|
||||
against: Against;
|
||||
/** The test files this run was pointed at. See {@link endToEnd}. */
|
||||
ran: string[];
|
||||
/** How many tests skipped, and each with its reason (novox/hq issue 693). Absent on older receipts. */
|
||||
skipped?: number;
|
||||
skips?: Skip[];
|
||||
/** Why the run did not pass although nothing failed — no test passed, or one was not reached. */
|
||||
notPassed?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -104,6 +110,7 @@ export function record(
|
||||
ran: string[],
|
||||
env = process.env,
|
||||
builtAgainst?: Against,
|
||||
outcome?: Outcome,
|
||||
): Receipt {
|
||||
const receipt: Receipt = {
|
||||
at: new Date().toISOString(),
|
||||
@@ -115,6 +122,8 @@ export function record(
|
||||
// never in the binaries. A verdict is only worth something attributed to one exact state.
|
||||
against: builtAgainst ?? whatWasTested(env),
|
||||
ran,
|
||||
...(outcome ? { skipped: outcome.skipped, skips: outcome.skips } : {}),
|
||||
...(outcome?.notPassed ? { notPassed: outcome.notPassed } : {}),
|
||||
};
|
||||
const path = receiptPath();
|
||||
mkdirSync(dirname(path), { recursive: true });
|
||||
@@ -166,9 +175,14 @@ export function judge(
|
||||
|
||||
const days = (now.getTime() - Date.parse(receipt.at)) / 86_400_000;
|
||||
const lines: string[] = [];
|
||||
// A run that proved nothing did not pass, though nothing failed (novox/hq issue 693): no test passed,
|
||||
// or one skipped as not reached. A receipt from before the field is judged by its count alone.
|
||||
const notPassed = receipt.failed > 0 ? "" : receipt.notPassed ?? (receipt.passed === 0 ? "no test passed" : "");
|
||||
const outcome = receipt.failed > 0
|
||||
? `last ran ${ago(days)} and ${receipt.failed} test(s) failed`
|
||||
: `last passed ${ago(days)}, ${receipt.passed} test(s)`;
|
||||
: notPassed
|
||||
? `last ran ${ago(days)} and did not pass: ${notPassed}`
|
||||
: `last passed ${ago(days)}, ${receipt.passed} test(s)`;
|
||||
lines.push(`the end-to-end suite ${outcome}`);
|
||||
|
||||
let moved = false;
|
||||
@@ -192,7 +206,9 @@ export function judge(
|
||||
lines.push(` That run did not include ${endToEnd}, so it raised no machines.`);
|
||||
}
|
||||
|
||||
if (receipt.failed > 0) {
|
||||
for (const s of receipt.skips ?? []) lines.push(` skipped: ${s.test} — ${s.reason || "no reason given"}`);
|
||||
|
||||
if (receipt.failed > 0 || notPassed) {
|
||||
lines.push(" Nothing has been proven end to end since.");
|
||||
} else if (moved) {
|
||||
lines.push(" What it proved was proven about code that has since changed.");
|
||||
@@ -201,7 +217,7 @@ export function judge(
|
||||
}
|
||||
|
||||
return {
|
||||
current: endToEndRan && receipt.failed === 0 && !moved && days <= staleAfterDays,
|
||||
current: endToEndRan && receipt.failed === 0 && !notPassed && !moved && days <= staleAfterDays,
|
||||
lines,
|
||||
};
|
||||
}
|
||||
|
||||
+102
-9
@@ -23,6 +23,88 @@ export const UPSTREAM_IMAGE = "images:archlinux/current";
|
||||
|
||||
const BUILDER = "mesh-lab-base-builder";
|
||||
|
||||
/**
|
||||
* **The mirrors the builder installs from, several and in order** (novox/hq issue 700).
|
||||
*
|
||||
* The stock image names one mirror, mirrors.kernel.org, and a base build failed twice on it in one morning:
|
||||
* timeouts while installing the runtime, then a 500 on wireguard-tools. pacman tries the next server in the
|
||||
* list for each file it could not fetch, so a list of several turns one mirror's bad minute into a slower
|
||||
* download instead of a failed build.
|
||||
*
|
||||
* A fixed list rather than ranking at build time: ranking (rankmirrors, reflector) needs a package installed
|
||||
* first, from the one mirror that is the problem, and gives a different list on every build. These are
|
||||
* Arch's own geo-routed mirror first, then well-kept European mirrors near the lab's machine, then the
|
||||
* stock image's own. Each answered for core.db on 2026-10-14. A mirror that goes away costs a fallback,
|
||||
* not a build, and is replaced here.
|
||||
*/
|
||||
export const MIRRORS = [
|
||||
"https://geo.mirror.pkgbuild.com/$repo/os/$arch",
|
||||
"https://mirror.netcologne.de/archlinux/$repo/os/$arch",
|
||||
"https://ftp.fau.de/archlinux/$repo/os/$arch",
|
||||
"https://archlinux.mirror.liteserver.nl/$repo/os/$arch",
|
||||
"https://mirror.leaseweb.net/archlinux/$repo/os/$arch",
|
||||
"https://mirrors.kernel.org/archlinux/$repo/os/$arch",
|
||||
];
|
||||
|
||||
/** The mirrorlist the builder is given: every mirror, in order. */
|
||||
export function mirrorlist(): string {
|
||||
return "# Written by the mesh-lab base build (novox/hq issue 700): several mirrors, tried in order.\n" +
|
||||
MIRRORS.map((m) => `Server = ${m}`).join("\n") + "\n";
|
||||
}
|
||||
|
||||
/** The mirrors a failed pacman step names: "from <host>" in what it said, each once. */
|
||||
export function failedMirrors(said: string): string[] {
|
||||
const hosts = [...said.matchAll(/\bfrom ([a-z0-9.-]+\.[a-z]{2,})\b/gi)].map((m) => m[1]!.toLowerCase());
|
||||
return [...new Set(hosts)];
|
||||
}
|
||||
|
||||
/** How long to wait before each retry of a failed pacman step: three retries, backing off. */
|
||||
export const PACMAN_BACKOFF_MS = [10_000, 30_000, 90_000];
|
||||
|
||||
/** What a base build runs through, so a test can stand in for the hypervisor and the clock. */
|
||||
export interface BaseDeps {
|
||||
incus: (args: string[], timeoutMs?: number) => Promise<unknown>;
|
||||
incusOk: (args: string[], timeoutMs?: number) => Promise<string | null>;
|
||||
succeeds: (args: string[], timeoutMs?: number) => Promise<boolean>;
|
||||
sleep: (ms: number) => Promise<void>;
|
||||
}
|
||||
|
||||
const realDeps: BaseDeps = {
|
||||
incus, incusOk, succeeds, sleep: (ms) => new Promise((r) => setTimeout(r, ms)),
|
||||
};
|
||||
|
||||
/**
|
||||
* pacmanIn runs one pacman step in the builder, and **runs it again after a pause when it fails**, up to
|
||||
* three more times, saying each time which mirror failed and what it said. Installing is idempotent — what is
|
||||
* installed stays installed — so a retry repeats only what did not happen. The last failure is thrown, naming
|
||||
* every mirror that failed along the way.
|
||||
*/
|
||||
export async function pacmanIn(name: string, args: string[], log: (m: string) => void, deps: BaseDeps = realDeps):
|
||||
Promise<void> {
|
||||
const failed: string[] = [];
|
||||
for (let attempt = 0; ; attempt++) {
|
||||
try {
|
||||
await deps.incus(["exec", name, "--", "pacman", ...args], 600_000);
|
||||
return;
|
||||
} catch (err) {
|
||||
// What pacman said, where incus kept it apart; otherwise the whole message.
|
||||
const said = (err as { stderr?: string }).stderr?.trim() || (err as Error).message;
|
||||
const mirrors = failedMirrors(said);
|
||||
for (const m of mirrors) if (!failed.includes(m)) failed.push(m);
|
||||
const where = mirrors.length > 0 ? `from ${mirrors.join(", ")}` : "naming no mirror";
|
||||
const first = said.split("\n").find((l) => /error/i.test(l))?.trim() ?? said.split("\n")[0]?.trim() ?? "";
|
||||
if (attempt >= PACMAN_BACKOFF_MS.length) {
|
||||
throw new BaseImageError(`pacman ${args.join(" ")} failed ${attempt + 1} times; the mirrors that failed: ` +
|
||||
`${failed.join(", ") || "none named"}. Last: ${said}`);
|
||||
}
|
||||
const wait = PACMAN_BACKOFF_MS[attempt]!;
|
||||
log(` pacman ${args.join(" ")} failed ${where} (${first}); trying again in ${wait / 1000}s ` +
|
||||
`(attempt ${attempt + 2} of ${PACMAN_BACKOFF_MS.length + 1})`);
|
||||
await deps.sleep(wait);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class BaseImageError extends Error {
|
||||
constructor(message: string) {
|
||||
super(message);
|
||||
@@ -38,7 +120,9 @@ export class BaseImageError extends Error {
|
||||
*/
|
||||
export async function buildBaseImage(
|
||||
log: (message: string) => void = () => {},
|
||||
deps: BaseDeps = realDeps,
|
||||
): Promise<{ alias: string; runtime: string }> {
|
||||
const { incus, incusOk, succeeds } = deps;
|
||||
await succeeds(["delete", "-f", BUILDER], 120_000);
|
||||
|
||||
log(` launching ${BUILDER} from ${UPSTREAM_IMAGE}, with a network`);
|
||||
@@ -50,10 +134,19 @@ export async function buildBaseImage(
|
||||
], 300_000);
|
||||
|
||||
try {
|
||||
await waitForAgent(BUILDER);
|
||||
await waitForAgent(BUILDER, deps);
|
||||
|
||||
// Several mirrors before anything is fetched (MIRRORS), and read back: a list that was not written is
|
||||
// the one mirror again, and the failure would look like the one this prevents.
|
||||
log(` giving pacman ${MIRRORS.length} mirrors`);
|
||||
await incus(["exec", BUILDER, "--", "sh", "-c", `printf '%s' '${mirrorlist()}' > /etc/pacman.d/mirrorlist`], 60_000);
|
||||
const written = await incusOk(["exec", BUILDER, "--", "cat", "/etc/pacman.d/mirrorlist"], 60_000);
|
||||
if (written?.trim() !== mirrorlist().trim()) {
|
||||
throw new BaseImageError(`the mirrorlist written into ${BUILDER} reads back as ${JSON.stringify(written)}`);
|
||||
}
|
||||
|
||||
log(" installing a container runtime");
|
||||
await incus(["exec", BUILDER, "--", "pacman", "-Sy", "--noconfirm", "docker"], 600_000);
|
||||
await pacmanIn(BUILDER, ["-Sy", "--noconfirm", "docker"], log, deps);
|
||||
|
||||
// And the tools for the private network, for the same reason as the runtime: a sealed
|
||||
// scenario cannot install them, so a lab that omits them cannot test connectivity at all —
|
||||
@@ -63,27 +156,27 @@ export async function buildBaseImage(
|
||||
// declaration; a lab that brought the interface up itself would be testing its own setup
|
||||
// rather than the mesh's.
|
||||
log(" installing the tools for the private network");
|
||||
await incus(["exec", BUILDER, "--", "pacman", "-S", "--noconfirm", "wireguard-tools"], 600_000);
|
||||
await pacmanIn(BUILDER, ["-S", "--noconfirm", "wireguard-tools"], log, deps);
|
||||
|
||||
// And git, for the same reason again: a machine that builds modules clones them, and a sealed
|
||||
// scenario cannot install it. On a real build machine the mesh installs it as a package like
|
||||
// anything else — the lab is the special case, because its machines reach no mirror.
|
||||
log(" installing git, so a machine can build modules");
|
||||
await incus(["exec", BUILDER, "--", "pacman", "-S", "--noconfirm", "git"], 600_000);
|
||||
await pacmanIn(BUILDER, ["-S", "--noconfirm", "git"], log, deps);
|
||||
|
||||
// And nftables, because the mesh computes a machine's filtering and delivers it as a file
|
||||
// that a service reflects — and neither the file nor the service can install what loads it.
|
||||
// Installed and NOT enabled: whether a machine filters is the mesh's decision, and a lab that
|
||||
// turned it on itself would be testing its own setup.
|
||||
log(" installing nftables, so a machine can enforce what the mesh computed");
|
||||
await incus(["exec", BUILDER, "--", "pacman", "-S", "--noconfirm", "nftables"], 600_000);
|
||||
await pacmanIn(BUILDER, ["-S", "--noconfirm", "nftables"], log, deps);
|
||||
|
||||
// And dnsmasq, because a service is named under the machine it runs on — postgres.novox.internal
|
||||
// — and only a resolver can answer a name the mesh was never told about. Installed and NOT
|
||||
// started: whether a machine resolves for the mesh is the mesh's decision, and a lab that
|
||||
// turned it on itself would be testing its own setup.
|
||||
log(" installing dnsmasq, so a machine can answer names under another machine");
|
||||
await incus(["exec", BUILDER, "--", "pacman", "-S", "--noconfirm", "dnsmasq"], 600_000);
|
||||
await pacmanIn(BUILDER, ["-S", "--noconfirm", "dnsmasq"], log, deps);
|
||||
|
||||
// Trust the documentation ranges as plain-HTTP registries.
|
||||
//
|
||||
@@ -216,10 +309,10 @@ export async function baseImageExists(): Promise<boolean> {
|
||||
* Wait for the guest agent, because `launch` returning means the VM started, not that anything
|
||||
* inside it will answer.
|
||||
*/
|
||||
async function waitForAgent(name: string): Promise<void> {
|
||||
async function waitForAgent(name: string, deps: BaseDeps = realDeps): Promise<void> {
|
||||
for (let i = 0; i < 90; i++) {
|
||||
if (await succeeds(["exec", name, "--", "true"], 10_000)) return;
|
||||
await new Promise((r) => setTimeout(r, 2_000));
|
||||
if (await deps.succeeds(["exec", name, "--", "true"], 10_000)) return;
|
||||
await deps.sleep(2_000);
|
||||
}
|
||||
throw new BaseImageError(`${name} started and its agent never answered.`);
|
||||
}
|
||||
|
||||
+114
@@ -0,0 +1,114 @@
|
||||
/**
|
||||
* What a suite's tests did, beyond the runner's totals: which were skipped and why, and whether the run
|
||||
* proved anything (novox/hq issue 693).
|
||||
*
|
||||
* **A run in which no test passed has proven nothing, whatever its exit code.** The runner exits 0 when
|
||||
* every test skipped, and the lab recorded such a run as passed: the genesis bed stopped before its
|
||||
* subject, skipped its only test as "NOT REACHED", and the run read "0 passed, 0 failed", passed.
|
||||
* Failure must be loud, and a green run that verified nothing is the quietest failure there is.
|
||||
*
|
||||
* The default export is a reporter for node's test runner (`--test-reporter`): it writes one JSON line per
|
||||
* skipped test, with its file, its name and the reason it gave, word for word. The reasons come from the
|
||||
* runner's events rather than from the spec reporter's text, because a reason runs over several lines and a
|
||||
* later test's output lands between them.
|
||||
*/
|
||||
|
||||
import { readFileSync } from "node:fs";
|
||||
|
||||
/** One skipped test and the reason it gave ("" when it gave none). */
|
||||
export interface Skip {
|
||||
file: string;
|
||||
test: string;
|
||||
reason: string;
|
||||
}
|
||||
|
||||
/** What a receipt keeps beside the totals: the skips, and why the run did not pass when it did not. */
|
||||
export interface Outcome {
|
||||
skipped: number;
|
||||
skips: Skip[];
|
||||
notPassed?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* The words a bed's test skips with when the run stopped before its subject: the subject was not reached,
|
||||
* so nothing about it was proven (the beds say "<what> NOT REACHED: <where it stopped>").
|
||||
*/
|
||||
export const NOT_REACHED = "NOT REACHED";
|
||||
|
||||
/**
|
||||
* Whether a run passed, and if not, why — the design limit of issue 693, in one place:
|
||||
*
|
||||
* - a test failed: not passed (the runner already says so);
|
||||
* - **no test passed**: not passed, whatever was skipped — a run that skipped everything, or ran
|
||||
* nothing, verified nothing;
|
||||
* - **a test skipped as NOT REACHED**: not passed, even beside tests that passed — its subject was not
|
||||
* reached, which is the bed failing to get where it was sent, not a skip anyone declared expected;
|
||||
* - otherwise passed, its other skips listed with their reasons: a test skipped for a reason its file
|
||||
* declares (no hypervisor, an optional bed not asked for) beside tests that passed is an expected
|
||||
* skip, and the run still proved what passed.
|
||||
*
|
||||
* Counts the runner did not report (null) decide nothing here: that is reportOn's "no receipt" case.
|
||||
*/
|
||||
export function judgeRun(
|
||||
counts: { passed: number | null; failed: number | null },
|
||||
skips: Skip[],
|
||||
): { passed: boolean; why: string } {
|
||||
if (counts.failed !== null && counts.failed > 0) return { passed: false, why: `${counts.failed} test(s) failed` };
|
||||
// In any case: "not reached" says the same as "NOT REACHED".
|
||||
const unreached = skips.filter((s) => s.reason.toUpperCase().includes(NOT_REACHED));
|
||||
if (counts.passed === 0) {
|
||||
return {
|
||||
passed: false,
|
||||
why: skips.length > 0
|
||||
? `no test passed: ${skips.length} skipped${unreached.length > 0 ? `, ${unreached.length} of them as ${NOT_REACHED}` : ""}`
|
||||
: "no test passed: none ran",
|
||||
};
|
||||
}
|
||||
if (unreached.length > 0) {
|
||||
return { passed: false, why: `${unreached.length} test(s) skipped as ${NOT_REACHED}: their subject was not reached` };
|
||||
}
|
||||
return { passed: true, why: "" };
|
||||
}
|
||||
|
||||
/** A reason on one line, for a log line and a record: its whitespace folded, and at most 500 characters. */
|
||||
export function oneLine(reason: string): string {
|
||||
const flat = reason.replace(/\s+/g, " ").trim();
|
||||
return flat.length > 500 ? `${flat.slice(0, 499)}…` : flat;
|
||||
}
|
||||
|
||||
/** The skips the reporter wrote to a file; none when it wrote nothing or the file cannot be read. */
|
||||
export function readSkips(path: string): Skip[] {
|
||||
let text: string;
|
||||
try {
|
||||
text = readFileSync(path, "utf8");
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
const skips: Skip[] = [];
|
||||
for (const line of text.split("\n")) {
|
||||
if (!line.trim()) continue;
|
||||
try {
|
||||
const s = JSON.parse(line) as Partial<Skip>;
|
||||
skips.push({ file: String(s.file ?? ""), test: String(s.test ?? ""), reason: String(s.reason ?? "") });
|
||||
} catch {
|
||||
// A torn last line, when the runner was killed mid-write: the lines before it still stand.
|
||||
}
|
||||
}
|
||||
return skips;
|
||||
}
|
||||
|
||||
interface Event {
|
||||
type: string;
|
||||
data: { name?: string; file?: string; skip?: string | boolean; details?: { type?: string } };
|
||||
}
|
||||
|
||||
/** The reporter: one JSON line per skipped test (not per skipped suite: its tests are reported each). */
|
||||
export default async function* skipsReporter(source: AsyncIterable<Event>): AsyncGenerator<string> {
|
||||
for await (const event of source) {
|
||||
if (event.type !== "test:pass" && event.type !== "test:fail") continue;
|
||||
const { skip, details } = event.data;
|
||||
if (skip === undefined || skip === false || details?.type === "suite") continue;
|
||||
const said: Skip = { file: event.data.file ?? "", test: event.data.name ?? "", reason: typeof skip === "string" ? skip : "" };
|
||||
yield `${JSON.stringify(said)}\n`;
|
||||
}
|
||||
}
|
||||
+70
-16
@@ -10,11 +10,16 @@
|
||||
*/
|
||||
|
||||
import { spawn } from "node:child_process";
|
||||
import { mkdtempSync, rmSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { isAbsolute, join, relative } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { endToEnd, record, whatWasTested } from "./lastrun.ts";
|
||||
import { judgeRun, oneLine, readSkips, type Outcome, type Skip } from "./outcomes.ts";
|
||||
import { rebuild } from "./rebuild.ts";
|
||||
|
||||
/** counted is what the runner said, or nulls when it said nothing recognisable. */
|
||||
export function counted(output: string): { passed: number | null; failed: number | null } {
|
||||
export function counted(output: string): { passed: number | null; failed: number | null; skipped: number | null } {
|
||||
// The runner's own summary lines, each on a line of its own. Anchored, so a test *named*
|
||||
// "pass 3" cannot be mistaken for the total — which is not a hypothetical worry in a suite whose
|
||||
// tests are named in sentences.
|
||||
@@ -23,13 +28,18 @@ export function counted(output: string): { passed: number | null; failed: number
|
||||
// running this against the real runner — the fixture it was first written against was output I
|
||||
// had imagined, which is a test that agrees with the mistake it was written beside.
|
||||
const plain = output.replace(/\u001b\[[0-9;]*m/g, "");
|
||||
// **The last such line, never the first** (novox/hq issue 693): the runner prints its summary after
|
||||
// everything a test printed, so a test that prints "ℹ pass 5" before it skips would otherwise be read
|
||||
// as five passes, and a run that proved nothing as passed.
|
||||
const total = (what: RegExp) => {
|
||||
const found = plain.match(what);
|
||||
return found ? Number(found[1]) : null;
|
||||
const found = [...plain.matchAll(what)];
|
||||
const last = found[found.length - 1];
|
||||
return last ? Number(last[1]) : null;
|
||||
};
|
||||
return {
|
||||
passed: total(/^\s*(?:\u2139|#)\s*pass\s+(\d+)\s*$/m),
|
||||
failed: total(/^\s*(?:\u2139|#)\s*fail\s+(\d+)\s*$/m),
|
||||
passed: total(/^\s*(?:\u2139|#)\s*pass\s+(\d+)\s*$/gm),
|
||||
failed: total(/^\s*(?:\u2139|#)\s*fail\s+(\d+)\s*$/gm),
|
||||
skipped: total(/^\s*(?:\u2139|#)\s*skipped\s+(\d+)\s*$/gm),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -57,16 +67,38 @@ export async function runSuite(args: string[]): Promise<number> {
|
||||
// `test/integration/canary.test.ts` is still there and still runs when it is named; it is no
|
||||
// longer raised on the way to everything else.
|
||||
|
||||
const { code, seen } = await runFiles(files);
|
||||
console.log("\n" + reportOn(counted(seen), (p, f) => record(p, f, files, process.env, against)));
|
||||
return code;
|
||||
const { code, seen, skips } = await runFiles(files);
|
||||
const counts = counted(seen);
|
||||
console.log("\n" + reportOn(counts, skips, (p, f, outcome) => record(p, f, files, process.env, against, outcome)));
|
||||
return exitOf(code, counts, skips);
|
||||
}
|
||||
|
||||
/** Run some test files, passing their output through as it arrives. */
|
||||
async function runFiles(files: string[]): Promise<{ code: number; seen: string }> {
|
||||
/**
|
||||
* The suite's exit: the runner's, unless it says 0 for a run that did not pass (novox/hq issue 693). The
|
||||
* runner exits 0 when every test skipped; the lab takes this exit as the run's verdict, so a run that
|
||||
* proved nothing must not end in 0.
|
||||
*/
|
||||
export function exitOf(code: number, counts: { passed: number | null; failed: number | null }, skips: Skip[]): number {
|
||||
if (code !== 0) return code;
|
||||
if (counts.passed === null || counts.failed === null) return code;
|
||||
return judgeRun(counts, skips).passed ? 0 : 1;
|
||||
}
|
||||
|
||||
/** The reporter that writes each skipped test and its reason (outcomes.ts), by its path. */
|
||||
const skipsReporter = fileURLToPath(new URL("./outcomes.ts", import.meta.url));
|
||||
|
||||
/**
|
||||
* Run some test files, passing their output through as it arrives, and collect what was skipped and why:
|
||||
* the spec reporter to stdout as before, and the skips reporter beside it into a file of the run's own.
|
||||
*/
|
||||
async function runFiles(files: string[]): Promise<{ code: number; seen: string; skips: Skip[] }> {
|
||||
const scratch = mkdtempSync(join(tmpdir(), "mesh-lab-suite-"));
|
||||
const skipsFile = join(scratch, "skips.jsonl");
|
||||
const running = spawn(
|
||||
process.execPath,
|
||||
["--test", "--test-concurrency=1", "--experimental-strip-types",
|
||||
"--test-reporter=spec", "--test-reporter-destination=stdout",
|
||||
`--test-reporter=${skipsReporter}`, `--test-reporter-destination=${skipsFile}`,
|
||||
...files],
|
||||
{ stdio: ["inherit", "pipe", "inherit"] },
|
||||
);
|
||||
@@ -81,7 +113,14 @@ async function runFiles(files: string[]): Promise<{ code: number; seen: string }
|
||||
const code: number = await new Promise((resolve) => {
|
||||
running.on("close", (c) => resolve(c ?? 1));
|
||||
});
|
||||
return { code, seen };
|
||||
// Named as the files were given, relative to where the suite runs, rather than as the runner's absolute paths.
|
||||
const named = (file: string) => {
|
||||
const rel = isAbsolute(file) ? relative(process.cwd(), file) : file;
|
||||
return rel.startsWith("..") ? file : rel;
|
||||
};
|
||||
const skips = readSkips(skipsFile).map((s) => ({ ...s, file: named(s.file) }));
|
||||
rmSync(scratch, { recursive: true, force: true });
|
||||
return { code, seen, skips };
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -92,16 +131,31 @@ async function runFiles(files: string[]): Promise<{ code: number; seen: string }
|
||||
* could check it — which is 04-ISSUES/005 in miniature, inside the fix for it.
|
||||
*/
|
||||
export function reportOn(
|
||||
counts: { passed: number | null; failed: number | null },
|
||||
write: (passed: number, failed: number) => { against: Record<string, string>; ran: string[] },
|
||||
counts: { passed: number | null; failed: number | null; skipped?: number | null },
|
||||
skips: Skip[],
|
||||
write: (passed: number, failed: number, outcome: Outcome) => { against: Record<string, string>; ran: string[] },
|
||||
): string {
|
||||
if (counts.passed === null || counts.failed === null) {
|
||||
// A run whose result could not be read is a run nobody can say anything about. Writing
|
||||
// "0 failed" because nothing said otherwise is how a green record comes to mean nothing.
|
||||
return "could not read what the runner reported; no receipt written";
|
||||
}
|
||||
const receipt = write(counts.passed, counts.failed);
|
||||
// **A skip is said, with its reason, and a run that proved nothing says NOT PASSED** (novox/hq issue
|
||||
// 693): "0 passed, 0 failed" read as a clean run. The lab module reads these lines into its record.
|
||||
const skipped = counts.skipped ?? skips.length;
|
||||
const judged = judgeRun({ passed: counts.passed, failed: counts.failed }, skips);
|
||||
const outcome: Outcome = {
|
||||
skipped,
|
||||
skips: skips.map((s) => ({ ...s, reason: oneLine(s.reason) })),
|
||||
...(judged.passed ? {} : { notPassed: judged.why }),
|
||||
};
|
||||
const receipt = write(counts.passed, counts.failed, outcome);
|
||||
const against = Object.entries(receipt.against).map(([n, c]) => `${n} ${c}`).join(", ");
|
||||
return `recorded: ${receipt.ran.join(", ")} — ${counts.passed} passed, ` +
|
||||
`${counts.failed} failed, against ${against || "nothing in git"}`;
|
||||
const lines = [`recorded: ${receipt.ran.join(", ")} — ${counts.passed} passed, ` +
|
||||
`${counts.failed} failed, ${skipped} skipped, against ${against || "nothing in git"}`];
|
||||
if (!judged.passed) lines.push(`NOT PASSED: ${judged.why}`);
|
||||
// As the runner's own spec line has it, "<test> (<file>) # <reason>": a test's name may hold any
|
||||
// punctuation, so the file in brackets is what the lab module reads the line apart by.
|
||||
for (const s of outcome.skips) lines.push(`skipped: ${s.test} (${s.file}) # ${s.reason || "no reason given"}`);
|
||||
return lines.join("\n");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { IncusError } from "../src/incus/client.ts";
|
||||
import {
|
||||
buildBaseImage, failedMirrors, MIRRORS, mirrorlist, PACMAN_BACKOFF_MS, pacmanIn, type BaseDeps,
|
||||
} from "../src/lifecycle/base.ts";
|
||||
import { BASE_IMAGE_ALIAS } from "../src/lifecycle/place.ts";
|
||||
|
||||
/**
|
||||
* Defends novox/hq issue 700: the base build installed from the one mirror the stock image names,
|
||||
* mirrors.kernel.org, and failed twice in a morning when that mirror timed out and then answered 500.
|
||||
*/
|
||||
|
||||
const KERNEL_500 = "error: failed retrieving file 'wireguard-tools-1.0.20260223-1-x86_64.pkg.tar.zst' from " +
|
||||
"mirrors.kernel.org : The requested URL returned error: 500\nwarning: failed to retrieve some files\n" +
|
||||
"error: failed to commit transaction (failed to retrieve some files)";
|
||||
|
||||
/** A hypervisor for one base build: pacman fails `fails` times per step, then installs. */
|
||||
function aBuilder(fails: number, said = KERNEL_500) {
|
||||
const ran: string[] = [];
|
||||
const slept: number[] = [];
|
||||
let mirrorlistWritten = "";
|
||||
const tries = new Map<string, number>();
|
||||
const deps: BaseDeps = {
|
||||
incus: async (args) => {
|
||||
ran.push(args.join(" "));
|
||||
const at = args.indexOf("pacman");
|
||||
if (at >= 0) {
|
||||
const step = args.slice(at).join(" ");
|
||||
const n = (tries.get(step) ?? 0) + 1;
|
||||
tries.set(step, n);
|
||||
if (n <= fails) throw new IncusError(args, said, 1);
|
||||
}
|
||||
const printf = args.join(" ").match(/printf '%s' '([\s\S]*)' > \/etc\/pacman.d\/mirrorlist/);
|
||||
if (printf) mirrorlistWritten = printf[1]!;
|
||||
return { stdout: "", stderr: "" };
|
||||
},
|
||||
incusOk: async (args) => {
|
||||
const c = args.join(" ");
|
||||
if (c.endsWith("cat /etc/pacman.d/mirrorlist")) return mirrorlistWritten;
|
||||
if (c.includes("{{.ServerVersion}}")) return "29.8.2";
|
||||
if (c.includes("InsecureRegistryCIDRs")) return "[127.0.0.0/8 192.0.2.0/24]";
|
||||
if (c.startsWith("image list")) return BASE_IMAGE_ALIAS;
|
||||
return "tool 1.0";
|
||||
},
|
||||
succeeds: async () => true,
|
||||
sleep: async (ms) => { slept.push(ms); },
|
||||
};
|
||||
return { deps, ran, slept };
|
||||
}
|
||||
|
||||
test("the builder is given several mirrors, the stock one last, before anything is installed", async () => {
|
||||
const hosts = MIRRORS.map((m) => new URL(m.replace("$repo", "core").replace("$arch", "x86_64")).host);
|
||||
assert.ok(new Set(hosts).size >= 4, `too few mirrors: ${hosts.join(", ")}`);
|
||||
assert.equal(hosts.at(-1), "mirrors.kernel.org");
|
||||
assert.ok(!mirrorlist().includes("'"), "the mirrorlist is written inside single quotes and holds one");
|
||||
assert.equal(mirrorlist().split("\n").filter((l) => l.startsWith("Server = ")).length, MIRRORS.length);
|
||||
|
||||
const b = aBuilder(0);
|
||||
await buildBaseImage(() => {}, b.deps);
|
||||
const wrote = b.ran.findIndex((c) => c.includes("/etc/pacman.d/mirrorlist"));
|
||||
const firstPacman = b.ran.findIndex((c) => c.includes(" pacman "));
|
||||
assert.ok(wrote >= 0 && wrote < firstPacman, "pacman ran before the mirrorlist was written");
|
||||
});
|
||||
|
||||
test("a pacman step that fails is tried again after a pause, saying which mirror failed", async () => {
|
||||
const said: string[] = [];
|
||||
const b = aBuilder(2);
|
||||
await pacmanIn("builder", ["-S", "--noconfirm", "wireguard-tools"], (m) => said.push(m), b.deps);
|
||||
assert.equal(b.ran.length, 3);
|
||||
assert.deepEqual(b.slept, PACMAN_BACKOFF_MS.slice(0, 2));
|
||||
assert.ok(PACMAN_BACKOFF_MS[1]! > PACMAN_BACKOFF_MS[0]!, "no backoff");
|
||||
assert.equal(said.length, 2);
|
||||
assert.match(said[0]!, /failed from mirrors\.kernel\.org \(error: failed retrieving file 'wireguard-tools/);
|
||||
assert.match(said[0]!, /trying again in 10s \(attempt 2 of 4\)/);
|
||||
});
|
||||
|
||||
test("a step that keeps failing stops the build, naming every mirror that failed", async () => {
|
||||
const b = aBuilder(99, "error: too many errors from mirrors.kernel.org\nerror: failed retrieving file 'x' from ftp.fau.de : 500");
|
||||
await assert.rejects(
|
||||
pacmanIn("builder", ["-Sy", "--noconfirm", "docker"], () => {}, b.deps),
|
||||
/failed 4 times; the mirrors that failed: mirrors\.kernel\.org, ftp\.fau\.de/,
|
||||
);
|
||||
assert.equal(b.ran.length, PACMAN_BACKOFF_MS.length + 1);
|
||||
});
|
||||
|
||||
test("a whole base build rides out a mirror's bad minute on every package", async () => {
|
||||
const b = aBuilder(1);
|
||||
const built = await buildBaseImage(() => {}, b.deps);
|
||||
assert.equal(built.alias, BASE_IMAGE_ALIAS);
|
||||
const pacman = b.ran.filter((c) => c.includes(" pacman "));
|
||||
assert.equal(pacman.length, 10, pacman.join("\n"));
|
||||
});
|
||||
|
||||
test("the mirrors a failure names are read from what pacman said, each once", () => {
|
||||
assert.deepEqual(failedMirrors(KERNEL_500), ["mirrors.kernel.org"]);
|
||||
assert.deepEqual(failedMirrors("Connection timed out after 10000 milliseconds\nerror: too many errors from mirrors.kernel.org"),
|
||||
["mirrors.kernel.org"]);
|
||||
assert.deepEqual(failedMirrors("error: target not found: dockr"), []);
|
||||
});
|
||||
@@ -0,0 +1,50 @@
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { execFileSync } from "node:child_process";
|
||||
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
|
||||
import { carry } from "./integration/forge.ts";
|
||||
|
||||
/**
|
||||
* A bed's forge takes the lab's checkouts as they are: shallow (novox/hq issue 689). The lab module clones
|
||||
* every repository with `--depth`, and the genesis bed's forge refused the push ("shallow update not
|
||||
* allowed"), so the bed never reached its installer. Held here with a real git and no lab.
|
||||
*/
|
||||
|
||||
const git = (cwd: string, ...args: string[]) =>
|
||||
execFileSync("git", ["-C", cwd, ...args], { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"],
|
||||
env: { ...process.env, GIT_AUTHOR_NAME: "lab", GIT_AUTHOR_EMAIL: "lab@example.org",
|
||||
GIT_COMMITTER_NAME: "lab", GIT_COMMITTER_EMAIL: "lab@example.org" } }).trim();
|
||||
|
||||
test("a shallow checkout, as the lab clones it, is carried into the bed's forge and served from it", () => {
|
||||
const dir = mkdtempSync(join(tmpdir(), "mesh-lab-689-"));
|
||||
try {
|
||||
const origin = join(dir, "origin");
|
||||
execFileSync("git", ["init", "-q", "-b", "main", origin]);
|
||||
for (let i = 0; i < 5; i++) {
|
||||
writeFileSync(join(origin, "file"), `${i}\n`);
|
||||
git(origin, "add", "file");
|
||||
git(origin, "commit", "-q", "-m", `commit ${i}`);
|
||||
}
|
||||
// As the lab module clones: shallow, over a transport that honours the depth.
|
||||
const checkout = join(dir, "checkout");
|
||||
execFileSync("git", ["clone", "-q", "--depth", "2", "--branch", "main", `file://${origin}`, checkout]);
|
||||
assert.equal(git(checkout, "rev-parse", "--is-shallow-repository"), "true");
|
||||
|
||||
const bare = join(dir, "forge", "repo.git");
|
||||
const head = carry(checkout, bare, ["main", "lab"]);
|
||||
assert.equal(head, git(origin, "rev-parse", "HEAD"));
|
||||
assert.equal(git(bare, "rev-parse", "refs/heads/main"), head);
|
||||
assert.equal(git(bare, "rev-parse", "refs/heads/lab"), head);
|
||||
|
||||
// What the bed's machines do with it: clone over git's protocol, and find the commit under test.
|
||||
const served = join(dir, "served");
|
||||
execFileSync("git", ["clone", "-q", "--branch", "main", `file://${bare}`, served]);
|
||||
assert.equal(git(served, "rev-parse", "HEAD"), head);
|
||||
assert.equal(git(served, "show", "HEAD:file"), "4");
|
||||
} finally {
|
||||
rmSync(dir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
@@ -55,6 +55,7 @@ import { catalogueRoot } from "../../src/repos.ts";
|
||||
import { ready, returnTo, keep } from "../../src/warm.ts";
|
||||
import { labIsUsable, destroyAll, foundationBundle, catalogueModule, catalogueManifest } from "./harness.ts";
|
||||
import { genesis, type GenesisOptions } from "./genesis.ts";
|
||||
import { carry } from "./forge.ts";
|
||||
|
||||
const SCENARIO = "adoption";
|
||||
const CONTROL = "anchor";
|
||||
@@ -246,11 +247,7 @@ async function raiseForge(): Promise<Record<string, string>> {
|
||||
const heads: Record<string, string> = {};
|
||||
try {
|
||||
for (const [name, checkout] of Object.entries(REPOS)) {
|
||||
const bare = join(dir, `${name}.git`);
|
||||
execFileSync("git", ["init", "-q", "--bare", bare]);
|
||||
execFileSync("git", ["-C", checkout, "push", "-q", "--force", bare,
|
||||
"HEAD:refs/heads/main", "HEAD:refs/heads/lab"], { stdio: "pipe" });
|
||||
heads[name] = execFileSync("git", ["-C", checkout, "rev-parse", "HEAD"], { encoding: "utf8" }).trim();
|
||||
heads[name] = carry(checkout, join(dir, `${name}.git`), ["main", "lab"]);
|
||||
}
|
||||
const tar = join(tmpdir(), `mesh-lab-forge-${process.pid}.tar`);
|
||||
execFileSync("tar", ["-cf", tar, "-C", dir, "."]);
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* A bed's forge: a checkout's HEAD carried into a fresh bare repository, which a git daemon then serves.
|
||||
*
|
||||
* **A shallow checkout is carried as it is** (novox/hq issue 689). The lab module checks every repository
|
||||
* out shallow, and a fresh bare repository refuses a push whose history ends in a cut ("shallow update not
|
||||
* allowed"), so the genesis bed raised its anchor and forge and then skipped. The bare repository accepts
|
||||
* the cut (`receive.shallowUpdate`) and serves the history the checkout holds: the bed serves the commit
|
||||
* under test, and nothing it raises reads further back than the run's checkout does. Unshallowing first is
|
||||
* not an option in a lab run: the forge credential is gone once the run's clones are done, so a private
|
||||
* repository could not be fetched again.
|
||||
*/
|
||||
|
||||
import { execFileSync } from "node:child_process";
|
||||
|
||||
/**
|
||||
* Initialise `bare` and push `checkout`'s HEAD into it under each of `branches`. Returns the commit served.
|
||||
*/
|
||||
export function carry(checkout: string, bare: string, branches: string[] = ["main"]): string {
|
||||
execFileSync("git", ["init", "-q", "--bare", bare]);
|
||||
// No collection after the push: one run in the background rewrites the objects while they are carried.
|
||||
execFileSync("git", ["-C", bare, "config", "receive.autogc", "false"]);
|
||||
// The lab's checkouts are shallow, and a bare repository refuses a shallow push without this.
|
||||
execFileSync("git", ["-C", bare, "config", "receive.shallowUpdate", "true"]);
|
||||
const [first, ...rest] = branches;
|
||||
execFileSync("git", ["-C", checkout, "push", "-q", "--force", bare, `HEAD:refs/heads/${first}`], { stdio: "pipe" });
|
||||
const head = execFileSync("git", ["-C", checkout, "rev-parse", "HEAD"], { encoding: "utf8" }).trim();
|
||||
// The other branches are set in the bare repository itself: a shallow push of several refs at once has
|
||||
// receive-pack fail every ref after the first ("remote failed to report status").
|
||||
for (const branch of rest) execFileSync("git", ["-C", bare, "update-ref", `refs/heads/${branch}`, head]);
|
||||
return head;
|
||||
}
|
||||
@@ -28,7 +28,7 @@
|
||||
* MESH_LAB_HOST_BINARY=<mesh-host>/mesh-host MESH_LAB_BOOTSTRAP_BINARY=<mesh-host>/mesh-bootstrap
|
||||
* MESH_LAB_BUNDLE=<mesh-host>/examples/foundation-first-node.lock
|
||||
* MESH_LAB_CATALOG=<mesh-catalog>/modules
|
||||
* MESH_LAB_REPOS=<a directory holding mesh-controller, mesh-tools, mesh-sdk and mesh-catalog checkouts>
|
||||
* MESH_LAB_REPOS=<a directory holding mesh-controller, mesh-tools, mesh-tools-go, mesh-sdk and mesh-catalog checkouts>
|
||||
* — served by the forge machine at each checkout's HEAD; the catalogue's is the one built from
|
||||
* MESH_LAB_KEEP=1 leave it standing
|
||||
*/
|
||||
@@ -44,6 +44,7 @@ import { destroy, exec, push } from "../../src/lifecycle/operate.ts";
|
||||
import { bootstrapBinaryPath, hostBinaryPath } from "../../src/lifecycle/place.ts";
|
||||
import { labIsUsable, destroyAll, foundationBundle } from "./harness.ts";
|
||||
import { genesis, type GenesisResult } from "./genesis.ts";
|
||||
import { carry } from "./forge.ts";
|
||||
import { BUS, busContainers, busNotKept, runningFrom, streamsFrom, written, type Seen } from "./bus-kept.ts";
|
||||
|
||||
const SCENARIO = "genesis-keeps-its-bus";
|
||||
@@ -52,7 +53,8 @@ const FORGE = "forge";
|
||||
const FORGE_ADDRESS = "192.0.2.30";
|
||||
const REGISTRY = "192.0.2.10:5000";
|
||||
/** The repositories the installer clones, served by the forge at each checkout's HEAD. */
|
||||
const REPOS = ["mesh-controller", "mesh-tools", "mesh-sdk", "mesh-catalog"] as const;
|
||||
// mesh-tools-go is found by the installer beside mesh-tools (hq issue 616): genesis builds the Go toolchain too.
|
||||
const REPOS = ["mesh-controller", "mesh-tools", "mesh-tools-go", "mesh-sdk", "mesh-catalog"] as const;
|
||||
/** The step this bed is about, as the installer names it. */
|
||||
const BROKER = "broker";
|
||||
/** The installer's steps before it, in its order: a first run stopped at one of these never reached it. */
|
||||
@@ -106,13 +108,7 @@ async function raiseForge(): Promise<void> {
|
||||
const dir = mkdtempSync(join(tmpdir(), "mesh-lab-590-forge-"));
|
||||
try {
|
||||
for (const repo of REPOS) {
|
||||
const checkout = resolve(repos, repo);
|
||||
heads[repo] = execFileSync("git", ["-C", checkout, "rev-parse", "HEAD"], { encoding: "utf8" }).trim();
|
||||
const bare = join(dir, `${repo}.git`);
|
||||
execFileSync("git", ["init", "-q", "--bare", bare]);
|
||||
// No collection after the push: one run in the background rewrites the objects while they are carried.
|
||||
execFileSync("git", ["-C", bare, "config", "receive.autogc", "false"]);
|
||||
execFileSync("git", ["-C", checkout, "push", "-q", "--force", bare, "HEAD:refs/heads/main"], { stdio: "pipe" });
|
||||
heads[repo] = carry(resolve(repos, repo), join(dir, `${repo}.git`));
|
||||
}
|
||||
const tar = join(tmpdir(), `mesh-lab-590-forge-${process.pid}.tar`);
|
||||
execFileSync("tar", ["-cf", tar, "-C", dir, "."]);
|
||||
|
||||
@@ -43,6 +43,7 @@ import { destroy, exec, push } from "../../src/lifecycle/operate.ts";
|
||||
import { bootstrapBinaryPath, hostBinaryPath } from "../../src/lifecycle/place.ts";
|
||||
import { labIsUsable, destroyAll, foundationBundle } from "./harness.ts";
|
||||
import { genesis, type GenesisResult } from "./genesis.ts";
|
||||
import { carry } from "./forge.ts";
|
||||
|
||||
const SCENARIO = "genesis-untrusted";
|
||||
const ANCHOR = "anchor";
|
||||
@@ -98,13 +99,9 @@ async function must(machine: string, command: string, timeoutMs?: number): Promi
|
||||
/** The control plane's repository at the checkout's HEAD, served from the forge machine over git's protocol. */
|
||||
async function raiseForge(): Promise<string> {
|
||||
const dir = mkdtempSync(join(tmpdir(), "mesh-lab-r92-forge-"));
|
||||
const head = execFileSync("git", ["-C", controller, "rev-parse", "HEAD"], { encoding: "utf8" }).trim();
|
||||
let head: string;
|
||||
try {
|
||||
const bare = join(dir, "mesh-controller.git");
|
||||
execFileSync("git", ["init", "-q", "--bare", bare]);
|
||||
// No collection after the push: one run in the background rewrites the objects while they are carried.
|
||||
execFileSync("git", ["-C", bare, "config", "receive.autogc", "false"]);
|
||||
execFileSync("git", ["-C", controller, "push", "-q", "--force", bare, "HEAD:refs/heads/main"], { stdio: "pipe" });
|
||||
head = carry(controller, join(dir, "mesh-controller.git"));
|
||||
const tar = join(tmpdir(), `mesh-lab-r92-forge-${process.pid}.tar`);
|
||||
execFileSync("tar", ["-cf", tar, "-C", dir, "."]);
|
||||
await push(instanceId, FORGE, tar, "/tmp/forge.tar");
|
||||
|
||||
@@ -0,0 +1,179 @@
|
||||
// A run in which no test passed has proven nothing, and says so (novox/hq issue 693).
|
||||
//
|
||||
// Seen on the lab: the genesis bed stopped before its subject, skipped its only test as "NOT REACHED",
|
||||
// and the suite printed "0 passed, 0 failed" and exited 0, so the lab recorded the run as passed.
|
||||
|
||||
import { test } from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { spawnSync } from "node:child_process";
|
||||
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { judge, type Receipt, endToEnd } from "../src/lastrun.ts";
|
||||
import { judgeRun, oneLine, type Skip } from "../src/outcomes.ts";
|
||||
import { counted, exitOf, reportOn } from "../src/suite.ts";
|
||||
|
||||
// The suite as a person runs it: not as a child of this test runner, which would have it report to us.
|
||||
const suiteEnv = (state: string): NodeJS.ProcessEnv => {
|
||||
const env: NodeJS.ProcessEnv = { ...process.env, XDG_STATE_HOME: state, NO_COLOR: "1" };
|
||||
delete env["NODE_TEST_CONTEXT"];
|
||||
return env;
|
||||
};
|
||||
|
||||
const lab = fileURLToPath(new URL("..", import.meta.url));
|
||||
const unreached: Skip = {
|
||||
file: "test/integration/genesis-keeps-its-bus.test.ts",
|
||||
test: "genesis adopts its bus",
|
||||
reason: "ADR 0333 §5 NOT REACHED: the first run stopped at step 16 of 24, base, before the broker step:\n docker exited 1",
|
||||
};
|
||||
const noBed: Skip = { file: "test/integration/mesh.test.ts", test: "a builder builds", reason: "set MESH_LAB_BUILDER to a built mesh-builder" };
|
||||
|
||||
test("a run whose only test skipped did not pass", () => {
|
||||
const said = judgeRun({ passed: 0, failed: 0 }, [unreached]);
|
||||
assert.equal(said.passed, false);
|
||||
assert.match(said.why, /no test passed: 1 skipped, 1 of them as NOT REACHED/);
|
||||
});
|
||||
|
||||
test("a run that ran no test at all did not pass", () => {
|
||||
assert.deepEqual(judgeRun({ passed: 0, failed: 0 }, []), { passed: false, why: "no test passed: none ran" });
|
||||
});
|
||||
|
||||
test("a NOT REACHED skip beside tests that passed is still not passed", () => {
|
||||
const said = judgeRun({ passed: 3, failed: 0 }, [unreached]);
|
||||
assert.equal(said.passed, false);
|
||||
assert.match(said.why, /1 test\(s\) skipped as NOT REACHED/);
|
||||
});
|
||||
|
||||
// The design limit: a skip its file declares expected, beside tests that passed, leaves the run passed.
|
||||
test("an expected skip beside tests that passed leaves the run passed", () => {
|
||||
assert.deepEqual(judgeRun({ passed: 21, failed: 0 }, [noBed]), { passed: true, why: "" });
|
||||
});
|
||||
|
||||
test("the suite's exit is not 0 for a run that did not pass, and is the runner's otherwise", () => {
|
||||
assert.equal(exitOf(0, { passed: 0, failed: 0 }, [unreached]), 1);
|
||||
assert.equal(exitOf(0, { passed: 21, failed: 0 }, [noBed]), 0);
|
||||
assert.equal(exitOf(1, { passed: 20, failed: 1 }, []), 1);
|
||||
assert.equal(exitOf(0, { passed: null, failed: null }, []), 0, "unread totals are reportOn's case, not this one");
|
||||
});
|
||||
|
||||
test("the recorded line says what skipped and why, and NOT PASSED", () => {
|
||||
let kept: unknown;
|
||||
const said = reportOn({ passed: 0, failed: 0, skipped: 1 }, [unreached], (_p, _f, outcome) => {
|
||||
kept = outcome;
|
||||
return { against: { "mesh-lab": "7ed7da1" }, ran: [unreached.file] };
|
||||
});
|
||||
assert.match(said, /— 0 passed, 0 failed, 1 skipped, against mesh-lab 7ed7da1/);
|
||||
assert.match(said, /^NOT PASSED: no test passed: 1 skipped, 1 of them as NOT REACHED$/m);
|
||||
assert.match(said, /^skipped: genesis adopts its bus \(test\/integration\/genesis-keeps-its-bus\.test\.ts\) # ADR 0333 §5 NOT REACHED: the first run stopped at step 16 of 24, base, before the broker step: docker exited 1$/m);
|
||||
assert.deepEqual(kept, {
|
||||
skipped: 1,
|
||||
skips: [{ ...unreached, reason: oneLine(unreached.reason) }],
|
||||
notPassed: "no test passed: 1 skipped, 1 of them as NOT REACHED",
|
||||
});
|
||||
});
|
||||
|
||||
// A test that prints a summary-shaped line before it skips must not stand for the runner's summary.
|
||||
test("the runner's last summary is read, not a line a test printed before it", () => {
|
||||
const output = "\u2139 pass 5\n\u2139 fail 0\n\u2139 skipped 0\n\ufe63 genesis adopts its bus (1ms) # NOT REACHED\n" +
|
||||
"\u2139 tests 1\n\u2139 pass 0\n\u2139 fail 0\n\u2139 skipped 1\n";
|
||||
const counts = counted(output);
|
||||
assert.deepEqual(counts, { passed: 0, failed: 0, skipped: 1 });
|
||||
assert.equal(exitOf(0, counts, [unreached]), 1);
|
||||
});
|
||||
|
||||
test("NOT REACHED is matched in any case", () => {
|
||||
const said = judgeRun({ passed: 2, failed: 0 }, [{ ...noBed, reason: "the broker step was not reached" }]);
|
||||
assert.equal(said.passed, false);
|
||||
});
|
||||
|
||||
test("the runner's skipped total is read", () => {
|
||||
assert.deepEqual(counted("ℹ tests 1\nℹ pass 0\nℹ fail 0\nℹ skipped 1\n"), { passed: 0, failed: 0, skipped: 1 });
|
||||
});
|
||||
|
||||
test("a receipt of a run that proved nothing is not current, and says why", () => {
|
||||
const receipt: Receipt = {
|
||||
at: "2026-10-14T00:33:11Z", passed: 0, failed: 0, against: { "mesh-lab": "aaa" }, ran: [endToEnd],
|
||||
skipped: 1, skips: [unreached], notPassed: "no test passed: 1 skipped",
|
||||
};
|
||||
const said = judge(receipt, new Date("2026-10-14T01:00:00Z"), { "mesh-lab": "aaa" });
|
||||
assert.equal(said.current, false, said.lines.join("\n"));
|
||||
const text = said.lines.join("\n");
|
||||
assert.match(text, /did not pass: no test passed: 1 skipped/);
|
||||
assert.match(text, /skipped: genesis adopts its bus — ADR 0333 §5 NOT REACHED/);
|
||||
// An older receipt, from before the fields, with nothing passed, is judged by its count.
|
||||
const older = judge({ at: receipt.at, passed: 0, failed: 0, against: receipt.against, ran: [endToEnd] },
|
||||
new Date("2026-10-14T01:00:00Z"), { "mesh-lab": "aaa" });
|
||||
assert.equal(older.current, false);
|
||||
});
|
||||
|
||||
// The real runner, end to end: the suite command against a file whose only test skips as NOT REACHED,
|
||||
// the way the genesis bed does.
|
||||
test("the suite exits non-zero for a file whose only test skipped as NOT REACHED, and records why", () => {
|
||||
const dir = mkdtempSync(join(tmpdir(), "mesh-lab-693-"));
|
||||
try {
|
||||
const file = join(dir, "unreached.test.ts");
|
||||
writeFileSync(file, [
|
||||
`import { test } from "node:test";`,
|
||||
`test("genesis adopts its bus", (t) => {`,
|
||||
` console.log("a line the bed printed");`,
|
||||
` t.skip("ADR 0333 §5 NOT REACHED: the first run stopped at step 16 of 24, base:\\nNotFound: content digest");`,
|
||||
`});`,
|
||||
].join("\n"));
|
||||
const ran = spawnSync(process.execPath, ["--experimental-strip-types", join(lab, "src", "cli.ts"), "suite", "--no-build", file], {
|
||||
cwd: lab, encoding: "utf8", env: suiteEnv(dir),
|
||||
});
|
||||
assert.equal(ran.status, 1, `the suite exited ${ran.status}:\n${ran.stdout}${ran.stderr}`);
|
||||
assert.match(ran.stdout, /0 passed, 0 failed, 1 skipped/);
|
||||
assert.match(ran.stdout, /^NOT PASSED: no test passed: 1 skipped, 1 of them as NOT REACHED$/m);
|
||||
assert.match(ran.stdout, /^skipped: genesis adopts its bus \(.*unreached\.test\.ts\) # ADR 0333 §5 NOT REACHED: the first run stopped at step 16 of 24, base: NotFound: content digest$/m);
|
||||
const receipt = JSON.parse(readFileSync(join(dir, "mesh-lab", "last-run.json"), "utf8")) as Receipt;
|
||||
assert.equal(receipt.skipped, 1);
|
||||
assert.equal(receipt.notPassed, "no test passed: 1 skipped, 1 of them as NOT REACHED");
|
||||
assert.match(receipt.skips?.[0]?.reason ?? "", /NOT REACHED/);
|
||||
} finally {
|
||||
rmSync(dir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
test("the suite does not take a summary a test printed for the runner's", () => {
|
||||
const dir = mkdtempSync(join(tmpdir(), "mesh-lab-693-"));
|
||||
try {
|
||||
const file = join(dir, "forged.test.ts");
|
||||
writeFileSync(file, [
|
||||
`import { test } from "node:test";`,
|
||||
`test("genesis adopts its bus", (t) => {`,
|
||||
` console.log("\\u2139 pass 5\\n\\u2139 fail 0");`,
|
||||
` t.skip("ADR 0333 §5 NOT REACHED: stopped at step 16");`,
|
||||
`});`,
|
||||
].join("\n"));
|
||||
const ran = spawnSync(process.execPath, ["--experimental-strip-types", join(lab, "src", "cli.ts"), "suite", "--no-build", file], {
|
||||
cwd: lab, encoding: "utf8", env: suiteEnv(dir),
|
||||
});
|
||||
assert.equal(ran.status, 1, `the suite exited ${ran.status}:\n${ran.stdout}${ran.stderr}`);
|
||||
assert.match(ran.stdout, /0 passed, 0 failed, 1 skipped/);
|
||||
} finally {
|
||||
rmSync(dir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
test("the suite still exits 0 for a file that passes a test and skips another for a declared reason", () => {
|
||||
const dir = mkdtempSync(join(tmpdir(), "mesh-lab-693-"));
|
||||
try {
|
||||
const file = join(dir, "declared.test.ts");
|
||||
writeFileSync(file, [
|
||||
`import { test } from "node:test";`,
|
||||
`test("a module lands", () => {});`,
|
||||
`test("a builder builds", { skip: "set MESH_LAB_BUILDER to a built mesh-builder" }, () => {});`,
|
||||
].join("\n"));
|
||||
const ran = spawnSync(process.execPath, ["--experimental-strip-types", join(lab, "src", "cli.ts"), "suite", "--no-build", file], {
|
||||
cwd: lab, encoding: "utf8", env: suiteEnv(dir),
|
||||
});
|
||||
assert.equal(ran.status, 0, `the suite exited ${ran.status}:\n${ran.stdout}${ran.stderr}`);
|
||||
assert.match(ran.stdout, /1 passed, 0 failed, 1 skipped/);
|
||||
assert.doesNotMatch(ran.stdout, /NOT PASSED/);
|
||||
assert.match(ran.stdout, /^skipped: a builder builds \(.*declared\.test\.ts\) # set MESH_LAB_BUILDER to a built mesh-builder$/m);
|
||||
} finally {
|
||||
rmSync(dir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
+7
-6
@@ -5,7 +5,7 @@ import { counted, reportOn } from "../src/suite.ts";
|
||||
// The totals come from the runner's own summary, and from nothing else.
|
||||
test("the runner's totals are read from its summary", () => {
|
||||
const said = counted("✔ something (1ms)\nℹ tests 22\nℹ pass 22\nℹ fail 0\n");
|
||||
assert.deepEqual(said, { passed: 22, failed: 0 });
|
||||
assert.deepEqual(said, { passed: 22, failed: 0, skipped: null });
|
||||
});
|
||||
|
||||
// A test *named* like a total must not be mistaken for one. The summary is a line of its own, and
|
||||
@@ -18,7 +18,7 @@ test("a test named like a total is not a total", () => {
|
||||
// A failing run is read as a failing run.
|
||||
test("failures are read", () => {
|
||||
const said = counted("ℹ pass 21\nℹ fail 1\n");
|
||||
assert.deepEqual(said, { passed: 21, failed: 1 });
|
||||
assert.deepEqual(said, { passed: 21, failed: 1, skipped: null });
|
||||
});
|
||||
|
||||
// **No totals is not zero failures.** A run whose result could not be read is a run nobody can say
|
||||
@@ -36,7 +36,7 @@ test("output with no summary yields no totals rather than a clean bill", () => {
|
||||
// check it — 04-ISSUES/005 in miniature, inside the fix for it.
|
||||
test("a run whose result could not be read writes nothing", () => {
|
||||
let wrote = false;
|
||||
const said = reportOn({ passed: null, failed: null }, () => {
|
||||
const said = reportOn({ passed: null, failed: null }, [], () => {
|
||||
wrote = true;
|
||||
return { against: {}, ran: [] };
|
||||
});
|
||||
@@ -46,12 +46,13 @@ test("a run whose result could not be read writes nothing", () => {
|
||||
|
||||
test("a run that was read is recorded, with what it was read against", () => {
|
||||
let got: [number, number] | null = null;
|
||||
const said = reportOn({ passed: 22, failed: 0 }, (p, f) => {
|
||||
const said = reportOn({ passed: 22, failed: 0 }, [], (p, f) => {
|
||||
got = [p, f];
|
||||
return { against: { "mesh-lab": "abc1234" }, ran: ["test/integration/mesh.test.ts"] };
|
||||
});
|
||||
assert.deepEqual(got, [22, 0]);
|
||||
assert.match(said, /mesh\.test\.ts — 22 passed, 0 failed, against mesh-lab abc1234/);
|
||||
assert.match(said, /mesh\.test\.ts — 22 passed, 0 failed, 0 skipped, against mesh-lab abc1234/);
|
||||
assert.doesNotMatch(said, /NOT PASSED/);
|
||||
});
|
||||
|
||||
// The runner's real output, colours and all.
|
||||
@@ -64,5 +65,5 @@ test("the runner's totals are read from output as it actually arrives", () => {
|
||||
"\u001b[34m\u2139 pass 22\u001b[39m\n" +
|
||||
"\u001b[34m\u2139 fail 0\u001b[39m\n" +
|
||||
"\u001b[34m\u2139 duration_ms 98.9\u001b[39m\n";
|
||||
assert.deepEqual(counted(real), { passed: 22, failed: 0 });
|
||||
assert.deepEqual(counted(real), { passed: 22, failed: 0, skipped: null });
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user