Pool Plutonium keys by game for launches and autoscaling
This commit is contained in:
@@ -6,7 +6,7 @@ let fixture: Fixture;
|
||||
beforeEach(async () => {
|
||||
vi.resetModules(); fixture = await newFixture([]);
|
||||
const { db } = await import('../../src/lib/server/db/index.js');
|
||||
for (const n of [3, 8, 9, 10]) db().prepare('INSERT INTO server_keys(server_id,pluto_key) VALUES(?,?)').run(`t6_zombie_town_${n}`, `secret-${n}`);
|
||||
for (const n of [3, 8, 9, 10]) db().prepare("INSERT INTO server_keys(id,game,pluto_key) VALUES(?,'t6',?)").run(`key-${n}`, `secret-${n}`);
|
||||
});
|
||||
afterEach(async () => { await fixture.cleanup(); vi.useRealTimers(); });
|
||||
const settings = { game: 't6', mapSlug: 'town', maximum: 4, mode: 'dry-run' };
|
||||
@@ -22,7 +22,7 @@ it('persists deduplicated dry-run decisions across restart without provisioning
|
||||
const view = scaling.scalingReport().policies[0];
|
||||
expect(view.policy.id).toBe(saved.id);
|
||||
expect(view.history).toHaveLength(1);
|
||||
expect(view.decision).toMatchObject({ action: 'create', server: 't6_zombie_town_3' });
|
||||
expect(view.decision).toMatchObject({ action: 'create', server: 't6_zombie_town_1' });
|
||||
expect(JSON.stringify(view)).not.toContain('secret');
|
||||
for (const table of ['server_deployments', 'native_creation_intents', 'native_instances']) expect(db().prepare(`SELECT COUNT(*) AS n FROM ${table}`).get()).toEqual({ n: 0 });
|
||||
});
|
||||
@@ -35,8 +35,10 @@ it('rejects duplicate policies, stale edits and changed previews', async () => {
|
||||
expect(() => scaling.previewScaling(settings, saved.id, 0)).toThrow('changed');
|
||||
expect(() => scaling.saveScaling({ ...settings, maximum: 5 }, saved.id, saved.revision, preview.token)).toThrow('preview changed');
|
||||
const { db } = await import('../../src/lib/server/db/index.js');
|
||||
db().prepare("DELETE FROM server_keys WHERE server_id='t6_zombie_town_10'").run();
|
||||
expect(() => scaling.saveScaling({ ...settings, mode: 'create-destroy' }, saved.id, saved.revision, scaling.previewScaling({ ...settings, mode: 'create-destroy' }, saved.id, saved.revision).token)).toThrow('Save keys');
|
||||
const beforeKeyLoss = scaling.previewScaling(settings, saved.id, saved.revision);
|
||||
db().prepare("DELETE FROM server_keys WHERE id='key-10'").run();
|
||||
expect(() => scaling.saveScaling(settings, saved.id, saved.revision, beforeKeyLoss.token)).toThrow('preview changed');
|
||||
expect(scaling.saveScaling(settings, saved.id, saved.revision, scaling.previewScaling(settings, saved.id, saved.revision).token).maximum).toBe(4);
|
||||
});
|
||||
|
||||
it('pauses evaluations and prunes expired observations without deleting current history', async () => {
|
||||
|
||||
Reference in New Issue
Block a user