Add deploy + destroy server flow; migrate to t5_<mode>_<slug>_<n> naming

Full server lifecycle management from Electric Cherry: pick game/mode/map/pluto
key in the Fleet page, EC provisions the deployment via Komodo, allocates a
port in 28960-28980, creates the 0o777 host dir, and starts the container.
Destroy button tears everything down (Komodo Destroy+Delete, rm -rf host dir,
transactional DB cleanup) and surfaces any partial-failure warnings inline.

Same phase cuts over to the new naming scheme (t5_zombie_cosmodrome_1 etc.).
Komodo entity names now match EC server names 1:1 (no more _/- transform), and
the map catalog carries friendly/slug/canonical for each of the 11 t5 zombie
maps. Server rows gain game_mode, map_slug, host_dir, config_file, game_id,
image, created_by, and destroyed_at columns for provisioning + audit.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-09-13 18:38:42 -04:00
co-authored by Claude Opus 4.7
parent 8c15cae80d
commit 13a29e5ace
25 changed files with 1103 additions and 123 deletions
+1 -1
View File
@@ -15,7 +15,7 @@ export interface Fixture {
* under test is imported. There's no shared/scripts directory anymore — the
* upload-only model puts script content in the DB.
*/
export async function newFixture(servers: string[] = ['t5_kino_1']): Promise<Fixture> {
export async function newFixture(servers: string[] = ['t5_zombie_theater_1']): Promise<Fixture> {
const root = await mkdtemp(join(tmpdir(), 'cherry-'));
const t5 = join(root, 't5');
const betaArchive = join(root, 'beta-archive');
+9 -9
View File
@@ -8,7 +8,7 @@ let fixture: Fixture;
beforeEach(async () => {
vi.resetModules();
fixture = await newFixture(['t5_kino_1']);
fixture = await newFixture(['t5_zombie_theater_1']);
delete process.env.KOMODO_ADDRESS;
delete process.env.RCON_PASSWORD;
});
@@ -30,7 +30,7 @@ async function seedFleet(): Promise<void> {
await seedServerRegistry();
// Pre-create the configs directory so the config write path finds a
// hospitable server tree.
await mkdir(join(fixture.t5, 't5_kino_1', 'configs'), { recursive: true });
await mkdir(join(fixture.t5, 't5_zombie_theater_1', 'configs'), { recursive: true });
}
describe('config baseline + overlay flow', () => {
@@ -65,14 +65,14 @@ describe('config baseline + overlay flow', () => {
{ scriptId: baselineScript.id, scriptVersionId: bVer.id },
{ scriptId: overlayScript.id, scriptVersionId: oVer.id }
],
servers: ['t5_kino_1'],
servers: ['t5_zombie_theater_1'],
waitForHealth: false,
waitForMatch: false
});
// 4. Verify: composed cfg lands at configs/dedicated_sp.cfg (in place,
// NO -beta suffix — the game reads the exact filename).
const cfgPath = join(fixture.t5, 't5_kino_1', 'configs', 'dedicated_sp.cfg');
const cfgPath = join(fixture.t5, 't5_zombie_theater_1', 'configs', 'dedicated_sp.cfg');
expect(existsSync(cfgPath)).toBe(true);
const composed = (await readFile(cfgPath)).toString('utf8');
expect(composed).toContain('set g_inactivity "0"');
@@ -106,14 +106,14 @@ describe('config baseline + overlay flow', () => {
// baseline is available.
const { betaId } = await openBeta({
scripts: [{ scriptId: overlayScript.id, scriptVersionId: oVer.id }],
servers: ['t5_kino_1'],
servers: ['t5_zombie_theater_1'],
waitForHealth: false,
waitForMatch: false
});
const row = db()
.prepare(`SELECT stage, error FROM beta_servers WHERE beta_id = ? AND server = ?`)
.get(betaId, 't5_kino_1') as { stage: string; error: string | null };
.get(betaId, 't5_zombie_theater_1') as { stage: string; error: string | null };
expect(row.stage).toBe('failed');
expect(row.error ?? '').toMatch(/no baseline available/);
});
@@ -123,7 +123,7 @@ describe('plugin kind writes to plugin destination', () => {
it('deploys a plugin .dll directly to its target filename', async () => {
await seedFleet();
// Pre-create the plugins dir so the write can succeed.
await mkdir(join(fixture.t5, 't5_kino_1', 'runtime/plutonium/plugins'), { recursive: true });
await mkdir(join(fixture.t5, 't5_zombie_theater_1', 'runtime/plutonium/plugins'), { recursive: true });
const { createScript, getLatestVersion } = await import('../../src/lib/server/fleet/scripts.js');
const { openBeta } = await import('../../src/lib/server/fleet/beta.js');
@@ -139,12 +139,12 @@ describe('plugin kind writes to plugin destination', () => {
const { betaId } = await openBeta({
scripts: [{ scriptId: script.id, scriptVersionId: v.id }],
servers: ['t5_kino_1'],
servers: ['t5_zombie_theater_1'],
waitForHealth: false,
waitForMatch: false
});
const pluginPath = join(fixture.t5, 't5_kino_1', 'runtime/plutonium/plugins', 'demo.dll');
const pluginPath = join(fixture.t5, 't5_zombie_theater_1', 'runtime/plutonium/plugins', 'demo.dll');
expect(existsSync(pluginPath)).toBe(true);
const bytes = await readFile(pluginPath);
expect(bytes.equals(Buffer.from([0x00, 0x01, 0x02, 0x03]))).toBe(true);
+12 -12
View File
@@ -8,13 +8,13 @@ let fixture: Fixture;
beforeEach(async () => {
vi.resetModules();
fixture = await newFixture(['t5_kino_1']);
fixture = await newFixture(['t5_zombie_theater_1']);
delete process.env.KOMODO_ADDRESS;
delete process.env.RCON_PASSWORD;
// Ensure the three per-kind destinations exist under the fixture tree.
await mkdir(join(fixture.t5, 't5_kino_1', 'runtime/plutonium/storage/t5/raw/scripts/sp'), { recursive: true });
await mkdir(join(fixture.t5, 't5_kino_1', 'configs'), { recursive: true });
await mkdir(join(fixture.t5, 't5_kino_1', 'runtime/plutonium/plugins'), { recursive: true });
await mkdir(join(fixture.t5, 't5_zombie_theater_1', 'runtime/plutonium/storage/t5/raw/scripts/sp'), { recursive: true });
await mkdir(join(fixture.t5, 't5_zombie_theater_1', 'configs'), { recursive: true });
await mkdir(join(fixture.t5, 't5_zombie_theater_1', 'runtime/plutonium/plugins'), { recursive: true });
});
afterEach(async () => {
@@ -28,7 +28,7 @@ describe('drift scanning', () => {
await seedServerRegistry();
// Drop one stray file in each managed destination.
const server = 't5_kino_1';
const server = 't5_zombie_theater_1';
await writeFile(
join(fixture.t5, server, 'runtime/plutonium/storage/t5/raw/scripts/sp', 'stray.gsc'),
'main(){}\n'
@@ -84,7 +84,7 @@ async function promoteAndOrphan(
const ver = getLatestVersion(created.script.id)!;
const { betaId } = await openBeta({
scripts: [{ scriptId: created.script.id, scriptVersionId: ver.id }],
servers: ['t5_kino_1'],
servers: ['t5_zombie_theater_1'],
waitForHealth: false,
waitForMatch: false
});
@@ -121,7 +121,7 @@ describe('missing artifact detection', () => {
const targetPath = join(
fixture.t5,
't5_kino_1',
't5_zombie_theater_1',
'runtime/plutonium/storage/t5/raw/scripts/sp',
'hud.gsc'
);
@@ -131,13 +131,13 @@ describe('missing artifact detection', () => {
// Simulate someone deleting the file out-of-band.
await rm(targetPath, { force: true });
const drift = await scanServerDrift('t5_kino_1');
const drift = await scanServerDrift('t5_zombie_theater_1');
const missing = drift.filter((d) => d.driftKind === 'missing' && d.kind === 'script');
expect(missing.length).toBe(1);
expect(missing[0].relPath).toBe('hud.gsc');
const result = await runDriftDeployment({
servers: ['t5_kino_1'],
servers: ['t5_zombie_theater_1'],
dryRun: false,
triggeredBy: 'ui'
});
@@ -169,7 +169,7 @@ describe('missing artifact detection', () => {
const bVer = getLatestVersion(baseline.script.id)!;
const { betaId } = await openBeta({
scripts: [{ scriptId: baseline.script.id, scriptVersionId: bVer.id }],
servers: ['t5_kino_1'],
servers: ['t5_zombie_theater_1'],
waitForHealth: false,
waitForMatch: false
});
@@ -179,11 +179,11 @@ describe('missing artifact detection', () => {
db().prepare(`UPDATE betas SET state = 'ready-promote' WHERE id = ?`).run(betaId);
await promoteBeta(betaId);
const cfgPath = join(fixture.t5, 't5_kino_1', 'configs', 'dedicated_sp.cfg');
const cfgPath = join(fixture.t5, 't5_zombie_theater_1', 'configs', 'dedicated_sp.cfg');
expect(existsSync(cfgPath)).toBe(true);
await rm(cfgPath, { force: true });
const drift = await scanServerDrift('t5_kino_1');
const drift = await scanServerDrift('t5_zombie_theater_1');
const missingCfg = drift.filter((d) => d.driftKind === 'missing' && d.kind === 'config');
expect(missingCfg.length).toBe(1);
expect(missingCfg[0].relPath).toBe('dedicated_sp.cfg');
+1 -1
View File
@@ -5,6 +5,6 @@ describe('slugify', () => {
it('matches the legacy behavior', () => {
expect(slugify('New HUD Test')).toBe('new-hud-test');
expect(slugify(' --Weird!!! ')).toBe('weird');
expect(slugify('t5_kino_1')).toBe('t5-kino-1');
expect(slugify('t5_zombie_theater_1')).toBe('t5-zombie-theater-1');
});
});
+1 -1
View File
@@ -16,7 +16,7 @@ const { resolveLogPath, tailLog, isLogKey } = await import(
'../../src/lib/server/fleet/logs.js'
);
const SERVER = 't5_test_1';
const SERVER = 't5_zombie_theater_1';
const LOG_DIR = resolve(TMP_ROOT, SERVER, 'logs');
beforeEach(() => {
+61 -28
View File
@@ -1,69 +1,102 @@
import { describe, expect, it } from 'vitest';
import { parseServerName, T5_MAP_ALIASES } from '../../src/lib/server/fleet/map-aliases.js';
import {
parseServerName,
t5ZombieMapBySlug,
T5_ZOMBIE_MAPS
} from '../../src/lib/server/fleet/map-aliases.js';
describe('parseServerName', () => {
it('extracts game, map alias, canonical map, and lobby from a T5 server name', () => {
expect(parseServerName('t5_ascension_1')).toEqual({
describe('parseServerName (new naming: t5_<mode>_<slug>_<n>)', () => {
it('extracts game, mode, slug, canonical, and lobby from a T5 zombie name', () => {
expect(parseServerName('t5_zombie_cosmodrome_1')).toEqual({
game: 't5',
mapAlias: 'ascension',
gameMode: 'zombie',
mapSlug: 'cosmodrome',
mapCanonical: 'zombie_cosmodrome',
lobby: 1
});
expect(parseServerName('t5_kino_1')).toEqual({
expect(parseServerName('t5_zombie_theater_2')).toEqual({
game: 't5',
mapAlias: 'kino',
gameMode: 'zombie',
mapSlug: 'theater',
mapCanonical: 'zombie_theater',
lobby: 1
lobby: 2
});
expect(parseServerName('t5_cotd_1')).toEqual({
expect(parseServerName('t5_zombie_coast_1')).toEqual({
game: 't5',
mapAlias: 'cotd',
gameMode: 'zombie',
mapSlug: 'coast',
mapCanonical: 'zombie_coast',
lobby: 1
});
});
it('joins multi-segment map aliases and matches the alias table', () => {
expect(parseServerName('t5_shi_no_numa_1')).toEqual({
it('joins multi-segment slugs and matches the catalog', () => {
// 'shinonuma' is written in-catalog as one word, so a name with
// separators still resolves via join-without-separators lookup.
expect(parseServerName('t5_zombie_shi_no_numa_1')).toEqual({
game: 't5',
mapAlias: 'shinonuma',
gameMode: 'zombie',
mapSlug: 'shinonuma',
mapCanonical: 'zombie_cod5_sumpf',
lobby: 1
});
expect(parseServerName('t5_der_riese_2')).toEqual({
game: 't5',
mapAlias: 'derriese',
mapCanonical: 'zombie_cod5_factory',
lobby: 2
});
});
it('treats a name with no trailing lobby number as an alias-only tail', () => {
expect(parseServerName('t5_moon')).toEqual({
it('treats an absent lobby number as null', () => {
expect(parseServerName('t5_zombie_moon')).toEqual({
game: 't5',
mapAlias: 'moon',
gameMode: 'zombie',
mapSlug: 'moon',
mapCanonical: 'zombie_moon',
lobby: null
});
});
it('returns mapCanonical=null for unknown aliases so operators can spot the gap', () => {
expect(parseServerName('t5_newmap_1')).toEqual({
it('returns mapCanonical=null for unknown slugs so operators can spot the gap', () => {
expect(parseServerName('t5_zombie_newmap_1')).toEqual({
game: 't5',
mapAlias: 'newmap',
gameMode: 'zombie',
mapSlug: 'newmap',
mapCanonical: null,
lobby: 1
});
});
it('parses legacy names without a mode segment (mode=null)', () => {
// Not the new format, but a name like 't5_theater_1' still returns
// meaningful info so the seeder can surface it during migration.
const parsed = parseServerName('t5_theater_1');
expect(parsed).toEqual({
game: 't5',
gameMode: null,
mapSlug: 'theater',
mapCanonical: 'zombie_theater',
lobby: 1
});
});
it('rejects names with fewer than two segments', () => {
expect(parseServerName('t5')).toBeNull();
expect(parseServerName('')).toBeNull();
});
});
it('every alias in T5_MAP_ALIASES resolves to a zombie_* canonical mapname', () => {
for (const canonical of Object.values(T5_MAP_ALIASES)) {
expect(canonical.startsWith('zombie')).toBe(true);
describe('t5ZombieMapBySlug', () => {
it('resolves each catalog slug to its canonical + friendly', () => {
for (const entry of T5_ZOMBIE_MAPS) {
const found = t5ZombieMapBySlug(entry.slug);
expect(found?.canonical).toBe(entry.canonical);
expect(found?.friendly).toBe(entry.friendly);
}
});
it('is case-insensitive', () => {
expect(t5ZombieMapBySlug('COSMODROME')?.canonical).toBe('zombie_cosmodrome');
});
it('every catalog entry canonical starts with zombie', () => {
for (const entry of T5_ZOMBIE_MAPS) {
expect(entry.canonical.startsWith('zombie')).toBe(true);
}
});
});
+10 -10
View File
@@ -7,7 +7,7 @@ let fixture: Fixture;
// fixtures and hits a released sqlite handle.
beforeEach(async () => {
vi.resetModules();
fixture = await newFixture(['t5_kino_1', 't5_ascension_1']);
fixture = await newFixture(['t5_zombie_theater_1', 't5_zombie_cosmodrome_1']);
delete process.env.KOMODO_ADDRESS;
delete process.env.RCON_PASSWORD;
});
@@ -55,7 +55,7 @@ describe('promote creates a deployment', () => {
// other server (via scope) and mark it pending for restart.
const { betaId } = await openBeta({
scripts: [{ scriptId: script.id, scriptVersionId: version.id }],
servers: ['t5_kino_1'],
servers: ['t5_zombie_theater_1'],
waitForHealth: false,
waitForMatch: false
});
@@ -68,7 +68,7 @@ describe('promote creates a deployment', () => {
const result = await promoteBeta(betaId);
expect(result.deploymentId).toMatch(/^dep-.*-promote-\d+$/);
expect(new Set(result.landed)).toEqual(new Set(['t5_kino_1', 't5_ascension_1']));
expect(new Set(result.landed)).toEqual(new Set(['t5_zombie_theater_1', 't5_zombie_cosmodrome_1']));
expect(result.scriptIds).toEqual([script.id]);
// Deployment row is action='promote'. The multi-script schema stores
@@ -99,8 +99,8 @@ describe('promote creates a deployment', () => {
.prepare(`SELECT * FROM deployment_servers WHERE deployment_id = ? ORDER BY server`)
.all(result.deploymentId) as any[];
const byName = Object.fromEntries(servers.map((s) => [s.server, s.restart_state]));
expect(byName['t5_kino_1']).toBe('done');
expect(byName['t5_ascension_1']).toBe('pending');
expect(byName['t5_zombie_theater_1']).toBe('done');
expect(byName['t5_zombie_cosmodrome_1']).toBe('pending');
// Script's current_version_id and beta state land.
const after = getScript(script.id)!;
@@ -128,7 +128,7 @@ describe('rollback beta on ready-promote marks version test-failed', () => {
const { betaId } = await openBeta({
scripts: [{ scriptId: script.id, scriptVersionId: v.id }],
servers: ['t5_kino_1'],
servers: ['t5_zombie_theater_1'],
waitForHealth: false,
waitForMatch: false
});
@@ -165,7 +165,7 @@ describe('rollback promote deployment', () => {
const { betaId } = await openBeta({
scripts: [{ scriptId: script.id, scriptVersionId: v.id }],
servers: ['t5_kino_1'],
servers: ['t5_zombie_theater_1'],
waitForHealth: false,
waitForMatch: false
});
@@ -179,7 +179,7 @@ describe('rollback promote deployment', () => {
const result = await rollbackPromoteDeployment(promote.deploymentId);
expect(result.deploymentId).toMatch(/^dep-.*-rollback-/);
expect(new Set(result.affectedServers)).toEqual(new Set(['t5_kino_1', 't5_ascension_1']));
expect(new Set(result.affectedServers)).toEqual(new Set(['t5_zombie_theater_1', 't5_zombie_cosmodrome_1']));
expect(result.scriptIds).toEqual([script.id]);
// Script's current_version_id reverted (was null before the promote).
@@ -241,7 +241,7 @@ describe('multi-script beta', () => {
{ scriptId: a.script.id, scriptVersionId: va.id },
{ scriptId: b.script.id, scriptVersionId: vb.id }
],
servers: ['t5_kino_1', 't5_ascension_1'],
servers: ['t5_zombie_theater_1', 't5_zombie_cosmodrome_1'],
waitForHealth: false,
waitForMatch: false
});
@@ -252,7 +252,7 @@ describe('multi-script beta', () => {
expect(new Set(bundle.map((r) => r.script_id))).toEqual(new Set([a.script.id, b.script.id]));
// Both target rel paths are held on both servers.
const held1 = heldByBeta('t5_kino_1');
const held1 = heldByBeta('t5_zombie_theater_1');
expect(held1.get('hud.gsc')).toBe(betaId);
expect(held1.get('flag.gsc')).toBe(betaId);
+3 -3
View File
@@ -5,7 +5,7 @@ let fixture: Fixture;
beforeEach(async () => {
vi.resetModules();
fixture = await newFixture(['t5_kino_1', 't5_ascension_1']);
fixture = await newFixture(['t5_zombie_theater_1', 't5_zombie_cosmodrome_1']);
// No integrations → sweep marks rows manual, exercising that branch.
delete process.env.KOMODO_ADDRESS;
delete process.env.RCON_PASSWORD;
@@ -31,12 +31,12 @@ describe('sweep', () => {
.prepare(
"INSERT INTO deployment_servers (deployment_id, server, files_changed, restart_state, attempts) VALUES (?, ?, 1, 'pending', 0)"
)
.run(depId, 't5_kino_1');
.run(depId, 't5_zombie_theater_1');
db()
.prepare(
"INSERT INTO deployment_servers (deployment_id, server, files_changed, restart_state, attempts) VALUES (?, ?, 1, 'pending', 0)"
)
.run(depId, 't5_ascension_1');
.run(depId, 't5_zombie_cosmodrome_1');
await sweep();