Skip to content

Commit

Permalink
test: retry concurrent query
Browse files Browse the repository at this point in the history
  • Loading branch information
Sciator committed Dec 8, 2023
1 parent 383458b commit e837334
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions packages/client/test/integration/e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,16 +173,26 @@ describe('e2e test', () => {
.map(() => client.queryPoints(query, database, queryType))
.map(async (data) => {
const queryValues: typeof values = []
for await (const row of data) {
queryValues.push({
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
avg: row.getFloatField('avg')!,
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
max: row.getFloatField('max')!,
})
// Introduce concurrency: try to process more streams at once and switch between them
await sleep(10)

for (let tries = 10; tries--; ) {
for await (const row of data) {
queryValues.push({
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
avg: row.getFloatField('avg')!,
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
max: row.getFloatField('max')!,
})
// Introduce concurrency: try to process more streams at once and switch between them
await sleep(10)
}
if (queryValues.length === values.length) break
// eslint-disable-next-line no-console
console.log('query failed. retrying')

queryValues.splice(0)
await sleep(2_000)
}

return queryValues
})
)
Expand All @@ -192,7 +202,7 @@ describe('e2e test', () => {
}

await client.close()
}).timeout(10_000)
}).timeout(20_000)

it('big query', async () => {
const {database, token, url} = getEnvVariables()
Expand Down

0 comments on commit e837334

Please sign in to comment.