Skip to content

Commit

Permalink
[Fleet] Fix docker registry timeout in integration tests (#124889) (#…
Browse files Browse the repository at this point in the history
…124959)

(cherry picked from commit df6d386)

Co-authored-by: Nicolas Chaulet <[email protected]>
  • Loading branch information
kibanamachine and nchaulet authored Feb 8, 2022
1 parent 4fb5419 commit 94913ac
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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) {
Expand Down

0 comments on commit 94913ac

Please sign in to comment.