Separate provisioning jobs from activity log
This commit is contained in:
@@ -58,6 +58,29 @@ describe('Activity query parameters', () => {
|
||||
});
|
||||
|
||||
describe('unified retained Activity', () => {
|
||||
it('excludes provisioning jobs from log totals and pages regardless of action or trigger, while retaining contextual history', async () => {
|
||||
const api = await setup();
|
||||
for (const action of ['create', 'start', 'restart', 'rebuild', 'stop', 'destroy']) {
|
||||
for (const source of ['ui', 'autoscaling:policy', 'maintenance:1', 'campaign:release', 'beta:1', 'watchdog:finding']) {
|
||||
api.operation(`${action}-${source}`, { action, source });
|
||||
}
|
||||
}
|
||||
api.remote('check', { kind: 'instance.inspect', routine: 1 });
|
||||
api.incident('finding');
|
||||
api.maintenance(2);
|
||||
const query = { excludeProvisioning: true, limit: 2 };
|
||||
const first = api.activityHistory(query);
|
||||
const last = api.activityHistory({ ...query, offset: 2 });
|
||||
expect(first.total).toBe(3);
|
||||
expect(last.total).toBe(3);
|
||||
expect(first.rows).toHaveLength(2);
|
||||
expect(last.rows).toHaveLength(1);
|
||||
expect([...first.rows, ...last.rows].map(row => row.id).sort()).toEqual(['host:check', 'maintenance:2', 'recovery:finding']);
|
||||
expect(api.activityHistory({ ...query, type: 'create' }).total).toBe(0);
|
||||
expect(api.activityHistory({ ...query, source: 'autoscaling' }).total).toBe(0);
|
||||
expect(api.activityHistory({ server }).total).toBe(39);
|
||||
});
|
||||
|
||||
it('paginates the full union with exact totals, stable ties and removed-server history', async () => {
|
||||
const api = await setup();
|
||||
api.handle.transaction(() => {
|
||||
@@ -205,12 +228,14 @@ describe('unified retained Activity', () => {
|
||||
it('uses the same query contract for API and page loaders with no-store API responses', async () => {
|
||||
const api = await setup();
|
||||
api.operation('a'); api.operation('b', { state: 'failed' });
|
||||
const url = new URL('http://localhost/activity?state=failed&limit=1');
|
||||
api.remote('failed-check', { kind: 'instance.inspect', routine: 1, state: 'failed' });
|
||||
const url = new URL('http://localhost/activity?state=failed&limit=1&excludeProvisioning=true');
|
||||
const { GET } = await import('../../src/routes/api/activity/+server.js');
|
||||
const { load } = await import('../../src/routes/activity/+page.server.js');
|
||||
const response = GET({ url });
|
||||
expect(response.headers.get('cache-control')).toBe('no-store');
|
||||
expect(await response.json()).toEqual(JSON.parse(JSON.stringify(load({ url }).activity)));
|
||||
expect(load({ url }).activity.rows[0].id).toBe('provisioning:b');
|
||||
expect(load({ url }).activity.rows[0].id).toBe('host:failed-check');
|
||||
expect(load({ url: new URL('http://localhost/activity?excludeProvisioning=false') }).activity.rows.some(row => row.id.startsWith('provisioning:'))).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user