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

Merge pull request #148 from sharelatex/hof-compile-acceptance-tests

Run acceptance tests on CI
James Allen 9 лет назад
Родитель
Сommit
e35356b4a4

+ 2 - 1
services/web/Gruntfile.coffee

@@ -39,6 +39,7 @@ module.exports = (grunt) ->
 			app:
 				options:
 					index: "app.js"
+					logFile: "app.log"
 
 		watch:
 			coffee:
@@ -407,7 +408,7 @@ module.exports = (grunt) ->
 	grunt.registerTask 'compile:unit_tests', 'Compile the unit tests', ['clean:unit_tests', 'coffee:unit_tests']
 	grunt.registerTask 'compile:acceptance_tests', 'Compile the acceptance tests', ['clean:acceptance_tests', 'coffee:acceptance_tests']
 	grunt.registerTask 'compile:smoke_tests', 'Compile the smoke tests', ['coffee:smoke_tests']
-	grunt.registerTask 'compile:tests', 'Compile all the tests', ['compile:smoke_tests', 'compile:unit_tests']
+	grunt.registerTask 'compile:tests', 'Compile all the tests', ['compile:smoke_tests', 'compile:unit_tests', 'compile:acceptance_tests']
 	grunt.registerTask 'compile', 'Compiles everything need to run web-sharelatex', ['compile:server', 'compile:client', 'compile:css']
 	grunt.registerTask 'quickcompile:coffee', 'Compiles only changed coffee files',['newer:coffee']
 

+ 9 - 4
services/web/Jenkinsfile

@@ -79,7 +79,7 @@ pipeline {
         }
       }
       steps {
-        sh 'node_modules/.bin/grunt compile  --verbose'
+        sh 'node_modules/.bin/grunt compile compile:tests  --verbose'
         // replace the build number placeholder for sentry
         sh 'node_modules/.bin/grunt version'
       }
@@ -117,14 +117,19 @@ pipeline {
         }
       }
       steps {
-        sh 'env NODE_ENV=development ./node_modules/.bin/grunt test:unit --reporter=tap'
+        sh 'env NODE_ENV=development ./node_modules/.bin/grunt mochaTest:unit --reporter=tap'
       }
     }
     
     stage('Acceptance Tests') {
       steps {
-        sh 'docker pull sharelatex/acceptance-test-runner'
-        sh 'docker run --rm -v $(pwd):/app --env SHARELATEX_ALLOW_PUBLIC_ACCESS=true sharelatex/acceptance-test-runner'
+        // This tagged relase of the acceptance test runner is a temporary fix
+        // to get the acceptance tests working before we move to a
+        // docker-compose workflow. See:
+        // https://github.com/sharelatex/web-sharelatex-internal/pull/148
+
+        sh 'docker pull sharelatex/sl-acceptance-test-runner:node-6.9-mongo-3.4'
+        sh 'docker run --rm -v $(pwd):/app --env SHARELATEX_ALLOW_PUBLIC_ACCESS=true sharelatex/sl-acceptance-test-runner:node-6.9-mongo-3.4 || (cat forever/app.log && false)'
       }
     }
     

+ 1 - 1
services/web/test/acceptance/coffee/helpers/User.coffee

@@ -163,7 +163,7 @@ class User
 		@request.get {
 			url: "/register"
 		}, (err, response, body) =>
-			return callback(error) if error?
+			return callback(err) if err?
 			csrfMatches = body.match("window.csrfToken = \"(.*?)\";")
 			if !csrfMatches?
 				return callback(new Error("no csrf token found"))

+ 27 - 13
services/web/test/acceptance/scripts/full-test.sh

@@ -1,26 +1,40 @@
 #! /usr/bin/env bash
 
-# If you're running on OS X, you probably need to manually
-# 'rm -r node_modules/bcrypt; npm install bcrypt' inside
-# the docker container, before it will start.
-# npm rebuild bcrypt
+# If you're running on OS X, you probably need to rebuild
+# some dependencies in the docker container, before it will start.
+#
+# npm rebuild --update-binary
 
 echo ">> Starting server..."
 
 grunt --no-color forever:app:start
 
-echo ">> Server started"
+echo ">> Waiting for Server"
 
-sleep 5
+count=1
+max_wait=60
 
-echo ">> Running acceptance tests..."
-grunt --no-color mochaTest:acceptance
-_test_exit_code=$?
+while [ $count -le $max_wait ]
+do
+  if nc -z localhost 3000
+  then
+    echo ">> Server Started"
 
-echo ">> Killing server"
+		echo ">> Running acceptance tests..."
+		grunt --no-color mochaTest:acceptance
+		_test_exit_code=$?
 
-grunt --no-color forever:app:stop
+		echo ">> Killing server"
 
-echo ">> Done"
+		grunt --no-color forever:app:stop
 
-exit $_test_exit_code
+		echo ">> Done"
+
+		exit $_test_exit_code
+  fi
+
+  sleep 1
+  echo -n "."
+  count=$((count+1))
+done
+exit 1