From cf928d6e5bc7ec63abf24929e025a8f48a0d4fd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20=C5=BBydek?= Date: Tue, 18 Jun 2024 14:28:56 +0200 Subject: [PATCH] test: wrap mock tests in retry policy --- e2e/scripts/mockTests.ts | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/e2e/scripts/mockTests.ts b/e2e/scripts/mockTests.ts index dac9e27..921b0f7 100644 --- a/e2e/scripts/mockTests.ts +++ b/e2e/scripts/mockTests.ts @@ -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() @@ -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) } }