Make metrics reflect autoscaling policies (Refs #137)
CI / checks (push) Successful in 4m49s
CI / checks (push) Successful in 4m49s
This commit is contained in:
@@ -138,3 +138,32 @@ it('rejects a database from a newer application without changing its version or
|
||||
inspect.close();
|
||||
}
|
||||
});
|
||||
|
||||
it('adds policy report invalidation when upgrading a database at version 12', async () => {
|
||||
const { db, closeDb } = await import('../../src/lib/server/db/index.js');
|
||||
const handle = db();
|
||||
for (const table of ['autoscaling_policies', 'settings'])
|
||||
for (const action of ['INSERT', 'UPDATE', 'DELETE'])
|
||||
handle.exec(`DROP TRIGGER report_metrics_${table}_${action}`);
|
||||
handle.pragma('user_version = 12');
|
||||
closeDb();
|
||||
const upgraded = db();
|
||||
const revision = () =>
|
||||
(
|
||||
upgraded
|
||||
.prepare("SELECT revision FROM report_revisions WHERE topic='metrics'")
|
||||
.get() as { revision: number }
|
||||
).revision;
|
||||
const before = revision();
|
||||
upgraded
|
||||
.prepare(
|
||||
"INSERT INTO settings(key,value) VALUES('autoscaling_paused','1') ON CONFLICT(key) DO UPDATE SET value='1'"
|
||||
)
|
||||
.run();
|
||||
expect(revision()).toBeGreaterThan(before);
|
||||
const paused = revision();
|
||||
upgraded.prepare("INSERT INTO settings(key,value) VALUES('unrelated-setting','1')").run();
|
||||
expect(revision()).toBe(paused);
|
||||
upgraded.prepare("DELETE FROM settings WHERE key='autoscaling_paused'").run();
|
||||
expect(revision()).toBeGreaterThan(paused);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user