Let each kind of game server alert be switched off

Three tick boxes on the Fragnet integration: do not alert about disk space,
memory or backups. The page still shows the figures (a switched-off bar is blue
and the backups tile says not judged); /metrics is unchanged.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5.5 committed 2026-11-08 22:36:54 +01:00
1 parent 4a7b1494c8
commit 1ef686d1ba
8 files changed
+58 -15

No files matched your search

+36 -4
View File
@@ -369,10 +369,42 @@ describe("what is wrong", () => {
});
test("the settings: what is given is used, nonsense falls back to the defaults, names are compared without regard to case", () => {
assert.deepEqual({ ...fn.optionsOf(null) }, { backupDays: 7, fullPercent: 90, ignoreBackups: [] });
assert.deepEqual({ ...fn.optionsOf({ backupDays: "3", fullPercent: "85,5", ignoreBackups: "Test, Rust\nBuild" }) }, { backupDays: 3, fullPercent: 85.5, ignoreBackups: ["test", "rust", "build"] });
assert.deepEqual({ ...fn.optionsOf({ backupDays: "0", fullPercent: "x" }) }, { backupDays: 0, fullPercent: 90, ignoreBackups: [] });
assert.deepEqual({ ...fn.optionsOf({ backupDays: "-4" }) }, { backupDays: 7, fullPercent: 90, ignoreBackups: [] });
const all = { backups: true, disk: true, memory: true };
assert.deepEqual({ ...fn.optionsOf(null) }, { backupDays: 7, fullPercent: 90, ignoreBackups: [], alerts: all });
assert.deepEqual({ ...fn.optionsOf({ backupDays: "3", fullPercent: "85,5", ignoreBackups: "Test, Rust\nBuild" }) }, { backupDays: 3, fullPercent: 85.5, ignoreBackups: ["test", "rust", "build"], alerts: all });
assert.deepEqual({ ...fn.optionsOf({ backupDays: "0", fullPercent: "x" }) }, { backupDays: 0, fullPercent: 90, ignoreBackups: [], alerts: all });
assert.deepEqual({ ...fn.optionsOf({ backupDays: "-4" }) }, { backupDays: 7, fullPercent: 90, ignoreBackups: [], alerts: all });
});
describe("alerts switched off", () => {
const use = (diskGb: number, memGb: number) => ({ memoryBytes: memGb * GB, cpu: 10, diskBytes: diskGb * GB, rxBytes: 0, txBytes: 0, uptimeMs: HOUR });
// a server with everything wrong at once: no backup, a nearly full disk, memory over the limit
const everything = () => stored({ backups: [], usage: use(19, 3.8) });
const kinds = (o = opts()) => problems(everything(), o).map((p) => p.key.replace(/:.*$/, "")).sort();
test("by default every kind is raised", () => {
assert.deepEqual(kinds(), ["fragnet-backup", "fragnet-disk", "fragnet-memory"]);
});
test("memory switched off: no memory alert, disk and backups still are", () => {
assert.deepEqual(kinds(fn.optionsOf({ muteMemory: true })), ["fragnet-backup", "fragnet-disk"]);
});
test("disk switched off, and backups switched off, each on its own", () => {
assert.deepEqual(kinds(fn.optionsOf({ muteDisk: true })), ["fragnet-backup", "fragnet-memory"]);
assert.deepEqual(kinds(fn.optionsOf({ muteBackups: true })), ["fragnet-disk", "fragnet-memory"]);
});
test("memory alone left on keeps the others quiet; all three off says nothing", () => {
assert.deepEqual(kinds(fn.optionsOf({ muteDisk: true, muteBackups: true })), ["fragnet-memory"]);
assert.deepEqual(kinds(fn.optionsOf({ muteDisk: true, muteMemory: true, muteBackups: true })), []);
});
test("a checkbox is true, or the text true as the settings keep it; anything else leaves the alert on", () => {
assert.equal(fn.optionsOf({ muteMemory: "true" }).alerts.memory, false);
for (const v of [false, "false", "", "yes", 1, null, undefined]) assert.equal(fn.optionsOf({ muteMemory: v }).alerts.memory, true, JSON.stringify(v));
});
test("it is the alert that goes, not the reading: the limit and the other servers are untouched", () => {
const two = [stored({ backups: [okBackup(DAY, {}, NOW)], usage: use(19, 1) }), { ...stored({ backups: [okBackup(DAY, {}, NOW)], usage: use(1, 3.8) }), id: "zzzz9999", name: "rust" }];
const out = fn.fragnetProblems(1, "Fragnet", two, NOW, fn.optionsOf({ muteMemory: true }));
assert.deepEqual(out.map((p) => p.key), ["fragnet-disk:1:abcd1234"], "rust's memory is quiet; survival's disk is not");
});
});
});