File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import http , { RefinedResponse , ResponseType } from "k6/http" ;
2+ import { getHeaders } from "./user.utils" ;
3+ import { fail } from "k6" ;
4+ //@ts -ignore
5+ import { FormData } from "https://jslib.k6.io/formdata/0.0.2/index.js" ;
6+ import {
7+ EventDTO ,
8+ } from "./models" ;
9+
10+ const rootUrl = __ENV . ROOT_URL ;
11+
12+ export function getLastEvents ( since : number , type : 'events' | 'traces' = 'events' ) : RefinedResponse < ResponseType | undefined > {
13+ let headers = getHeaders ( ) ;
14+ return http . get ( `${ rootUrl } /infra/v2/event/list/${ type } /${ since } ` , { headers } ) ;
15+ }
16+
17+ export function getLastEventsOrFail ( since : number , type : 'events' | 'traces' = 'events' ) : EventDTO [ ] {
18+ const res = getLastEvents ( since , type ) ;
19+ if ( res . status !== 200 ) {
20+ fail ( `Failed to get last events since ${ since } of type ${ type } ` ) ;
21+ }
22+ return JSON . parse ( res . body as string ) as EventDTO [ ] ;
23+ }
Original file line number Diff line number Diff line change @@ -19,3 +19,4 @@ export * from "./userbook.utils";
1919export * from "./ws.utils" ;
2020export * from "./archive.utils" ;
2121export * from "./explorer.utils" ;
22+ export * from "./events.utils" ;
Original file line number Diff line number Diff line change @@ -301,3 +301,19 @@ export type AppImportResult = {
301301 resourcesIdsMap : Record < string , Record < string , string > > ;
302302 duplicatesNumberMap : Record < string , number > ;
303303} ;
304+
305+
306+ export type EventDTO = {
307+ _id : string ;
308+ resource : string ;
309+ "event-type" : string ;
310+ module : string ;
311+ date : number ;
312+ userId : string ;
313+ profil : string ;
314+ structures : string [ ] ;
315+ classes : string [ ] ;
316+ groups : string [ ] ;
317+ referer : string ;
318+ sessionId : string ;
319+ } ;
You can’t perform that action at this time.
0 commit comments