diff --git a/e2e/helpers/config.js b/e2e/helpers/config.js index e5862d52c..8e5bda96c 100644 --- a/e2e/helpers/config.js +++ b/e2e/helpers/config.js @@ -1,3 +1,3 @@ -export default { +module.exports = { url: 'http://localhost:5000' }; diff --git a/gulpfile.js b/gulpfile.js index fa38d5bea..b696431c0 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -4,6 +4,8 @@ const exec = require('child_process').exec; const PluginError = require('plugin-error'); const argv = require('minimist')(process.argv.slice(2)); const log = require('fancy-log'); +const request = require('request'); +const e2eConfig = require('./e2e/helpers/config.js'); // Configuration @@ -188,7 +190,31 @@ function e2eOnly() { } e2eOnly.description = `Runs the e2e tests only`; -e2e = gulp.series(docker, e2eOnly); +async function backendStatus() { + const milliseconds = 250; + return new Promise(resolve => { + let timer; + let attempts = 1; + timer = setInterval(() => { + const url = `${e2eConfig.url}/api/Applications/status`; + request.get(url, (err, res) => { + if (res.body == 'true') { + clearInterval(timer); + resolve(attempts); + } else + attempts++; + }); + }, milliseconds); + }); +} +backendStatus.description = `Performs a simple requests to check the backend status`; + +e2e = gulp.series(docker, async function isBackendReady() { + const attempts = await backendStatus(); + log(`Backend ready after ${attempts} attempt(s)`); + + return attempts; +}, e2eOnly); e2e.description = `Restarts database and runs the e2e tests`; function smokesOnly() { @@ -533,5 +559,6 @@ module.exports = { watch, docker, dockerStart, - dockerWait + dockerWait, + backendStatus };