Share status monitoring snapshots across each fleet pass
This commit is contained in:
@@ -45,6 +45,24 @@ async function setup(count = 5, hostCount = 1) {
|
||||
}
|
||||
|
||||
describe('host status observations', () => {
|
||||
it('bounds monitoring reads below five per server across thirty instances', async () => {
|
||||
const api = await setup(10, 3);
|
||||
const hosts = await import('../../src/lib/server/hosts/index.js');
|
||||
const wait = vi.spyOn(hosts, 'waitHostOperationStatus').mockImplementation(async id => {
|
||||
const operation = hosts.getHostOperation(id)!;
|
||||
return { ...operation, state: 'completed', result: { results: (operation.payload.instances as { instanceId: string; generation: number }[])
|
||||
.map(target => ({ ...target, reply: { ok: true, text: 'map: mp_kino\nnum score ping guid name\n--- ----- ---- ---- ----\n' } })) } };
|
||||
});
|
||||
const prepare = vi.spyOn(api.db, 'prepare');
|
||||
try {
|
||||
await api.fanoutStatus();
|
||||
const reads = prepare.mock.calls.filter(([sql]) => /^\s*(SELECT|WITH)\b/i.test(sql));
|
||||
expect(reads.length).toBeLessThan(30 * 5);
|
||||
expect(reads.filter(([sql]) => sql.includes('instance_json')).length).toBeLessThanOrEqual(30 * 3 + 5);
|
||||
expect(api.getServer('server-2-9')?.last_players).toBe(0);
|
||||
} finally { prepare.mockRestore(); wait.mockRestore(); }
|
||||
});
|
||||
|
||||
it('uses one batch per host for a fifteen-server pass and shares overlapping scans', async () => {
|
||||
const api = await setup(5, 3);
|
||||
const hosts = await import('../../src/lib/server/hosts/index.js');
|
||||
|
||||
Reference in New Issue
Block a user