Add autoscaling outcomes to Metrics (Refs #140)

This commit is contained in:
2026-10-10 17:51:31 -04:00
parent 0bfda267ec
commit 528ed7f37a
15 changed files with 612 additions and 6 deletions
+29
View File
@@ -17,6 +17,15 @@ const report = (days: number) => ({
summary: totals,
running: { average: null, peak: 0, capturedHours: 0 },
matches: emptyMatches,
autoscaling: {
added: 0,
removed: 0,
failed: 0,
cancelled: 0,
readinessSamples: 0,
readinessMeanSeconds: null,
readinessMaxSeconds: null
},
points: [],
maps: [],
sampledServerCount: 0,
@@ -71,6 +80,26 @@ function setup(fetcher: typeof fetch) {
}
describe('metrics background refresh', () => {
it.each([
null,
{ ...report(7).autoscaling, added: -1 },
{ ...report(7).autoscaling, cancelled: 1.5 },
{ ...report(7).autoscaling, readinessMeanSeconds: '72' },
{ ...report(7).autoscaling, readinessMaxSeconds: -1 }
])(
'keeps the previous report when autoscaling measurements are invalid (%j)',
async (autoscaling) => {
const refresh = setup(
vi.fn().mockResolvedValue(Response.json({ ...report(7), autoscaling }))
);
await refresh.refresh();
expect(refresh.onData).not.toHaveBeenCalled();
expect(refresh.onError).toHaveBeenLastCalledWith(
'The metrics response was incomplete.'
);
}
);
it.each([undefined, null, -1, 1.5, '1'])(
'rejects an invalid sampled-server count (%s) and accepts a count without server rows',
async (sampledServerCount) => {