From 879482a955d5ca55a8ddfbdf1c518dcd0170948b Mon Sep 17 00:00:00 2001 From: Shane Kilkelly Date: Fri, 8 Jul 2016 12:09:01 +0100 Subject: [PATCH] grunt scripts to run the docker acceptance tests --- services/document-updater/Gruntfile.coffee | 36 +++++++++++++++++-- services/document-updater/package.json | 3 +- .../test/acceptance/docker-entrypoint.sh | 3 -- 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/services/document-updater/Gruntfile.coffee b/services/document-updater/Gruntfile.coffee index 3497455a57..e31eb742cf 100644 --- a/services/document-updater/Gruntfile.coffee +++ b/services/document-updater/Gruntfile.coffee @@ -6,7 +6,8 @@ module.exports = (grunt) -> grunt.loadNpmTasks 'grunt-execute' grunt.loadNpmTasks 'grunt-bunyan' grunt.loadNpmTasks 'grunt-forever' - + grunt.loadNpmTasks 'grunt-shell' + grunt.initConfig forever: app: @@ -67,6 +68,21 @@ module.exports = (grunt) -> grep: grunt.option("grep") timeout: 10000 + shell: + fullAcceptanceTests: + command: "bash ./test/acceptance/scripts/full-test.sh" + buildDockerImage: + command: """ + if [ -z $(docker images | awk \'{ print $1 }\' | grep sharelatex-docupdater-tests) ]; + then + docker build . -t sharelatex-docupdater-tests; + else + echo ">> docker image \'sharelatex-docupdater-tests\' already exists"; + fi + """ + dockerTests: + command: 'docker run -v "$(pwd):/document-updater" --rm --name doc-updater-test sharelatex-docupdater-tests' + availabletasks: tasks: options: @@ -111,8 +127,24 @@ module.exports = (grunt) -> grunt.registerTask 'install', "Compile everything when installing as an npm module", ['compile'] grunt.registerTask 'test:unit', 'Run the unit tests (use --grep= for individual tests)', ['compile:server', 'compile:unit_tests', 'mochaTest:unit'] + + grunt.registerTask( + 'test:acceptance:full', + "Start server and run acceptance tests", + ['shell:fullAcceptanceTests'] + ) + grunt.registerTask( + 'test:acceptance:buildDockerImage', + "Build docker image for acceptance tests", + ['shell:buildDockerImage'] + ) + grunt.registerTask( + 'test:acceptance:docker', + "Run acceptance tests inside docker container", + ['shell:buildDockerImage', 'shell:dockerTests'] + ) + grunt.registerTask 'test:acceptance', 'Run the acceptance tests (use --grep= for individual tests)', ['compile:acceptance_tests', 'mochaTest:acceptance'] grunt.registerTask 'run', "Compile and run the document-updater-sharelatex server", ['compile', 'bunyan', 'execute'] grunt.registerTask 'default', 'run' - diff --git a/services/document-updater/package.json b/services/document-updater/package.json index a9d610a4c1..3133881691 100644 --- a/services/document-updater/package.json +++ b/services/document-updater/package.json @@ -34,6 +34,7 @@ "grunt-contrib-coffee": "~0.10.0", "grunt-execute": "~0.1.5", "grunt-forever": "0.4.1", - "grunt-mocha-test": "~0.9.0" + "grunt-mocha-test": "~0.9.0", + "grunt-shell": "^1.3.0" } } diff --git a/services/document-updater/test/acceptance/docker-entrypoint.sh b/services/document-updater/test/acceptance/docker-entrypoint.sh index e42c3cc391..54a12c0468 100644 --- a/services/document-updater/test/acceptance/docker-entrypoint.sh +++ b/services/document-updater/test/acceptance/docker-entrypoint.sh @@ -9,7 +9,4 @@ npm install source ./test/acceptance/scripts/full-test.sh -service redis-server stop -service mongodb stop - exit 0