Add autoscaling outcomes to Metrics (Refs #140)
This commit is contained in:
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user