Merge pull request #1249 from sharelatex/ja-single-process-acceptance-tests-2

Move to running acceptance tests in same process as web server

GitOrigin-RevId: 65757f0b57ac621cafb0066b5c5a7abb30333edd
This commit is contained in:
James Allen 2018-12-13 09:07:55 +00:00 committed by sharelatex
parent d0744d779e
commit 65c1943c63
7 changed files with 32 additions and 55 deletions

View file

@ -209,40 +209,26 @@ test_frontend: test_clean # stop service
$(MAKE) compile
docker-compose ${DOCKER_COMPOSE_FLAGS} up --exit-code-from test_frontend --abort-on-container-exit test_frontend
test_acceptance: test_acceptance_app test_acceptance_modules
test_acceptance: compile test_acceptance_app_run test_acceptance_modules_run
test_acceptance_app:
test_acceptance_app: compile test_acceptance_app_run
test_acceptance_module: compile test_acceptance_module_run
test_acceptance_app_run: test_clean
@set -e; \
$(MAKE) test_acceptance_app_start_service; \
$(MAKE) test_acceptance_app_run; \
$(MAKE) test_acceptance_app_stop_service;
docker-compose ${DOCKER_COMPOSE_FLAGS} run --rm test_acceptance npm -q run test:acceptance:run_dir -- ${MOCHA_ARGS} test/acceptance/js
test_acceptance_app_start_service: test_clean # stop service and clear dbs
$(MAKE) compile
docker-compose ${DOCKER_COMPOSE_FLAGS} up -d test_acceptance
test_acceptance_app_stop_service:
docker-compose ${DOCKER_COMPOSE_FLAGS} stop -t 0 test_acceptance redis mongo
test_acceptance_app_run:
@docker-compose ${DOCKER_COMPOSE_FLAGS} exec -T test_acceptance npm -q run test:acceptance -- ${MOCHA_ARGS}; \
result=$$?; \
if [ $$result -eq 137 ]; then \
docker-compose logs --tail=50 test_acceptance; \
echo "\nOh dear, it looks like the web process crashed! Some logs are above, but to see them all, run:\n\n\tdocker-compose logs test_acceptance\n"; \
fi; \
exit $$result
test_acceptance_modules:
test_acceptance_modules_run:
@set -e; \
for dir in $(MODULE_DIRS); \
do \
if [ -e $$dir/test/acceptance ]; then \
$(MAKE) test_acceptance_module MODULE=$$dir; \
$(MAKE) test_acceptance_module_run MODULE=$$dir; \
fi; \
done
test_acceptance_module: $(MODULE_MAKEFILES)
test_acceptance_module_run: $(MODULE_MAKEFILES) test_clean
@if [ -e $(MODULE)/test/acceptance ]; then \
cd $(MODULE) && $(MAKE) test_acceptance; \
fi

View file

@ -59,14 +59,5 @@ compile_full:
if [ -e test/unit_frontend/src/ide ]; then $(BABEL) test/unit_frontend/src/ide --out-dir ../../test/unit_frontend/js/ide/$(MODULE_NAME); fi
@$(MAKE) compile
test_acceptance: test_acceptance_start_service test_acceptance_run
$(MAKE) test_acceptance_stop_service
test_acceptance_start_service: test_acceptance_stop_service
$(DOCKER_COMPOSE) up -d test_acceptance
test_acceptance_stop_service:
$(DOCKER_COMPOSE) stop -t 0 test_acceptance redis mongo
test_acceptance_run:
$(DOCKER_COMPOSE) exec -T test_acceptance npm -q run test:acceptance:dir -- ${MOCHA_ARGS} $(MODULE_DIR)/test/acceptance/js
test_acceptance:
${DOCKER_COMPOSE} run --rm test_acceptance npm -q run test:acceptance:run_dir -- ${MOCHA_ARGS} $(MODULE_DIR)/test/acceptance/js

View file

@ -26,6 +26,7 @@ if Settings.catchErrors
port = Settings.port or Settings.internal?.web?.port or 3000
host = Settings.internal.web.host or "localhost"
if !module.parent # Called directly
Server.server.listen port, host, ->
logger.info "web starting up, listening on #{host}:#{port}"
logger.info("#{require('http').globalAgent.maxSockets} sockets enabled")
@ -35,3 +36,5 @@ Server.server.listen port, host, ->
if argv.group
process.setgid argv.group
logger.info "Running as group: #{argv.group}"
module.exports = Server.server

View file

@ -1,4 +0,0 @@
#!/bin/bash
set -e;
MOCHA="node_modules/.bin/mocha --exit --recursive --reporter spec --timeout 15000"
$MOCHA "$@"

View file

@ -7,8 +7,7 @@ services:
test_acceptance:
image: node:6.9.5
volumes:
- .:/app:ro
- data:/app/data:rw
- .:/app
working_dir: /app
environment:
REDIS_HOST: redis
@ -23,7 +22,7 @@ services:
depends_on:
- redis
- mongo
command: node app.js
command: npm run test:acceptance:app
test_frontend:
build:

View file

@ -10,10 +10,7 @@
"public": "./public"
},
"scripts": {
"test:acceptance:wait_for_app": "echo 'Waiting for app to be accessible' && while (! curl -s -o /dev/null localhost:3000/status) do sleep 1; done",
"test:acceptance:run": "bin/acceptance_test $@",
"test:acceptance:dir": "npm -q run test:acceptance:wait_for_app && npm -q run test:acceptance:run -- $@",
"test:acceptance": "npm -q run test:acceptance:dir -- $@ test/acceptance/js",
"test:acceptance:run_dir": "mocha --recursive --reporter spec --timeout 15000 --exit $@",
"test:unit": "npm -q run compile && bin/unit_test $@",
"test:unit:app": "npm -q run compile && bin/unit_test_app $@",
"test:frontend": "karma start",

View file

@ -0,0 +1,5 @@
App = require '../../../app.js'
require("logger-sharelatex").logger.level("error")
before (done) ->
App.listen 3000, 'localhost', done