The run rebuilds the module runtimes its beds stock (075); two mechanism beds read the catalogue's redis (074) #43

Merged
jschoubben merged 3 commits from feat/mesh-tests-and-runtimes into main 2026-09-21 17:36:44 +00:00
4 changed files with 31 additions and 101 deletions
Showing only changes of commit 1b2443690d - Show all commits
+3
View File
@@ -24,6 +24,9 @@ images:
# Redis's tool+provisioner runtime, built by scripts/build-module-runtime.sh redis into the local # Redis's tool+provisioner runtime, built by scripts/build-module-runtime.sh redis into the local
# daemon and loaded onto the machine, which holds it by its own image ID. # daemon and loaded onto the machine, which holds it by its own image ID.
- mesh-runtime-redis:development - mesh-runtime-redis:development
# The vault's, for the beds that install the catalogue's redis: its own password is a secret the
# vault provides (novox/hq ADR 0085).
- mesh-runtime-mesh-vault:development
place: place:
all: [host, runtime] all: [host, runtime]
+5 -4
View File
@@ -34,8 +34,11 @@ import { catalogueIsPresent, catalogueDir } from "./integration/harness.ts";
* WEARING the bed proves a mesh mechanism (a grant, a credential, a restart, a route) with a * WEARING the bed proves a mesh mechanism (a grant, a credential, a restart, a route) with a
* module cut down to the shape the mechanism needs — no upstream server, a secret in the * module cut down to the shape the mechanism needs — no upstream server, a secret in the
* environment, a requirement edge removed — and gives it a catalogue name. It is a mesh * environment, a requirement edge removed — and gives it a catalogue name. It is a mesh
* test wearing a catalogue module's name. It should carry a name of its own, or read the * test wearing a catalogue module's name. It cannot simply be renamed: a module's name
* catalogue and meet the module's real requirements. * is its tool namespace and its broker scope, so a fixture running the module's runtime
* must carry the module's name (novox/hq ADR 0093). It reads the catalogue and installs
* what the module requires — the vault for a secret, the route module for a route — or
* it runs no real runtime and carries a name of its own.
* DIFFERS a module bed whose copy differs from the catalogue in more than the lab may rewrite * DIFFERS a module bed whose copy differs from the catalogue in more than the lab may rewrite
* (an image, a port, an address). Reading the catalogue is the fix and needs a run. * (an image, a port, an address). Reading the catalogue is the fix and needs a run.
*/ */
@@ -55,10 +58,8 @@ const STILL_CARRIED: Record<string, { modules: string[]; why: string }> = {
"assigned-plex.test.ts": { modules: ["plex"], why: "WEARING: the sidecar alone, no Plex, the token in the environment" }, "assigned-plex.test.ts": { modules: ["plex"], why: "WEARING: the sidecar alone, no Plex, the token in the environment" },
"assigned-redis.test.ts": { modules: ["redis"], why: "WEARING: its own secret, a lab seal key in the environment" }, "assigned-redis.test.ts": { modules: ["redis"], why: "WEARING: its own secret, a lab seal key in the environment" },
"assigned-sonarr.test.ts": { modules: ["sonarr"], why: "WEARING: the sidecar alone against a forged config.xml" }, "assigned-sonarr.test.ts": { modules: ["sonarr"], why: "WEARING: the sidecar alone against a forged config.xml" },
"mesh-grant-end-to-end.test.ts": { modules: ["redis"], why: "WEARING: a grant mechanism test" },
"minio-grant-end-to-end.test.ts": { modules: ["minio"], why: "WEARING: a grant mechanism test, the root password by env-file" }, "minio-grant-end-to-end.test.ts": { modules: ["minio"], why: "WEARING: a grant mechanism test, the root password by env-file" },
"postgres-grant-end-to-end.test.ts": { modules: ["postgres"], why: "WEARING: a grant mechanism test, the superuser by env-file" }, "postgres-grant-end-to-end.test.ts": { modules: ["postgres"], why: "WEARING: a grant mechanism test, the superuser by env-file" },
"provider-on-backend-network.test.ts": { modules: ["redis"], why: "WEARING: a network mechanism test" },
"provider-uses-mesh-credential.test.ts": { modules: ["redis"], why: "WEARING: a credential mechanism test" }, "provider-uses-mesh-credential.test.ts": { modules: ["redis"], why: "WEARING: a credential mechanism test" },
"runtime-restart-on-config.test.ts": { modules: ["grafana"], why: "WEARING: a restart mechanism test" }, "runtime-restart-on-config.test.ts": { modules: ["grafana"], why: "WEARING: a restart mechanism test" },
"route-forwarding.test.ts": { modules: ["route-proxy", "hello-web"], "route-forwarding.test.ts": { modules: ["route-proxy", "hello-web"],
+12 -47
View File
@@ -23,7 +23,7 @@ import { loadScenario } from "../../src/declaration/parse.ts";
import { raise } from "../../src/lifecycle/raise.ts"; import { raise } from "../../src/lifecycle/raise.ts";
import { destroy, exec } from "../../src/lifecycle/operate.ts"; import { destroy, exec } from "../../src/lifecycle/operate.ts";
import { hostBinaryPath, HOST_PATH } from "../../src/lifecycle/place.ts"; import { hostBinaryPath, HOST_PATH } from "../../src/lifecycle/place.ts";
import { labIsUsable, destroyAll, foundationBundle, onTheMachine } from "./harness.ts"; import { labIsUsable, destroyAll, foundationBundle, onTheMachine, catalogueModule, catalogueIsPresent } from "./harness.ts";
import type { HeldImage } from "../../src/pinning.ts"; import type { HeldImage } from "../../src/pinning.ts";
const capability = await labIsUsable(); const capability = await labIsUsable();
@@ -36,7 +36,7 @@ const skip = !capability.usable
? "MESH_LAB_HOST_BINARY is not set to a built mesh-host" ? "MESH_LAB_HOST_BINARY is not set to a built mesh-host"
: !bundle || !existsSync(bundle) : !bundle || !existsSync(bundle)
? "MESH_LAB_BUNDLE is not set to a foundation bundle (mesh-host examples/)" ? "MESH_LAB_BUNDLE is not set to a foundation bundle (mesh-host examples/)"
: false; : catalogueIsPresent();
const SCENARIO = "redis-node"; const SCENARIO = "redis-node";
const MACHINE = "anchor"; const MACHINE = "anchor";
@@ -139,51 +139,12 @@ after(async () => {
test("the mesh grants a consumer redis's cache, and the credential it delivers authenticates", { test("the mesh grants a consumer redis's cache, and the credential it delivers authenticates", {
skip, timeout: 900_000, skip, timeout: 900_000,
}, async () => { }, async () => {
// The PROVIDER: redis in its committed shape — server and a broker-bound runtime on the private // The PROVIDER: the catalogue's redis (novox/hq 04-ISSUES/074) — server and a broker-bound
// redis network, the runtime running the provisioner. // runtime on the private redis network, the runtime running the provisioner. It requires a
const redisManifest = JSON.stringify({ // `secret` for its own password, so the vault that provides one is installed beside it, exactly
module: "redis", // as the vault bed does.
version: "1", const vaultManifest = catalogueModule("mesh-vault", held);
provides: [{ name: "redis-cache", scope: "mesh" }], const redisManifest = catalogueModule("redis", held);
serves: { "redis-cache": {} },
emits: ["module.redis.cache.provisioned", "module.redis.cache.deprovisioned"],
consumes: ["module.redis.cache.provisioned", "module.redis.cache.deprovisioned"],
receives: { "redis-cache": "/var/lib/redis-module/grants/mesh.json" },
grants: { "redis-cache": "/var/lib/redis-module/grants" },
"own-secrets": { default: "/var/lib/redis-module/default.secret", broker: "/var/lib/mesh/redis/broker" },
resources: [
{ id: "mesh-state", type: "directory", path: "/var/lib/mesh/redis", mode: "0700" },
{ id: "state", type: "directory", path: "/var/lib/redis-module", mode: "0700" },
{ id: "grants-dir", type: "directory", path: "/var/lib/redis-module/grants", mode: "0700" },
{ id: "data", type: "directory", path: "/services/redis/data", mode: "0700", owner: "999:999" },
{
id: "server-conf", type: "file", path: "/var/lib/redis-module/redis.conf", mode: "0644",
content: "requirepass ${secret:default}\nappendonly no\ndir /data\n",
},
{ id: "net", type: "network", name: "redis" },
{
id: "server", type: "container", name: "redis", image: pinned("redis"), network: "redis",
ports: ["6379"],
volumes: ["/services/redis/data:/data", "/var/lib/redis-module/redis.conf:/etc/redis/redis.conf:ro"],
args: ["/etc/redis/redis.conf"],
},
{
id: "runtime", type: "container", name: "mesh-redis", image: pinned("mesh-runtime-redis"),
network: "redis",
volumes: [
"/var/lib/mesh/redis/broker:/run/secrets/broker:ro",
"/var/lib/redis-module/grants:/var/lib/redis-module/grants:ro",
"/var/lib/redis-module/default.secret:/run/secrets/default:ro",
],
env: {
MESH_BROKER_FILE: "/run/secrets/broker",
MESH_RECEIVES: "/var/lib/redis-module/grants/mesh.json",
MESH_PROVISION_REDIS: "redis:6379",
MESH_PROVISION_PASSWORD_FILE: "/run/secrets/default",
},
},
],
});
// The CONSUMER: a module that requires redis-cache and no more. It runs no code here — the mesh // The CONSUMER: a module that requires redis-cache and no more. It runs no code here — the mesh
// delivers it a bound file (where redis is, and the login to present) and its sealed password, // delivers it a bound file (where redis is, and the login to present) and its sealed password,
@@ -201,6 +162,10 @@ test("the mesh grants a consumer redis's cache, and the credential it delivers a
resources: [{ id: "state", type: "directory", path: "/var/lib/cacheuser", mode: "0700" }], resources: [{ id: "state", type: "directory", path: "/var/lib/cacheuser", mode: "0700" }],
}); });
await must(`printf %s ${quote(vaultManifest)} > /tmp/mesh-vault.json && docker cp /tmp/mesh-vault.json mesh-controller:/mesh-vault.json`);
await mesh("module add /mesh-vault.json");
await mesh(`module issue mesh-vault --node ${MACHINE}`);
await mesh(`assign ${MACHINE} mesh-vault`);
await must(`printf %s ${quote(redisManifest)} > /tmp/redis.json && docker cp /tmp/redis.json mesh-controller:/redis.json`); await must(`printf %s ${quote(redisManifest)} > /tmp/redis.json && docker cp /tmp/redis.json mesh-controller:/redis.json`);
await mesh("module add /redis.json"); await mesh("module add /redis.json");
await mesh(`module issue redis --node ${MACHINE}`); await mesh(`module issue redis --node ${MACHINE}`);
@@ -20,7 +20,7 @@ import { loadScenario } from "../../src/declaration/parse.ts";
import { raise } from "../../src/lifecycle/raise.ts"; import { raise } from "../../src/lifecycle/raise.ts";
import { destroy, exec } from "../../src/lifecycle/operate.ts"; import { destroy, exec } from "../../src/lifecycle/operate.ts";
import { hostBinaryPath, HOST_PATH } from "../../src/lifecycle/place.ts"; import { hostBinaryPath, HOST_PATH } from "../../src/lifecycle/place.ts";
import { labIsUsable, destroyAll, foundationBundle, onTheMachine } from "./harness.ts"; import { labIsUsable, destroyAll, foundationBundle, onTheMachine, catalogueModule, catalogueIsPresent } from "./harness.ts";
import type { HeldImage } from "../../src/pinning.ts"; import type { HeldImage } from "../../src/pinning.ts";
const capability = await labIsUsable(); const capability = await labIsUsable();
@@ -33,7 +33,7 @@ const skip = !capability.usable
? "MESH_LAB_HOST_BINARY is not set to a built mesh-host" ? "MESH_LAB_HOST_BINARY is not set to a built mesh-host"
: !bundle || !existsSync(bundle) : !bundle || !existsSync(bundle)
? "MESH_LAB_BUNDLE is not set to a foundation bundle (mesh-host examples/)" ? "MESH_LAB_BUNDLE is not set to a foundation bundle (mesh-host examples/)"
: false; : catalogueIsPresent();
const SCENARIO = "redis-node"; const SCENARIO = "redis-node";
const MACHINE = "anchor"; const MACHINE = "anchor";
@@ -136,54 +136,15 @@ after(async () => {
test("redis's runtime, on the backend's private network, binds the broker and provisions with the mesh's credential", { test("redis's runtime, on the backend's private network, binds the broker and provisions with the mesh's credential", {
skip, timeout: 900_000, skip, timeout: 900_000,
}, async () => { }, async () => {
// Exactly the committed redis shape: a private `redis` network, the server on it with a published // The catalogue's redis (novox/hq 04-ISSUES/074): a private `redis` network, the server on it
// port, and the runtime on it too — reaching redis by name and the broker by NAT. // with a published port, and the runtime on it too — reaching redis by name and the broker by
const manifest = JSON.stringify({ // NAT. Its own password is a `secret` the vault provides, so the vault is installed beside it.
module: "redis", const vaultManifest = catalogueModule("mesh-vault", held);
version: "1", await must(`printf %s ${quote(vaultManifest)} > /tmp/mesh-vault.json && docker cp /tmp/mesh-vault.json mesh-controller:/mesh-vault.json`);
provides: [{ name: "redis-cache", scope: "mesh" }], await mesh("module add /mesh-vault.json");
serves: { "redis-cache": {} }, await mesh(`module issue mesh-vault --node ${MACHINE}`);
emits: ["module.redis.cache.provisioned", "module.redis.cache.deprovisioned"], await mesh(`assign ${MACHINE} mesh-vault`);
consumes: ["module.redis.cache.provisioned", "module.redis.cache.deprovisioned"], const manifest = catalogueModule("redis", held);
receives: { "redis-cache": "/var/lib/redis-module/grants/mesh.json" },
grants: { "redis-cache": "/var/lib/redis-module/grants" },
"own-secrets": { default: "/var/lib/redis-module/default.secret", broker: "/var/lib/mesh/redis/broker" },
resources: [
{ id: "mesh-state", type: "directory", path: "/var/lib/mesh/redis", mode: "0700" },
{ id: "state", type: "directory", path: "/var/lib/redis-module", mode: "0700" },
{ id: "grants-dir", type: "directory", path: "/var/lib/redis-module/grants", mode: "0700" },
{ id: "data", type: "directory", path: "/services/redis/data", mode: "0700", owner: "999:999" },
{
id: "server-conf", type: "file", path: "/var/lib/redis-module/redis.conf", mode: "0644",
content: "requirepass ${secret:default}\nappendonly no\ndir /data\n",
},
{ id: "net", type: "network", name: "redis" },
{
id: "server", type: "container", name: "redis", image: pinned("redis"), network: "redis",
ports: ["6379"],
volumes: [
"/services/redis/data:/data",
"/var/lib/redis-module/redis.conf:/etc/redis/redis.conf:ro",
],
args: ["/etc/redis/redis.conf"],
},
{
id: "runtime", type: "container", name: "mesh-redis", image: pinned("mesh-runtime-redis"),
network: "redis",
volumes: [
"/var/lib/mesh/redis/broker:/run/secrets/broker:ro",
"/var/lib/redis-module/grants:/var/lib/redis-module/grants:ro",
"/var/lib/redis-module/default.secret:/run/secrets/default:ro",
],
env: {
MESH_BROKER_FILE: "/run/secrets/broker",
MESH_RECEIVES: "/var/lib/redis-module/grants/mesh.json",
MESH_PROVISION_REDIS: "redis:6379",
MESH_PROVISION_PASSWORD_FILE: "/run/secrets/default",
},
},
],
});
await must(`printf %s ${quote(manifest)} > /tmp/redis.json && docker cp /tmp/redis.json mesh-controller:/redis.json`); await must(`printf %s ${quote(manifest)} > /tmp/redis.json && docker cp /tmp/redis.json mesh-controller:/redis.json`);
await mesh("module add /redis.json"); await mesh("module add /redis.json");
await mesh(`module issue redis --node ${MACHINE}`); await mesh(`module issue redis --node ${MACHINE}`);