Skip to content

Commit

Permalink
test: wrap mock tests in retry policy
Browse files Browse the repository at this point in the history
  • Loading branch information
TheUnderScorer committed Jun 18, 2024
1 parent 62923e6 commit cf928d6
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion e2e/scripts/mockTests.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { execSync } from 'child_process'
import { readTestInfo } from '../shared/testInfo'
import pkg from '../../package.json'
import { ExponentialBackoff, handleAll, retry } from 'cockatiel'

async function main() {
async function doMockTests() {
let hasError = false
const testInfo = readTestInfo()

Expand Down Expand Up @@ -42,6 +43,24 @@ async function main() {
}

if (hasError) {
throw new Error('One or more tests failed')
}
}

async function main() {
const policy = retry(handleAll, {
backoff: new ExponentialBackoff({
// 5 minutes
maxDelay: 1000 * 60 * 5,
}),
maxAttempts: 3,
})

try {
await policy.execute(doMockTests)
} catch (e) {
console.error(e)

process.exit(1)
}
}
Expand Down

0 comments on commit cf928d6

Please sign in to comment.