Skip to content

Commit

Permalink
Add an e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
amortemousque committed Jan 22, 2024
1 parent ac14252 commit b41dba2
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
4 changes: 4 additions & 0 deletions test/e2e/lib/framework/intakeRegistry.ts
Expand Up @@ -121,6 +121,10 @@ export class IntakeRegistry {
get replaySegments() {
return this.replayRequests.map((request) => request.segment)
}

get replayRecords() {
return this.replayRequests.flatMap((request) => request.segment.records)
}
}

function isLogsIntakeRequest(request: IntakeRequest): request is LogsIntakeRequest {
Expand Down
19 changes: 18 additions & 1 deletion test/e2e/lib/framework/serverApps/intake.ts
Expand Up @@ -58,7 +58,7 @@ function computeIntakeRequestInfos(req: express.Request): IntakeRequestInfos {
return {
isBridge: true,
encoding,
intakeType: eventType === 'log' ? 'logs' : 'rum',
intakeType: eventType === 'log' ? 'logs' : eventType === 'record' ? 'replay' : 'rum',
}
}

Expand Down Expand Up @@ -104,6 +104,23 @@ function readReplayIntakeRequest(
infos: IntakeRequestInfos & { intakeType: 'replay' }
): Promise<ReplayIntakeRequest> {
return new Promise((resolve, reject) => {
if (infos.isBridge) {
readStream(req)
.then((rawBody) => {
resolve({
...infos,
segment: {
records: rawBody
.toString('utf-8')
.split('\n')
.map((line): any => JSON.parse(line)),
},
} as ReplayIntakeRequest)
})
.catch(reject)
return
}

let segmentPromise: Promise<{
encoding: string
filename: string
Expand Down
10 changes: 10 additions & 0 deletions test/e2e/scenario/eventBridge.scenario.ts
Expand Up @@ -91,4 +91,14 @@ describe('bridge present', () => {
expect(intakeRegistry.logsEvents.length).toBe(1)
expect(intakeRegistry.hasOnlyBridgeRequests).toBe(true)
})

createTest('send records to the bridge')
.withRum()
.withEventBridge()
.run(async ({ intakeRegistry }) => {
await flushEvents()

expect(intakeRegistry.replayRecords.length).toBeGreaterThan(0)
expect(intakeRegistry.hasOnlyBridgeRequests).toBe(true)
})
})

0 comments on commit b41dba2

Please sign in to comment.