From 94f6a5dd4a1747580ff99029b2ee49535af14dc6 Mon Sep 17 00:00:00 2001 From: Nicolas Chaulet Date: Tue, 8 Feb 2022 09:14:01 -0500 Subject: [PATCH] [Fleet] Fix docker registry timeout in integration tests (#124889) (cherry picked from commit df6d386d5087a250ac5eec31edddb830c16c4d21) --- .../server/integration_tests/docker_registry_helper.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/fleet/server/integration_tests/docker_registry_helper.ts b/x-pack/plugins/fleet/server/integration_tests/docker_registry_helper.ts index bb34dc3258d05..902be3aa35bcd 100644 --- a/x-pack/plugins/fleet/server/integration_tests/docker_registry_helper.ts +++ b/x-pack/plugins/fleet/server/integration_tests/docker_registry_helper.ts @@ -12,6 +12,8 @@ import fetch from 'node-fetch'; const delay = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms)); +const DOCKER_START_TIMEOUT = 5 * 60 * 1000; // 5 minutes + export function useDockerRegistry() { const packageRegistryPort = process.env.FLEET_PACKAGE_REGISTRY_PORT || '8081'; @@ -32,8 +34,9 @@ export function useDockerRegistry() { isExited = true; }); - let retries = 0; - while (!isExited && retries++ <= 20) { + const startedAt = Date.now(); + + while (!isExited && Date.now() - startedAt <= DOCKER_START_TIMEOUT) { try { const res = await fetch(`http://localhost:${packageRegistryPort}/`); if (res.status === 200) {