Files
mesh-catalog/modules/gitea/test/pool-cap.test.ts
T
jschoubben 4becc7bd83
mesh/delivery merged: source.main moved to novox/mesh-catalog@53d173aa7de5
mesh/check checking 4becc7bd8312 on 53d173aa7de5
Forge database pool caps are config values and a change recreates the forge (issue 1966, recovery)
The caps were literals in server.env and the container named no restart-on, so a changed env-file never reached the running forge. They are now three gitea config values placed with ${config:...}, and the server container restarts on server-env.

Claude-Session: https://claude.ai/code/session_01NcbgfFfQ4Z9UE5jK32PmE5
2026-11-08 03:33:16 +01:00

27 lines
1.5 KiB
TypeScript

import { test } from "node:test";
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
// The forge's own database pool is capped (issue 1966): the store's connections are shared by every module on the machine.
// The caps are config values placed into the env-file, and a changed env-file recreates the container.
const env = readFileSync(new URL("../files/server.env", import.meta.url), "utf8");
const manifest = JSON.parse(readFileSync(new URL("../module.json", import.meta.url), "utf8"));
test("the forge's pool caps are config values, placed in server.env, and a change recreates the container", () => {
const lines = env.split("\n");
const placed: Record<string, [string, unknown]> = {
GITEA__database__MAX_OPEN_CONNS: ["database-max-open-connections", 40],
GITEA__database__MAX_IDLE_CONNS: ["database-max-idle-connections", 10],
GITEA__database__CONN_MAX_LIFETIME: ["database-connection-lifetime", "5m"],
};
for (const [name, [key, def]] of Object.entries(placed)) {
assert.ok(lines.includes(`${name}=\${config:${key}}`), `server.env does not place ${key} at ${name}`);
assert.equal(manifest.config[key].default, def);
assert.equal(manifest.config[key].trusted, false);
assert.ok(manifest.config[key].description.includes("100 connections"));
}
assert.equal(manifest.config["database-max-open-connections"].minimum, 1);
const server = manifest.resources.find((r: { id: string }) => r.id === "server");
assert.deepEqual(server["restart-on"], ["server-env"]);
});