[Fleet] Add retries when starting docker registry in integration tests (#125530)

This commit is contained in:
Nicolas Chaulet 2022-02-14 15:04:45 -05:00 committed by GitHub
parent 1751cb2774
commit 57aefd0a6b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -8,6 +8,7 @@
import { spawn } from 'child_process';
import type { ChildProcess } from 'child_process';
import pRetry from 'p-retry';
import fetch from 'node-fetch';
const delay = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
@ -49,8 +50,12 @@ export function useDockerRegistry() {
await delay(3000);
}
if (isExited && dockerProcess.exitCode !== 0) {
throw new Error(`Unable to setup docker registry exit code ${dockerProcess.exitCode}`);
}
dockerProcess.kill();
throw new Error('Unable to setup docker registry');
throw new pRetry.AbortError('Unable to setup docker registry after timeout');
}
async function cleanupDockerRegistryServer() {
@ -60,8 +65,11 @@ export function useDockerRegistry() {
}
beforeAll(async () => {
jest.setTimeout(5 * 60 * 1000); // 5 minutes timeout
await startDockerRegistryServer();
const testTimeout = 5 * 60 * 1000; // 5 minutes timeout
jest.setTimeout(testTimeout);
await pRetry(() => startDockerRegistryServer(), {
retries: 3,
});
});
afterAll(async () => {