From 4b013a478c32c7f1b3fba74caccf18a0b699cdf1 Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Thu, 26 Sep 2024 17:42:46 +0300 Subject: [PATCH] Tests: Improve docker start time --- test/docker_start.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/test/docker_start.js b/test/docker_start.js index d8ff462..a0e57a0 100644 --- a/test/docker_start.js +++ b/test/docker_start.js @@ -15,11 +15,18 @@ test('starting docker network..', (t) => { exec(`docker-compose -p test -f ${__dirname}/docker-compose-testbed.yaml up -d`, (err, stdout, stderr) => { if (-1 != stderr.indexOf('is up-to-date')) return t.end() ; console.log('docker network started, giving extra time for freeswitch to initialize...'); - setTimeout(() => { + let retries = 30; + const interval = setInterval(() => { exec('docker exec freeswitch fs_cli -x "console loglevel debug"', (err, stdout, stderr) => { - t.end(err) ; + if (err) { + if (--retries > 0) return ; + clearInterval(interval) ; + return t.end(err) ; + } + clearInterval(interval); + t.end() ; }); - }, 18000); + }, 1000); }); });