Remove Komodo backend in favor of native hosts
This commit is contained in:
@@ -4,9 +4,6 @@ import { mkdir, writeFile } from 'node:fs/promises';
|
||||
import { join } from 'node:path';
|
||||
import { gameEvent, postTelemetry } from '../helpers/telemetry.js';
|
||||
|
||||
vi.mock('../../src/lib/server/integrations/komodo.js', () => ({
|
||||
komodoInspectHealthy: vi.fn(), komodoRestart: vi.fn()
|
||||
}));
|
||||
vi.mock('../../src/lib/server/integrations/rcon.js', () => ({
|
||||
rconStatusResult: vi.fn(), rconGetPlayerCount: vi.fn()
|
||||
}));
|
||||
@@ -21,12 +18,13 @@ afterEach(async () => { vi.useRealTimers(); await fixture.cleanup(); });
|
||||
|
||||
async function setup() {
|
||||
const { db } = await import('../../src/lib/server/db/index.js');
|
||||
db().prepare("INSERT INTO servers (name, komodo_name, last_error) VALUES ('managed', 'managed', 'timeout:old process')").run();
|
||||
const { komodoInspectHealthy } = await import('../../src/lib/server/integrations/komodo.js');
|
||||
db().prepare("INSERT INTO servers (name, last_error) VALUES ('managed', 'timeout:old process')").run();
|
||||
vi.spyOn(await import('../../src/lib/server/backends/native.js'), 'nativeHealth');
|
||||
const { nativeHealth } = await import('../../src/lib/server/backends/native.js');
|
||||
const { rconStatusResult } = await import('../../src/lib/server/integrations/rcon.js');
|
||||
const { fanoutStatus } = await import('../../src/lib/server/pipeline/worker.js');
|
||||
const { getServer } = await import('../../src/lib/server/fleet/servers.js');
|
||||
return { db: db(), inspect: vi.mocked(komodoInspectHealthy), rcon: vi.mocked(rconStatusResult), fanoutStatus, getServer };
|
||||
return { db: db(), inspect: vi.mocked(nativeHealth), rcon: vi.mocked(rconStatusResult), fanoutStatus, getServer };
|
||||
}
|
||||
|
||||
describe('database fleet and container readiness', () => {
|
||||
@@ -152,7 +150,9 @@ describe('database fleet and container readiness', () => {
|
||||
vi.useFakeTimers({ toFake: ['Date'] });
|
||||
const now = Date.parse('2026-10-02T12:00:00Z');
|
||||
vi.setSystemTime(now);
|
||||
for (let i = 0; i < 9; i++) db.prepare('INSERT INTO servers (name, komodo_name) VALUES (?, ?)').run(`fast-${i}`, `fast-${i}`);
|
||||
for (let i = 0; i < 9; i++) db.prepare('INSERT INTO servers (name) VALUES (?)').run(`fast-${i}`);
|
||||
const { prepareNativeHost } = await import('../helpers/native-host.js');
|
||||
await prepareNativeHost(['managed', ...Array.from({ length: 9 }, (_, i) => `fast-${i}`)]);
|
||||
let release!: (result: { ok: true; state: string }) => void;
|
||||
let active = 0;
|
||||
let peak = 0;
|
||||
@@ -191,7 +191,7 @@ describe('database fleet and container readiness', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it.each(['native', 'komodo'])('gives each %s host two slots through inspection and RCON, independently of a stalled host', async backend => {
|
||||
it('gives each host two slots through inspection and RCON, independently of a stalled host', async () => {
|
||||
const { db, inspect, rcon, fanoutStatus, getServer } = await setup();
|
||||
db.prepare("DELETE FROM servers WHERE name='managed'").run();
|
||||
const hosts = await import('../../src/lib/server/hosts/index.js');
|
||||
@@ -200,9 +200,9 @@ describe('database fleet and container readiness', () => {
|
||||
hosts.enrollHost(hosts.createEnrollment(registered.id).token, { protocolVersion: 1 });
|
||||
for (let instance = 0; instance < 4; instance++) {
|
||||
const name = `host-${host}-${instance}`;
|
||||
db.prepare('INSERT INTO servers (name, komodo_name, komodo_server) VALUES (?, ?, ?)')
|
||||
.run(name, name, backend === 'komodo' ? registered.id : null);
|
||||
if (backend === 'native') db.prepare(`INSERT INTO native_instances (id,server,host_id,library_id,image,port,created_at)
|
||||
db.prepare('INSERT INTO servers (name) VALUES (?)')
|
||||
.run(name);
|
||||
db.prepare(`INSERT INTO native_instances (id,server,host_id,library_id,image,port,created_at)
|
||||
VALUES (?, ?, ?, 'library', 'image', ?, ?)`).run(name, name, registered.id, 28960 + instance, new Date().toISOString());
|
||||
}
|
||||
}
|
||||
@@ -254,7 +254,7 @@ describe('database fleet and container readiness', () => {
|
||||
vi.useFakeTimers({ toFake: ['Date'] });
|
||||
const now = Date.parse('2026-10-02T12:00:00Z');
|
||||
vi.setSystemTime(now);
|
||||
db.prepare("INSERT INTO servers (name, komodo_name) VALUES ('slow', 'slow')").run();
|
||||
db.prepare("INSERT INTO servers (name) VALUES ('slow')").run();
|
||||
let release!: (result: { ok: true; state: string }) => void;
|
||||
inspect.mockImplementation(async name => name === 'slow'
|
||||
? await new Promise<{ ok: true; state: string }>(resolve => { release = resolve; })
|
||||
@@ -531,7 +531,7 @@ describe('database fleet and container readiness', () => {
|
||||
expect(listServers()).toEqual([]);
|
||||
});
|
||||
|
||||
it('skips startup RCON, clears old errors, and resumes polling only after Komodo is ready', async () => {
|
||||
it('skips startup RCON, clears old errors, and resumes polling only after the host agent reports readiness', async () => {
|
||||
const { inspect, rcon, fanoutStatus, getServer } = await setup();
|
||||
const { GET } = await import('../../src/routes/api/servers/+server.js');
|
||||
inspect.mockResolvedValue({ ok: false, state: 'starting', reason: 'container state: starting' });
|
||||
|
||||
Reference in New Issue
Block a user