mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #24 from sharelatex/ja-dockerize-acceptance-tests
Set up acceptance tests to run in docker container; Fixes overleaf/sharelatex#138
This commit is contained in:
commit
63097aaf73
7 changed files with 103 additions and 3 deletions
|
@ -20,6 +20,8 @@ module.exports = (grunt) ->
|
|||
grunt.loadNpmTasks 'grunt-parallel'
|
||||
grunt.loadNpmTasks 'grunt-exec'
|
||||
grunt.loadNpmTasks 'grunt-postcss'
|
||||
grunt.loadNpmTasks 'grunt-forever'
|
||||
grunt.loadNpmTasks 'grunt-shell'
|
||||
# grunt.loadNpmTasks 'grunt-contrib-imagemin'
|
||||
# grunt.loadNpmTasks 'grunt-sprity'
|
||||
|
||||
|
@ -31,6 +33,10 @@ module.exports = (grunt) ->
|
|||
cssmin:
|
||||
command:"node_modules/clean-css/bin/cleancss --s0 -o public/stylesheets/style.css public/stylesheets/style.css"
|
||||
|
||||
forever:
|
||||
app:
|
||||
options:
|
||||
index: "app.js"
|
||||
|
||||
watch:
|
||||
coffee:
|
||||
|
@ -244,8 +250,11 @@ module.exports = (grunt) ->
|
|||
pattern: "@@RELEASE@@"
|
||||
replacement: process.env.BUILD_NUMBER || "(unknown build)"
|
||||
|
||||
|
||||
|
||||
shell:
|
||||
fullAcceptanceTests:
|
||||
command: "bash ./test/acceptance/scripts/full-test.sh"
|
||||
dockerTests:
|
||||
command: 'docker run -v "$(pwd):/app" --env SHARELATEX_ALLOW_PUBLIC_ACCESS=true --rm sharelatex/acceptance-test-runner'
|
||||
|
||||
availabletasks:
|
||||
tasks:
|
||||
|
@ -396,6 +405,18 @@ module.exports = (grunt) ->
|
|||
grunt.registerTask 'test:acceptance', 'Run the acceptance tests (use --grep=<regex> or --feature=<feature> for individual tests)', ['compile:acceptance_tests', 'mochaTest:acceptance']
|
||||
grunt.registerTask 'test:smoke', 'Run the smoke tests', ['compile:smoke_tests', 'mochaTest:smoke']
|
||||
|
||||
grunt.registerTask(
|
||||
'test:acceptance:full',
|
||||
"Start server and run acceptance tests",
|
||||
['shell:fullAcceptanceTests']
|
||||
)
|
||||
|
||||
grunt.registerTask(
|
||||
'test:acceptance:docker',
|
||||
"Run acceptance tests inside docker container",
|
||||
['compile:acceptance_tests', 'shell:dockerTests']
|
||||
)
|
||||
|
||||
grunt.registerTask 'test:modules:unit', 'Run the unit tests for the modules', ['compile:modules:server', 'compile:modules:unit_tests'].concat(moduleUnitTestTasks)
|
||||
|
||||
grunt.registerTask 'run:watch', "Compile and run the web-sharelatex server", ['compile', 'env:run', 'parallel']
|
||||
|
|
7
services/web/Jenkinsfile
vendored
7
services/web/Jenkinsfile
vendored
|
@ -113,6 +113,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 sharelatex/acceptance-test-runner'
|
||||
}
|
||||
}
|
||||
|
||||
stage('Package') {
|
||||
steps {
|
||||
sh 'rm -rf ./node_modules/grunt*'
|
||||
|
|
|
@ -75,9 +75,9 @@
|
|||
"bunyan": "0.22.1",
|
||||
"chai": "3.5.0",
|
||||
"chai-spies": "",
|
||||
"grunt": "0.4.5",
|
||||
"clean-css": "^3.4.18",
|
||||
"es6-promise": "^4.0.5",
|
||||
"grunt": "0.4.5",
|
||||
"grunt-available-tasks": "0.4.1",
|
||||
"grunt-bunyan": "0.5.0",
|
||||
"grunt-contrib-clean": "0.5.0",
|
||||
|
@ -89,12 +89,14 @@
|
|||
"grunt-exec": "^0.4.7",
|
||||
"grunt-execute": "^0.2.2",
|
||||
"grunt-file-append": "0.0.6",
|
||||
"grunt-forever": "^0.4.7",
|
||||
"grunt-git-rev-parse": "^0.1.4",
|
||||
"grunt-mocha-test": "0.9.0",
|
||||
"grunt-newer": "^1.2.0",
|
||||
"grunt-parallel": "^0.5.1",
|
||||
"grunt-postcss": "^0.8.0",
|
||||
"grunt-sed": "^0.1.1",
|
||||
"grunt-shell": "^2.1.0",
|
||||
"sandboxed-module": "0.2.0",
|
||||
"sinon": "^1.17.0",
|
||||
"timekeeper": "",
|
||||
|
|
|
@ -4,6 +4,9 @@ User = require "./helpers/User"
|
|||
request = require "./helpers/request"
|
||||
settings = require "settings-sharelatex"
|
||||
|
||||
MockDocstoreApi = require './helpers/MockDocstoreApi'
|
||||
MockDocUpdaterApi = require './helpers/MockDocUpdaterApi'
|
||||
|
||||
try_read_access = (user, project_id, test, callback) ->
|
||||
async.series [
|
||||
(cb) ->
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
express = require("express")
|
||||
app = express()
|
||||
|
||||
module.exports = MockDocUpdaterApi =
|
||||
run: () ->
|
||||
app.post "/project/:project_id/flush", (req, res, next) =>
|
||||
res.sendStatus 200
|
||||
|
||||
app.listen 3003, (error) ->
|
||||
throw error if error?
|
||||
|
||||
MockDocUpdaterApi.run()
|
|
@ -0,0 +1,29 @@
|
|||
express = require("express")
|
||||
bodyParser = require "body-parser"
|
||||
app = express()
|
||||
|
||||
module.exports = MockDocStoreApi =
|
||||
docs: {}
|
||||
|
||||
run: () ->
|
||||
app.post "/project/:project_id/doc/:doc_id", bodyParser.json(), (req, res, next) =>
|
||||
{project_id, doc_id} = req.params
|
||||
{lines, version, ranges} = req.body
|
||||
@docs[project_id] ?= {}
|
||||
@docs[project_id][doc_id] = {lines, version, ranges}
|
||||
@docs[project_id][doc_id].rev ?= 0
|
||||
@docs[project_id][doc_id].rev += 1
|
||||
res.json {
|
||||
modified: true
|
||||
rev: @docs[project_id][doc_id].rev
|
||||
}
|
||||
|
||||
app.get "/project/:project_id/doc", (req, res, next) =>
|
||||
docs = (doc for doc_id, doc of @docs[req.params.project_id])
|
||||
res.send JSON.stringify docs
|
||||
|
||||
app.listen 3016, (error) ->
|
||||
throw error if error?
|
||||
|
||||
MockDocUpdaterApi.run()
|
||||
|
26
services/web/test/acceptance/scripts/full-test.sh
Executable file
26
services/web/test/acceptance/scripts/full-test.sh
Executable file
|
@ -0,0 +1,26 @@
|
|||
#! /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
|
||||
|
||||
echo ">> Starting server..."
|
||||
|
||||
grunt --no-color forever:app:start
|
||||
|
||||
echo ">> Server started"
|
||||
|
||||
sleep 5
|
||||
|
||||
echo ">> Running acceptance tests..."
|
||||
grunt --no-color mochaTest:acceptance
|
||||
_test_exit_code=$?
|
||||
|
||||
echo ">> Killing server"
|
||||
|
||||
grunt --no-color forever:app:stop
|
||||
|
||||
echo ">> Done"
|
||||
|
||||
exit $_test_exit_code
|
Loading…
Reference in a new issue