Remove Komodo backend in favor of native hosts
This commit is contained in:
@@ -2,7 +2,6 @@ import { randomUUID } from 'node:crypto';
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import { newFixture, type Fixture } from '../helpers/fixture.js';
|
||||
|
||||
vi.mock('../../src/lib/server/integrations/komodo.js', () => ({ komodoInspectHealthy: vi.fn() }));
|
||||
vi.mock('../../src/lib/server/integrations/rcon.js', () => ({ rconStatusResult: vi.fn() }));
|
||||
|
||||
const server = 'managed';
|
||||
@@ -22,11 +21,12 @@ afterEach(async () => { vi.useRealTimers(); await fixture.cleanup(); vi.restoreA
|
||||
async function setup() {
|
||||
const { db } = await import('../../src/lib/server/db/index.js');
|
||||
const database = db();
|
||||
database.prepare('INSERT INTO servers(name,komodo_name,created_at,game_port) VALUES(?,?,?,28960)')
|
||||
.run(server, server, new Date(now).toISOString());
|
||||
const { komodoInspectHealthy } = await import('../../src/lib/server/integrations/komodo.js');
|
||||
database.prepare('INSERT INTO servers(name,created_at,game_port) VALUES(?,?,28960)')
|
||||
.run(server, new Date(now).toISOString());
|
||||
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 inspect = vi.mocked(komodoInspectHealthy).mockResolvedValue(healthy);
|
||||
const inspect = vi.mocked(nativeHealth).mockResolvedValue(healthy);
|
||||
const rcon = vi.mocked(rconStatusResult).mockResolvedValue(playing);
|
||||
return { database, inspect, rcon, ...await import('../../src/lib/server/fleet/health-observations.js') };
|
||||
}
|
||||
@@ -228,37 +228,6 @@ describe('shared monitoring observations', () => {
|
||||
expect(api.inspect).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
it('invalidates integration changes and accepts legacy port discovery by the successful RCON probe', async () => {
|
||||
const api = await setup();
|
||||
await api.inspectForMonitoring(server);
|
||||
api.database.prepare("UPDATE servers SET komodo_name='replacement' WHERE name=?").run(server);
|
||||
await api.inspectForMonitoring(server);
|
||||
expect(api.inspect).toHaveBeenCalledTimes(2);
|
||||
api.database.prepare('UPDATE servers SET game_port=NULL WHERE name=?').run(server);
|
||||
api.rcon.mockImplementationOnce(async () => {
|
||||
api.database.prepare('UPDATE servers SET game_port=28960 WHERE name=?').run(server);
|
||||
return playing;
|
||||
});
|
||||
expect((await api.rconForMonitoring(server)).result).toEqual(playing);
|
||||
await api.rconForMonitoring(server);
|
||||
expect(api.rcon).toHaveBeenCalledTimes(1);
|
||||
api.database.prepare('UPDATE servers SET game_port=28961 WHERE name=?').run(server);
|
||||
await api.rconForMonitoring(server);
|
||||
expect(api.rcon).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
it.each(['inspect', 'rcon'] as const)('does not reuse %s after a newer manual observation', async kind => {
|
||||
const api = await setup();
|
||||
const call = kind === 'inspect' ? api.inspectForMonitoring : api.rconForMonitoring;
|
||||
const request = kind === 'inspect' ? api.inspect : api.rcon;
|
||||
const field = kind === 'inspect' ? 'container_checked_at' : 'last_checked_at';
|
||||
await call(server);
|
||||
vi.setSystemTime(now + 1000);
|
||||
api.database.prepare(`UPDATE servers SET ${field}=? WHERE name=?`).run(new Date(now + 1000).toISOString(), server);
|
||||
await call(server);
|
||||
expect(request).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
it('rejects a previous generation completing after replacement without discarding the new generation cache', async () => {
|
||||
const api = await setup();
|
||||
const { instanceId } = await native(api);
|
||||
|
||||
Reference in New Issue
Block a user