Просмотр исходного кода

grunt scripts to run the docker acceptance tests

Shane Kilkelly 10 лет назад
Родитель
Сommit
879482a955

+ 34 - 2
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=<regex> 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=<regex> 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'
-

+ 2 - 1
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"
   }
 }

+ 0 - 3
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