Remove autoscaling action cooldown
This commit is contained in:
@@ -114,3 +114,25 @@ it.each([false, true])('reconciles removed-mode creation while preserving submit
|
||||
expect(db().prepare('SELECT COUNT(*) AS n FROM server_key_leases').get()).toEqual({ n: submitted ? 1 : 0 });
|
||||
expect(db().prepare("SELECT COUNT(*) AS n FROM server_deployments WHERE action='create'").get()).toEqual({ n: 1 });
|
||||
});
|
||||
|
||||
it('removes saved cooldowns on upgrade without changing the empty hold or pausing the policy', async () => {
|
||||
const { db, closeDb } = await import('../../src/lib/server/db/index.js');
|
||||
const scaling = await import('../../src/lib/server/autoscaling/index.js');
|
||||
const input = { ...settings, emptyMinutes: 17 };
|
||||
const saved = scaling.saveScaling(input, undefined, undefined, scaling.previewScaling(input).token);
|
||||
db().exec('ALTER TABLE autoscaling_policies ADD COLUMN next_action_at INTEGER NOT NULL DEFAULT 0');
|
||||
db().prepare("UPDATE autoscaling_policies SET next_action_at=?,settings=json_set(settings,'$.cooldownMinutes',60) WHERE id=?")
|
||||
.run(Date.now() + 3600_000, saved.id);
|
||||
closeDb();
|
||||
const restored = scaling.getScalingPolicy(saved.id)!;
|
||||
expect(restored).toEqual(saved);
|
||||
expect(restored).not.toHaveProperty('cooldownMinutes');
|
||||
expect(restored).not.toHaveProperty('nextActionAt');
|
||||
expect(db().pragma('table_info(autoscaling_policies)')).not.toContainEqual(expect.objectContaining({ name: 'next_action_at' }));
|
||||
expect(JSON.parse((db().prepare('SELECT settings FROM autoscaling_policies WHERE id=?').get(saved.id) as { settings: string }).settings))
|
||||
.not.toHaveProperty('cooldownMinutes');
|
||||
closeDb();
|
||||
expect(scaling.getScalingPolicy(saved.id)).toEqual(saved);
|
||||
expect(await scaling.runAutoscaling()).toBe(true);
|
||||
expect(scaling.scalingReport().policies[0].policy.emptyMinutes).toBe(17);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user