Restrict launches to prepared runtimes (Refs #93)
CI / checks (push) Successful in 4m53s

This commit is contained in:
2026-10-09 17:15:15 -04:00
parent f0afd6de67
commit 596b160be3
36 changed files with 347 additions and 116 deletions
+27 -1
View File
@@ -15,7 +15,7 @@ const inventory = {
cpuUsagePercent: 0,
memoryTotal: 64 * GiB,
memoryAvailable: 60 * GiB,
runtimeImages: ['image'],
preparedRuntimeImages: ['image'],
libraries: [
{ id: 't5-library', state: 'ready' },
{ id: 't6-library', state: 'ready' }
@@ -46,6 +46,32 @@ afterEach(async () => {
});
describe('cached launch availability', () => {
it.each([{ preparedRuntimeImages: [] }, { preparedRuntimeImages: ['another:image'] }])(
'excludes a cached image until it is prepared ($preparedRuntimeImages)',
async ({ preparedRuntimeImages }) => {
const { heartbeat } = await import('../../src/lib/server/hosts/index.js');
const { launchAvailability } =
await import('../../src/lib/server/hosts/availability.js');
heartbeat(hostId, {
...inventory,
runtimeImages: ['image'],
preparedRuntimeImages
});
const unavailable = launchAvailability([t5]);
expect(unavailable.availability).toMatchObject({
estimatedAvailable: 0,
portsAvailable: 0
});
expect(unavailable.warnings.join(' ')).toContain('Waiting for an eligible host');
heartbeat(hostId, { ...inventory, runtimeImages: ['image'] });
expect(launchAvailability([t5]).availability).toMatchObject({
estimatedAvailable: 1,
portsAvailable: 3
});
}
);
it('reads cached estimates without placement, historical scans, or repeated database reads', async () => {
const { db } = await import('../../src/lib/server/db/index.js');
const capacity = await import('../../src/lib/server/hosts/capacity.js');