Files
mtusi2026lab6/evidence/openobserve/bootstrap-legacy-red.txt

138 lines
18 KiB
Plaintext

bun test v1.4.4 (38afee6c8)
vp/lab6/student-tests/openobserve-bootstrap.test.ts:
5 | const checkpoints:Partial<Record<AccountKey,Account>>={},intents:Partial<Record<AccountKey,Intent>>={},captured:Record<string,any>={},creates:AccountKey[]=[];
6 | let index:Record<AccountKey,Account>|undefined,derived=0,published=0,failCreate:AccountKey|undefined,proof:Partial<Capability>={},persistedBeforeQuery=false;
7 | const ports:BootstrapPorts={readIndex:async()=>index,readAccount:async k=>checkpoints[k],readIntent:async k=>intents[k],makeIntent:k=>({email:accountEmail(k),rawFile:'/fake/'+k,captureId:'create-'+k}),claimIntent:async(k,v)=>{if(intents[k])throw new Error('claim exists');intents[k]=v;},readCaptured:async i=>captured[i.rawFile],create:async(k)=>{creates.push(k);if(k==='query')persistedBeforeQuery=!!checkpoints.ingest;if(k===failCreate)throw new Error('synthetic second create failure');return{status:200,body:{code:200,user:accountEmail(k),token:account(k).token}};},saveAccount:async(k,a)=>{checkpoints[k]=a;},verify:async()=>({role:'service_account',searchHTTP:200,searchHasRows:true,ingestHTTP:200,adminRotateHTTP:403,...proof}),publishIndex:async a=>{published++;index=a;},publishDerived:async()=>{derived++;}};
8 | return{ports,checkpoints,intents,captured,creates,setIndex(v:Record<AccountKey,Account>){index=v;},fail(k:AccountKey){failCreate=k;},setProof(v:Partial<Capability>){proof=v;},get derived(){return derived},get published(){return published},get persistedBeforeQuery(){return persistedBeforeQuery}};
9 | }
10 | test('first received credential survives a second account creation failure',async()=>{const f=fixture();f.fail('query');await expect(createAccountBootstrap(f.ports)()).rejects.toThrow();expect(f.checkpoints.ingest).toEqual(account('ingest'));expect(f.derived).toBe(0);});
^
error: expect(received).toEqual(expected)
- {
- "email": "vp6-ingest@lab.invalid",
- "token": "fixture-ingest-token-only",
- }
+ undefined
- Expected - 4
+ Received + 1
at <anonymous> (/Users/rey/mtuci/vp/lab6/student-tests/openobserve-bootstrap.test.ts:10:216)
(fail) first received credential survives a second account creation failure [3.54ms]
6 | let index:Record<AccountKey,Account>|undefined,derived=0,published=0,failCreate:AccountKey|undefined,proof:Partial<Capability>={},persistedBeforeQuery=false;
7 | const ports:BootstrapPorts={readIndex:async()=>index,readAccount:async k=>checkpoints[k],readIntent:async k=>intents[k],makeIntent:k=>({email:accountEmail(k),rawFile:'/fake/'+k,captureId:'create-'+k}),claimIntent:async(k,v)=>{if(intents[k])throw new Error('claim exists');intents[k]=v;},readCaptured:async i=>captured[i.rawFile],create:async(k)=>{creates.push(k);if(k==='query')persistedBeforeQuery=!!checkpoints.ingest;if(k===failCreate)throw new Error('synthetic second create failure');return{status:200,body:{code:200,user:accountEmail(k),token:account(k).token}};},saveAccount:async(k,a)=>{checkpoints[k]=a;},verify:async()=>({role:'service_account',searchHTTP:200,searchHasRows:true,ingestHTTP:200,adminRotateHTTP:403,...proof}),publishIndex:async a=>{published++;index=a;},publishDerived:async()=>{derived++;}};
8 | return{ports,checkpoints,intents,captured,creates,setIndex(v:Record<AccountKey,Account>){index=v;},fail(k:AccountKey){failCreate=k;},setProof(v:Partial<Capability>){proof=v;},get derived(){return derived},get published(){return published},get persistedBeforeQuery(){return persistedBeforeQuery}};
9 | }
10 | test('first received credential survives a second account creation failure',async()=>{const f=fixture();f.fail('query');await expect(createAccountBootstrap(f.ports)()).rejects.toThrow();expect(f.checkpoints.ingest).toEqual(account('ingest'));expect(f.derived).toBe(0);});
11 | test('resume reuses one persisted credential instead of repeating its account POST',async()=>{const f=fixture();f.checkpoints.ingest=account('ingest');await createAccountBootstrap(f.ports)();expect(f.creates).toEqual(['query']);});
^
error: expect(received).toEqual(expected)
[
+ "ingest",
"query",
]
- Expected - 0
+ Received + 1
at <anonymous> (/Users/rey/mtuci/vp/lab6/student-tests/openobserve-bootstrap.test.ts:11:210)
(fail) resume reuses one persisted credential instead of repeating its account POST [0.28ms]
7 | const ports:BootstrapPorts={readIndex:async()=>index,readAccount:async k=>checkpoints[k],readIntent:async k=>intents[k],makeIntent:k=>({email:accountEmail(k),rawFile:'/fake/'+k,captureId:'create-'+k}),claimIntent:async(k,v)=>{if(intents[k])throw new Error('claim exists');intents[k]=v;},readCaptured:async i=>captured[i.rawFile],create:async(k)=>{creates.push(k);if(k==='query')persistedBeforeQuery=!!checkpoints.ingest;if(k===failCreate)throw new Error('synthetic second create failure');return{status:200,body:{code:200,user:accountEmail(k),token:account(k).token}};},saveAccount:async(k,a)=>{checkpoints[k]=a;},verify:async()=>({role:'service_account',searchHTTP:200,searchHasRows:true,ingestHTTP:200,adminRotateHTTP:403,...proof}),publishIndex:async a=>{published++;index=a;},publishDerived:async()=>{derived++;}};
8 | return{ports,checkpoints,intents,captured,creates,setIndex(v:Record<AccountKey,Account>){index=v;},fail(k:AccountKey){failCreate=k;},setProof(v:Partial<Capability>){proof=v;},get derived(){return derived},get published(){return published},get persistedBeforeQuery(){return persistedBeforeQuery}};
9 | }
10 | test('first received credential survives a second account creation failure',async()=>{const f=fixture();f.fail('query');await expect(createAccountBootstrap(f.ports)()).rejects.toThrow();expect(f.checkpoints.ingest).toEqual(account('ingest'));expect(f.derived).toBe(0);});
11 | test('resume reuses one persisted credential instead of repeating its account POST',async()=>{const f=fixture();f.checkpoints.ingest=account('ingest');await createAccountBootstrap(f.ports)();expect(f.creates).toEqual(['query']);});
12 | test('resume recovers a valid captured response without repeating account POST',async()=>{const f=fixture();f.intents.ingest=f.ports.makeIntent('ingest');f.captured['/fake/ingest']={status:200,body:{code:200,user:accountEmail('ingest'),token:account('ingest').token}};await createAccountBootstrap(f.ports)();expect(f.creates).toEqual(['query']);expect(f.checkpoints.ingest).toEqual(account('ingest'));});
^
error: expect(received).toEqual(expected)
[
+ "ingest",
"query",
]
- Expected - 0
+ Received + 1
at <anonymous> (/Users/rey/mtuci/vp/lab6/student-tests/openobserve-bootstrap.test.ts:12:327)
(fail) resume recovers a valid captured response without repeating account POST [0.07ms]
8 | return{ports,checkpoints,intents,captured,creates,setIndex(v:Record<AccountKey,Account>){index=v;},fail(k:AccountKey){failCreate=k;},setProof(v:Partial<Capability>){proof=v;},get derived(){return derived},get published(){return published},get persistedBeforeQuery(){return persistedBeforeQuery}};
9 | }
10 | test('first received credential survives a second account creation failure',async()=>{const f=fixture();f.fail('query');await expect(createAccountBootstrap(f.ports)()).rejects.toThrow();expect(f.checkpoints.ingest).toEqual(account('ingest'));expect(f.derived).toBe(0);});
11 | test('resume reuses one persisted credential instead of repeating its account POST',async()=>{const f=fixture();f.checkpoints.ingest=account('ingest');await createAccountBootstrap(f.ports)();expect(f.creates).toEqual(['query']);});
12 | test('resume recovers a valid captured response without repeating account POST',async()=>{const f=fixture();f.intents.ingest=f.ports.makeIntent('ingest');f.captured['/fake/ingest']={status:200,body:{code:200,user:accountEmail('ingest'),token:account('ingest').token}};await createAccountBootstrap(f.ports)();expect(f.creates).toEqual(['query']);expect(f.checkpoints.ingest).toEqual(account('ingest'));});
13 | test('uncertain intent without recoverable native JSON fails closed without POST retry',async()=>{const f=fixture();f.intents.ingest=f.ports.makeIntent('ingest');await expect(createAccountBootstrap(f.ports)()).rejects.toThrow();expect(f.creates).toHaveLength(0);expect(f.published).toBe(0);expect(f.derived).toBe(0);});
^
error: expect(received).rejects.toThrow(expected)
Expected promise that rejects
Received promise that resolved: Promise { <resolved> }
at <anonymous> (/Users/rey/mtuci/vp/lab6/student-tests/openobserve-bootstrap.test.ts:13:219)
(fail) uncertain intent without recoverable native JSON fails closed without POST retry [0.43ms]
9 | }
10 | test('first received credential survives a second account creation failure',async()=>{const f=fixture();f.fail('query');await expect(createAccountBootstrap(f.ports)()).rejects.toThrow();expect(f.checkpoints.ingest).toEqual(account('ingest'));expect(f.derived).toBe(0);});
11 | test('resume reuses one persisted credential instead of repeating its account POST',async()=>{const f=fixture();f.checkpoints.ingest=account('ingest');await createAccountBootstrap(f.ports)();expect(f.creates).toEqual(['query']);});
12 | test('resume recovers a valid captured response without repeating account POST',async()=>{const f=fixture();f.intents.ingest=f.ports.makeIntent('ingest');f.captured['/fake/ingest']={status:200,body:{code:200,user:accountEmail('ingest'),token:account('ingest').token}};await createAccountBootstrap(f.ports)();expect(f.creates).toEqual(['query']);expect(f.checkpoints.ingest).toEqual(account('ingest'));});
13 | test('uncertain intent without recoverable native JSON fails closed without POST retry',async()=>{const f=fixture();f.intents.ingest=f.ports.makeIntent('ingest');await expect(createAccountBootstrap(f.ports)()).rejects.toThrow();expect(f.creates).toHaveLength(0);expect(f.published).toBe(0);expect(f.derived).toBe(0);});
14 | for(const [name,proof]of [['stale search token401',{searchHTTP:401}],['unavailable ingest503',{ingestHTTP:503}],['rotation401 is not the required403 denial',{adminRotateHTTP:401}]] as const){test(name+' prevents derived publication and successful continuation',async()=>{const f=fixture();f.setIndex({ingest:account('ingest'),query:account('query')});f.setProof(proof);let started=false;await expect((async()=>{await createAccountBootstrap(f.ports)();started=true;})()).rejects.toThrow();expect(f.derived).toBe(0);expect(started).toBe(false);});}
error: expect(received).rejects.toThrow(expected)
Expected promise that rejects
Received promise that resolved: Promise { <resolved> }
at <anonymous> (/Users/rey/mtuci/vp/lab6/student-tests/openobserve-bootstrap.test.ts:14:479)
(fail) stale search token401 prevents derived publication and successful continuation [0.09ms]
9 | }
10 | test('first received credential survives a second account creation failure',async()=>{const f=fixture();f.fail('query');await expect(createAccountBootstrap(f.ports)()).rejects.toThrow();expect(f.checkpoints.ingest).toEqual(account('ingest'));expect(f.derived).toBe(0);});
11 | test('resume reuses one persisted credential instead of repeating its account POST',async()=>{const f=fixture();f.checkpoints.ingest=account('ingest');await createAccountBootstrap(f.ports)();expect(f.creates).toEqual(['query']);});
12 | test('resume recovers a valid captured response without repeating account POST',async()=>{const f=fixture();f.intents.ingest=f.ports.makeIntent('ingest');f.captured['/fake/ingest']={status:200,body:{code:200,user:accountEmail('ingest'),token:account('ingest').token}};await createAccountBootstrap(f.ports)();expect(f.creates).toEqual(['query']);expect(f.checkpoints.ingest).toEqual(account('ingest'));});
13 | test('uncertain intent without recoverable native JSON fails closed without POST retry',async()=>{const f=fixture();f.intents.ingest=f.ports.makeIntent('ingest');await expect(createAccountBootstrap(f.ports)()).rejects.toThrow();expect(f.creates).toHaveLength(0);expect(f.published).toBe(0);expect(f.derived).toBe(0);});
14 | for(const [name,proof]of [['stale search token401',{searchHTTP:401}],['unavailable ingest503',{ingestHTTP:503}],['rotation401 is not the required403 denial',{adminRotateHTTP:401}]] as const){test(name+' prevents derived publication and successful continuation',async()=>{const f=fixture();f.setIndex({ingest:account('ingest'),query:account('query')});f.setProof(proof);let started=false;await expect((async()=>{await createAccountBootstrap(f.ports)();started=true;})()).rejects.toThrow();expect(f.derived).toBe(0);expect(started).toBe(false);});}
error: expect(received).rejects.toThrow(expected)
Expected promise that rejects
Received promise that resolved: Promise { <resolved> }
at <anonymous> (/Users/rey/mtuci/vp/lab6/student-tests/openobserve-bootstrap.test.ts:14:479)
(fail) unavailable ingest503 prevents derived publication and successful continuation [0.04ms]
9 | }
10 | test('first received credential survives a second account creation failure',async()=>{const f=fixture();f.fail('query');await expect(createAccountBootstrap(f.ports)()).rejects.toThrow();expect(f.checkpoints.ingest).toEqual(account('ingest'));expect(f.derived).toBe(0);});
11 | test('resume reuses one persisted credential instead of repeating its account POST',async()=>{const f=fixture();f.checkpoints.ingest=account('ingest');await createAccountBootstrap(f.ports)();expect(f.creates).toEqual(['query']);});
12 | test('resume recovers a valid captured response without repeating account POST',async()=>{const f=fixture();f.intents.ingest=f.ports.makeIntent('ingest');f.captured['/fake/ingest']={status:200,body:{code:200,user:accountEmail('ingest'),token:account('ingest').token}};await createAccountBootstrap(f.ports)();expect(f.creates).toEqual(['query']);expect(f.checkpoints.ingest).toEqual(account('ingest'));});
13 | test('uncertain intent without recoverable native JSON fails closed without POST retry',async()=>{const f=fixture();f.intents.ingest=f.ports.makeIntent('ingest');await expect(createAccountBootstrap(f.ports)()).rejects.toThrow();expect(f.creates).toHaveLength(0);expect(f.published).toBe(0);expect(f.derived).toBe(0);});
14 | for(const [name,proof]of [['stale search token401',{searchHTTP:401}],['unavailable ingest503',{ingestHTTP:503}],['rotation401 is not the required403 denial',{adminRotateHTTP:401}]] as const){test(name+' prevents derived publication and successful continuation',async()=>{const f=fixture();f.setIndex({ingest:account('ingest'),query:account('query')});f.setProof(proof);let started=false;await expect((async()=>{await createAccountBootstrap(f.ports)();started=true;})()).rejects.toThrow();expect(f.derived).toBe(0);expect(started).toBe(false);});}
error: expect(received).rejects.toThrow(expected)
Expected promise that rejects
Received promise that resolved: Promise { <resolved> }
at <anonymous> (/Users/rey/mtuci/vp/lab6/student-tests/openobserve-bootstrap.test.ts:14:479)
(fail) rotation401 is not the required403 denial prevents derived publication and successful continuation [0.04ms]
10 | test('first received credential survives a second account creation failure',async()=>{const f=fixture();f.fail('query');await expect(createAccountBootstrap(f.ports)()).rejects.toThrow();expect(f.checkpoints.ingest).toEqual(account('ingest'));expect(f.derived).toBe(0);});
11 | test('resume reuses one persisted credential instead of repeating its account POST',async()=>{const f=fixture();f.checkpoints.ingest=account('ingest');await createAccountBootstrap(f.ports)();expect(f.creates).toEqual(['query']);});
12 | test('resume recovers a valid captured response without repeating account POST',async()=>{const f=fixture();f.intents.ingest=f.ports.makeIntent('ingest');f.captured['/fake/ingest']={status:200,body:{code:200,user:accountEmail('ingest'),token:account('ingest').token}};await createAccountBootstrap(f.ports)();expect(f.creates).toEqual(['query']);expect(f.checkpoints.ingest).toEqual(account('ingest'));});
13 | test('uncertain intent without recoverable native JSON fails closed without POST retry',async()=>{const f=fixture();f.intents.ingest=f.ports.makeIntent('ingest');await expect(createAccountBootstrap(f.ports)()).rejects.toThrow();expect(f.creates).toHaveLength(0);expect(f.published).toBe(0);expect(f.derived).toBe(0);});
14 | for(const [name,proof]of [['stale search token401',{searchHTTP:401}],['unavailable ingest503',{ingestHTTP:503}],['rotation401 is not the required403 denial',{adminRotateHTTP:401}]] as const){test(name+' prevents derived publication and successful continuation',async()=>{const f=fixture();f.setIndex({ingest:account('ingest'),query:account('query')});f.setProof(proof);let started=false;await expect((async()=>{await createAccountBootstrap(f.ports)();started=true;})()).rejects.toThrow();expect(f.derived).toBe(0);expect(started).toBe(false);});}
15 | test('healthy initial bootstrap checkpoints ingest before starting query creation',async()=>{const f=fixture();await createAccountBootstrap(f.ports)();expect(f.persistedBeforeQuery).toBe(true);expect(f.published).toBe(1);expect(f.derived).toBe(1);});
^
error: expect(received).toBe(expected)
Expected: true
Received: false
at <anonymous> (/Users/rey/mtuci/vp/lab6/student-tests/openobserve-bootstrap.test.ts:15:183)
(fail) healthy initial bootstrap checkpoints ingest before starting query creation [0.57ms]
(pass) healthy saved index revalidates both native identities without new account POST [0.05ms]
1 pass
8 fail
11 expect() calls
Ran 9 tests across 1 file. [43.00ms]