Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
benjackwhite committed Dec 23, 2024
1 parent f97ae83 commit 235807b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion plugin-server/tests/e2e.timeout.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe('e2e ingestion timeout', () => {
expect((await hub.db.fetchEvents()).length).toBe(0)
const uuid = new UUIDT().toString()
await posthog.capture('custom event', { name: 'haha', uuid, randomProperty: 'lololo' })
await delayUntilEventIngested(() => hub.db.fetchEvents())
await delayUntilEventIngested(() => hub.db.fetchEvents(), { maxDelayMs: 50000 })

await hub.kafkaProducer.flush()
const events = await hub.db.fetchEvents()
Expand Down
9 changes: 6 additions & 3 deletions plugin-server/tests/helpers/clickhouse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,13 @@ export async function resetTestDatabaseClickhouse(extraServerConfig?: Partial<Pl

export async function delayUntilEventIngested<T extends any[] | number>(
fetchData: () => T | Promise<T>,
minLength = 1,
delayMs = 100,
maxDelayMs = 5000
options: {
minLength?: number
delayMs?: number
maxDelayMs?: number
} = {}
): Promise<T> {
const { minLength = 1, delayMs = 100, maxDelayMs = 5000 } = options
const timer = performance.now()
let data: T
let dataLength = 0
Expand Down

0 comments on commit 235807b

Please sign in to comment.