diff --git a/services/web/Makefile b/services/web/Makefile index d5ae799d44..e71ce004c2 100644 --- a/services/web/Makefile +++ b/services/web/Makefile @@ -170,6 +170,7 @@ test_frontend_ct_modules: # Acceptance tests # +# Keep in sync with TEST_ACCEPTANCE_MONGO_INIT in Makefile.module TEST_ACCEPTANCE_MONGO_INIT := \ $(DOCKER_COMPOSE) up -d mongo; \ $(DOCKER_COMPOSE) exec -T mongo sh -c ' \ diff --git a/services/web/Makefile.module b/services/web/Makefile.module index 89ca1ddf96..ddc1fd5cf3 100644 --- a/services/web/Makefile.module +++ b/services/web/Makefile.module @@ -27,6 +27,16 @@ DOCKER_COMPOSE_TEST_UNIT := \ export COMPOSE_PROJECT_NAME=unit_test_$(BUILD_DIR_NAME)_$(MODULE_NAME) \ && $(DOCKER_COMPOSE) +# Keep in sync with TEST_ACCEPTANCE_MONGO_INIT in Makefile +TEST_ACCEPTANCE_MONGO_INIT := \ + $(DOCKER_COMPOSE_TEST_ACCEPTANCE) up -d mongo; \ + $(DOCKER_COMPOSE_TEST_ACCEPTANCE) exec -T mongo sh -c ' \ + while ! mongo --eval "db.version()" > /dev/null; do \ + echo "Waiting for Mongo..."; \ + sleep 1; \ + done; \ + mongo --eval "rs.initiate({ _id: \"overleaf\", members: [ { _id: 0, host: \"mongo:27017\" } ] })"' + ifeq (,$(wildcard test/unit)) test_unit: @@ -58,6 +68,7 @@ test_acceptance_server_pro: export BASE_CONFIG = $(CFG_SERVER_PRO) $(ALL_TEST_ACCEPTANCE_VARIANTS): $(MAKE) --no-print-directory clean_test_acceptance + $(TEST_ACCEPTANCE_MONGO_INIT) ${DOCKER_COMPOSE_TEST_ACCEPTANCE} run --rm test_acceptance npm -q run test:acceptance:run_dir -- ${MOCHA_ARGS} $(MODULE_DIR)/test/acceptance/src $(MAKE) --no-print-directory clean_test_acceptance