From 09964cfe9575dbd3cb5cfef366842c61e0d93007 Mon Sep 17 00:00:00 2001 From: Hayden Faulds Date: Mon, 20 Nov 2017 10:36:48 +0000 Subject: [PATCH 1/4] compile acceptance tests --- services/web/Gruntfile.coffee | 2 +- services/web/Jenkinsfile | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/services/web/Gruntfile.coffee b/services/web/Gruntfile.coffee index d4a4929964..04c164c013 100644 --- a/services/web/Gruntfile.coffee +++ b/services/web/Gruntfile.coffee @@ -407,7 +407,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'] diff --git a/services/web/Jenkinsfile b/services/web/Jenkinsfile index 788731efb0..9b3ddad5c8 100644 --- a/services/web/Jenkinsfile +++ b/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,7 +117,7 @@ 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' } } From 5cdddc7d0e2947b1282ee0d31899743a751b5f87 Mon Sep 17 00:00:00 2001 From: Hayden Faulds Date: Tue, 21 Nov 2017 09:01:07 +0000 Subject: [PATCH 2/4] debugging output if acceptance tests fail on CI --- services/web/Gruntfile.coffee | 1 + services/web/Jenkinsfile | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/services/web/Gruntfile.coffee b/services/web/Gruntfile.coffee index 04c164c013..6144dd8fc6 100644 --- a/services/web/Gruntfile.coffee +++ b/services/web/Gruntfile.coffee @@ -39,6 +39,7 @@ module.exports = (grunt) -> app: options: index: "app.js" + logFile: "app.log" watch: coffee: diff --git a/services/web/Jenkinsfile b/services/web/Jenkinsfile index 9b3ddad5c8..c8cdb52c26 100644 --- a/services/web/Jenkinsfile +++ b/services/web/Jenkinsfile @@ -124,7 +124,7 @@ pipeline { 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' + sh 'docker run --rm -v $(pwd):/app --env SHARELATEX_ALLOW_PUBLIC_ACCESS=true sharelatex/acceptance-test-runner || (cat forever/app.log && false)' } } From e54e2c8328c18c218f7f236e5461b3ced2834dff Mon Sep 17 00:00:00 2001 From: Hayden Faulds Date: Tue, 21 Nov 2017 17:04:09 +0000 Subject: [PATCH 3/4] fix acceptance tests --- services/web/Jenkinsfile | 2 +- .../acceptance/coffee/helpers/User.coffee | 2 +- .../web/test/acceptance/scripts/full-test.sh | 40 +++++++++++++------ 3 files changed, 29 insertions(+), 15 deletions(-) diff --git a/services/web/Jenkinsfile b/services/web/Jenkinsfile index c8cdb52c26..6c03319dea 100644 --- a/services/web/Jenkinsfile +++ b/services/web/Jenkinsfile @@ -124,7 +124,7 @@ pipeline { 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 || (cat forever/app.log && false)' + sh 'docker run --rm -v $(pwd):/app --env SHARELATEX_ALLOW_PUBLIC_ACCESS=true fauldsh/sl-acceptance-test-runner:node-6.9 || (cat forever/app.log && false)' } } diff --git a/services/web/test/acceptance/coffee/helpers/User.coffee b/services/web/test/acceptance/coffee/helpers/User.coffee index 3ee7ea52c2..d9f0b1409a 100644 --- a/services/web/test/acceptance/coffee/helpers/User.coffee +++ b/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")) diff --git a/services/web/test/acceptance/scripts/full-test.sh b/services/web/test/acceptance/scripts/full-test.sh index c8ce75dd4b..ca10c32a0a 100755 --- a/services/web/test/acceptance/scripts/full-test.sh +++ b/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 \ No newline at end of file + echo ">> Done" + + exit $_test_exit_code + fi + + sleep 1 + echo -n "." + count=$((count+1)) +done +exit 1 From 19d9aafbbd028589c0d3a0ca12f20c69fc374225 Mon Sep 17 00:00:00 2001 From: Hayden Faulds Date: Wed, 22 Nov 2017 10:15:32 +0000 Subject: [PATCH 4/4] use release of SL acceptance-test-runner rather then fork --- services/web/Jenkinsfile | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/services/web/Jenkinsfile b/services/web/Jenkinsfile index 6c03319dea..33aa807fdd 100644 --- a/services/web/Jenkinsfile +++ b/services/web/Jenkinsfile @@ -123,8 +123,13 @@ pipeline { stage('Acceptance Tests') { steps { - sh 'docker pull sharelatex/acceptance-test-runner' - sh 'docker run --rm -v $(pwd):/app --env SHARELATEX_ALLOW_PUBLIC_ACCESS=true fauldsh/sl-acceptance-test-runner:node-6.9 || (cat forever/app.log && false)' + // 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)' } }