diff --git a/gulpfile.js b/gulpfile.js index dcdf51ef2e..a735887b8f 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -66,29 +66,21 @@ gulp.task('services-only', callback => { * Runs the e2e tests, restoring the fixtures first. */ gulp.task('e2e', ['docker'], async() => { - await runSequenceP('e2e-only'); -}); - -/** - * Runs the e2e tests. - */ -gulp.task('e2e-only', () => { const jasmine = require('gulp-jasmine'); if (argv.show || argv.s) process.env.E2E_SHOW = true; - return gulp.src('./e2e_tests.js') + return gulp.src('./e2e/tests.js') .pipe(jasmine({reporter: 'none'})); }); +/** + * Runs the smokes tests, restoring the fixtures first. + */ gulp.task('smokes', ['docker'], async() => { - await runSequenceP('smokes-only'); -}); - -gulp.task('smokes-only', () => { const jasmine = require('gulp-jasmine'); - return gulp.src('./smokes-tests.js') + return gulp.src('./e2e/smokes-tests.js') .pipe(jasmine({reporter: 'none'})); }); @@ -390,26 +382,21 @@ gulp.task('watch', function() { // Docker /** - * Rebuilds the docker, if already exists, destroys and - * rebuild it. + * Rebuilds the docker, if already exists, destroys and rebuild it. + * Also, if the container or it's image doesn't exists builds them. */ gulp.task('docker', async() => { try { await execP('docker rm -fv salix-db'); } catch (e) {} - try { - await execP('docker volume rm data'); - } catch (e) {} - log('Building image...'); - await execP('docker build -t salix-db:latest ./services/db'); - - await runSequenceP('docker-run'); + await execP('docker build -t salix-db ./services/db'); + await execP('docker run -d --name salix-db -p 3306:3306 salix-db'); }); /** * Does the minium effort to start the docker, if it doesn't exists calls - * the 'docker-run' task, if it is started does nothing. Keep in mind that when + * the 'docker' task, if it is started does nothing. Keep in mind that when * you do not rebuild the docker you may be using an outdated version of it. * See the 'docker' task for more info. */ @@ -419,7 +406,7 @@ gulp.task('docker-start', async() => { let result = await execP('docker container inspect -f "{{json .State}}" salix-db'); state = JSON.parse(result.stdout); } catch (err) { - return await runSequenceP('docker-run'); + return await runSequenceP('docker'); } switch (state.Status) { @@ -434,28 +421,15 @@ gulp.task('docker-start', async() => { } }); -/** - * Runs the docker, if the container or it's image doesn't exists builds them. - */ -gulp.task('docker-run', async() => { - try { - await execP('docker image inspect -f "{{json .Id}}" salix-db'); - await execP('docker run -d --name salix-db --volume ./dist/salix-db:/data -p 3306:3306 salix-db'); - await runSequenceP('docker-wait'); - } catch (err) { - await runSequenceP('docker'); - } -}); - /** * Waits until MySQL docker is started and ready to serve connections. */ gulp.task('docker-wait', callback => { const mysql = require('mysql2'); - let interval = 1; + let interval = 100; let elapsedTime = 0; - let maxInterval = 30 * 60; + let maxInterval = 30 * 60 * 1000; log('Waiting for MySQL init process...'); checker(); @@ -487,7 +461,7 @@ gulp.task('docker-wait', callback => { if (elapsedTime >= maxInterval) callback(new Error(`MySQL not initialized whithin ${elapsedTime} secs`)); else - setTimeout(checker, interval * 1000); + setTimeout(checker, interval); }); } });