Lighten library cache reports and heartbeat cleanup

This commit is contained in:
2026-10-05 15:51:55 -04:00
parent 847399a4ff
commit c8c53e87d6
5 changed files with 127 additions and 3 deletions
+24
View File
@@ -31,6 +31,30 @@ async function setup() {
}
describe('independent provisioning scheduling', () => {
it('runs controller library cleanup on worker ticks without overlapping a slow cleanup', async () => {
const s = await setup();
const { cleanupControllerLibraries } = await import('../../src/lib/server/game-files/index.js');
const cleanup = deferred();
vi.mocked(cleanupControllerLibraries).mockImplementationOnce(() => cleanup.promise);
vi.useFakeTimers();
try {
s.startWorker();
expect(cleanupControllerLibraries).toHaveBeenCalledTimes(1);
await vi.advanceTimersByTimeAsync(30_000);
expect(cleanupControllerLibraries).toHaveBeenCalledTimes(1);
expect(s.process.mock.calls.length).toBeGreaterThan(1);
cleanup.resolve();
await vi.advanceTimersByTimeAsync(0);
await vi.advanceTimersByTimeAsync(15_000);
expect(cleanupControllerLibraries).toHaveBeenCalledTimes(2);
} finally {
s.stopWorker(); cleanup.resolve(); s.background.resolve();
await vi.advanceTimersByTimeAsync(0);
vi.useRealTimers();
await vi.waitFor(() => expect(s.workerActivity()).toEqual([]));
}
});
it('admits and checks new work while campaign, beta and maintenance observers are still waiting', async () => {
const s = await setup();
try {