This commit is contained in:
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user