Keep lower-numbered lobbies during autoscaling

This commit is contained in:
2026-10-08 14:41:22 -04:00
parent c4e2ff4384
commit 62e3397d5c
5 changed files with 63 additions and 9 deletions
+4 -3
View File
@@ -51,8 +51,9 @@ async function setup(gameWide = false) {
return { db, scaling, authorization, policy: saved, operationId: intent.operation_id, hostId: host.host.id, fresh, dispatch, processProvisioning };
}
it('removes only after a full observed empty interval and claims authorization once', async () => {
it('removes the higher surplus lobby after a full empty interval and claims authorization once', async () => {
const s = await setup();
expect(s.db().prepare('SELECT server FROM server_deployments WHERE id=?').get(s.operationId)).toEqual({ server: names[1] });
const { enableSafetyOverride } = await import('../../src/lib/server/provisioning/safety-override.js');
expect(enableSafetyOverride(s.operationId, { id: 'admin', username: 'admin' }).ok).toBe(false);
const command = await s.dispatch();
@@ -63,7 +64,7 @@ it('removes only after a full observed empty interval and claims authorization o
it('withdraws a queued removal when a player arrives and restarts the empty interval', async () => {
const s = await setup();
s.db().prepare('UPDATE servers SET last_players=1 WHERE name=?').run(names[0]);
s.db().prepare('UPDATE servers SET last_players=1 WHERE name=?').run(names[1]);
await s.scaling.runAutoscaling();
expect(s.db().prepare('SELECT state FROM server_deployments WHERE id=?').get(s.operationId)).toEqual({ state: 'cancelled' });
s.db().prepare('UPDATE servers SET last_players=0').run();
@@ -115,7 +116,7 @@ it('rejects expired, changed revision, and newly protected removal authorization
it('authorizes a game-wide removal without trimming any map below its targets', async () => {
const s = await setup(true);
expect(s.db().prepare("SELECT server FROM server_deployments WHERE id=?").get(s.operationId)).toEqual({ server: names[0] });
expect(s.db().prepare("SELECT server FROM server_deployments WHERE id=?").get(s.operationId)).toEqual({ server: names[1] });
const command = await s.dispatch();
expect(s.authorization.claimRemovalAuthorization(s.hostId, command.id, command.payload).authorized).toBe(true);
});