forked from mtusi2026/mtusi2026lab6
49 lines
4.5 KiB
Plaintext
49 lines
4.5 KiB
Plaintext
bun test v1.4.4 (38afee6c8)
|
|
|
|
student-tests/incident-readback.test.ts:
|
|
1 | import{test,expect}from'bun:test';import{readyIncidentObserved,drained}from'../scripts/lib/incident-readback';
|
|
2 | const fact={id:'own',status:'ready',accepted_at:'2026-11-16T04:14:31Z',first_ready_at:'2026-11-16T04:15:22Z',ready_seconds:51},stop='2026-11-16T04:14:30Z',start='2026-11-16T04:15:16Z';
|
|
3 | const sample=(at:string,phase='worker_recovery')=>({at,phase,rules:[{name:'MessengerReadyErrorBudgetBurn',state:'Alerting'}]});
|
|
4 | test('recognizes firing while the same accepted backlog is recovering after process start',()=>{expect(readyIncidentObserved([sample('2026-11-16T04:15:19Z')],[fact],['own'],stop,start)).toBe(true)});
|
|
^
|
|
error: expect(received).toBe(expected)
|
|
|
|
Expected: true
|
|
Received: false
|
|
|
|
at <anonymous> (/Users/rey/mtuci/vp/lab6/student-tests/incident-readback.test.ts:4:187)
|
|
(fail) recognizes firing while the same accepted backlog is recovering after process start [0.25ms]
|
|
1 | import{test,expect}from'bun:test';import{readyIncidentObserved,drained}from'../scripts/lib/incident-readback';
|
|
2 | const fact={id:'own',status:'ready',accepted_at:'2026-11-16T04:14:31Z',first_ready_at:'2026-11-16T04:15:22Z',ready_seconds:51},stop='2026-11-16T04:14:30Z',start='2026-11-16T04:15:16Z';
|
|
3 | const sample=(at:string,phase='worker_recovery')=>({at,phase,rules:[{name:'MessengerReadyErrorBudgetBurn',state:'Alerting'}]});
|
|
4 | test('recognizes firing while the same accepted backlog is recovering after process start',()=>{expect(readyIncidentObserved([sample('2026-11-16T04:15:19Z')],[fact],['own'],stop,start)).toBe(true)});
|
|
5 | test('accepts firing during worker stop and requires the complete owned late-job cohort',()=>{expect(readyIncidentObserved([sample('2026-11-16T04:15:10Z','worker_stopped')],[fact],['own'],stop,start)).toBe(true);expect(readyIncidentObserved([sample('2026-11-16T04:15:10Z','worker_stopped')],[],['own'],stop,start)).toBe(false)});
|
|
^
|
|
error: expect(received).toBe(expected)
|
|
|
|
Expected: false
|
|
Received: true
|
|
|
|
at <anonymous> (/Users/rey/mtuci/vp/lab6/student-tests/incident-readback.test.ts:5:316)
|
|
(fail) accepts firing during worker stop and requires the complete owned late-job cohort [0.06ms]
|
|
(pass) rejects an unrelated later alert or timely successful workload [0.02ms]
|
|
2 | const fact={id:'own',status:'ready',accepted_at:'2026-11-16T04:14:31Z',first_ready_at:'2026-11-16T04:15:22Z',ready_seconds:51},stop='2026-11-16T04:14:30Z',start='2026-11-16T04:15:16Z';
|
|
3 | const sample=(at:string,phase='worker_recovery')=>({at,phase,rules:[{name:'MessengerReadyErrorBudgetBurn',state:'Alerting'}]});
|
|
4 | test('recognizes firing while the same accepted backlog is recovering after process start',()=>{expect(readyIncidentObserved([sample('2026-11-16T04:15:19Z')],[fact],['own'],stop,start)).toBe(true)});
|
|
5 | test('accepts firing during worker stop and requires the complete owned late-job cohort',()=>{expect(readyIncidentObserved([sample('2026-11-16T04:15:10Z','worker_stopped')],[fact],['own'],stop,start)).toBe(true);expect(readyIncidentObserved([sample('2026-11-16T04:15:10Z','worker_stopped')],[],['own'],stop,start)).toBe(false)});
|
|
6 | test('rejects an unrelated later alert or timely successful workload',()=>{expect(readyIncidentObserved([sample('2026-11-16T04:17:19Z')],[fact],['own'],stop,start)).toBe(false);expect(readyIncidentObserved([sample('2026-11-16T04:15:19Z')],[{...fact,ready_seconds:2}],['own'],stop,start)).toBe(false)});
|
|
7 | test('queue drain needs actual finite samples rather than empty NoData',()=>{expect(drained([])).toBe(false);expect(drained([0])).toBe(true);expect(drained([0,1])).toBe(false);expect(drained([NaN])).toBe(false)});
|
|
^
|
|
error: expect(received).toBe(expected)
|
|
|
|
Expected: false
|
|
Received: true
|
|
|
|
at <anonymous> (/Users/rey/mtuci/vp/lab6/student-tests/incident-readback.test.ts:7:98)
|
|
(fail) queue drain needs actual finite samples rather than empty NoData [0.06ms]
|
|
|
|
1 pass
|
|
3 fail
|
|
6 expect() calls
|
|
Ran 4 tests across 1 file. [8.00ms]
|