Files
mesh-lab/test/warm.test.ts
T
jschoubben a516ee847b Adopt a third-party workload, and keep a mesh between runs
**The adoption.** Software nobody here wrote, taking its credentials the
way such software does — from its environment — and needing two
containers that reach each other by name. The first module that could
not have been declared this morning: it needs the network shape and it
needs a sealed value to reach a container's environment.

Its password is accepted rather than generated, which is the whole shape
of an adoption: a service that already exists keeps the credential it
already has. Asserted properly — a wrong password is refused by the same
database, so the passing case means something.

**The warm scenario.** A mesh kept between runs and returned to, which
turned twelve minutes of bootstrap into thirty seconds of restore. Off
unless asked for: a run that is meant to mean something raises from
nothing.

Its guard fired for real during this work, unprompted — a mesh-host
commit landed and it refused the stale base, naming both commits, rather
than passing tests against yesterday's binary. That is 04-ISSUES/005's
rule one level down.

Three things the guard learned the hard way and now handles: a snapshot
captures disk and not memory, so the host is restarted after a restore
and asserted to have come back; the stocked image digests are worked out
while raising and a restored instance never raises, so they are kept;
and comparing only the repositories this run can see clears the ones it
cannot, so both directions are compared.

The one real bug behind five failed attempts was in mesh-host and it
reported itself precisely: a network shape the language had and no host
implemented. Everything else was scaffolding of mine.
2026-09-01 01:20:14 +02:00

62 lines
3.0 KiB
TypeScript

import { test } from "node:test";
import assert from "node:assert/strict";
import { judge, type Warm } from "../src/warm.ts";
const at = "2026-08-31T20:00:00Z";
const built = { "mesh-lab": "aaa", "mesh-host": "bbb", "mesh-control": "ccc" };
const warm = (over: Partial<Warm> = {}): Warm =>
({ scenario: "two-nodes", instanceId: "mlab-two-nodes-1", images: [], against: built, at, ...over });
// The check this exists for: a mesh warmed against code that has since moved would pass today's
// tests against yesterday's binaries, and the result would say nothing about it.
//
// Same fault as novox/hq 04-ISSUES/005, one level down — a green result standing for a run
// against something other than what is in front of you.
test("a warm mesh built from code that has moved is refused", () => {
const said = judge(warm(), "two-nodes", ["mlab-two-nodes-1"], true,
{ ...built, "mesh-host": "moved" });
assert.equal(said.use, "raise");
assert.match(said.use === "raise" ? said.why : "", /mesh-host was at bbb.*now at moved/);
});
test("a warm mesh built from the same code is used", () => {
const said = judge(warm(), "two-nodes", ["mlab-two-nodes-1"], true, built);
assert.equal(said.use, "restore");
});
// Each refusal is named, because each is a different thing being wrong.
test("every reason to raise instead says which reason it was", () => {
const cases: [string, ReturnType<typeof judge>][] = [
["nothing kept", judge(null, "two-nodes", [], true, built)],
["another scenario", judge(warm({ scenario: "first-node" }), "two-nodes",
["mlab-two-nodes-1"], true, built)],
["not standing", judge(warm(), "two-nodes", [], true, built)],
["no snapshot", judge(warm(), "two-nodes", ["mlab-two-nodes-1"], false, built)],
];
for (const [what, said] of cases) {
assert.equal(said.use, "raise", what);
assert.ok(said.use === "raise" && said.why.length > 10,
`${what} was refused without saying why: ${JSON.stringify(said)}`);
}
});
// A repository the warm record never accounted for is a difference, not a match.
test("a repository that was not recorded when it was warmed is refused", () => {
const said = judge(warm({ against: { "mesh-lab": "aaa" } }), "two-nodes",
["mlab-two-nodes-1"], true, built);
assert.equal(said.use, "raise");
});
// A repository the current run cannot see is not a repository that agrees.
//
// **Found by testing the guard rather than trusting it.** The first version walked only the
// repositories the current environment names, so running without that environment compared
// nothing and called a stale mesh usable. The mesh had genuinely moved; the check had looked at
// neither side.
test("a repository this run cannot locate is refused, not passed over", () => {
const said = judge(warm(), "two-nodes", ["mlab-two-nodes-1"], true, { "mesh-lab": "aaa" });
assert.equal(said.use, "raise");
assert.match(said.use === "raise" ? said.why : "",
/nothing says where it is now|so nothing can say whether it moved/);
});