mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
46fb6f7c83
[web] initialize mongo replicaset for individual modules GitOrigin-RevId: 9f8934ae58b21a99f466093617449f5e792d39cd
82 lines
2.7 KiB
Text
82 lines
2.7 KiB
Text
BUILD_DIR_NAME ?= web
|
|
MODULE_NAME := $(notdir $(shell pwd))
|
|
MODULE_DIR := modules/$(MODULE_NAME)
|
|
PROJECT_NAME = web
|
|
|
|
export SHARELATEX_CONFIG = /overleaf/services/web/$(MODULE_DIR)/test/acceptance/config/settings.test.js
|
|
export BASE_CONFIG ?= /overleaf/services/web/test/acceptance/config/settings.test.saas.js
|
|
|
|
CFG_SAAS=/overleaf/services/web/test/acceptance/config/settings.test.saas.js
|
|
CFG_SERVER_CE=/overleaf/services/web/test/acceptance/config/settings.test.server-ce.js
|
|
CFG_SERVER_PRO=/overleaf/services/web/test/acceptance/config/settings.test.server-pro.js
|
|
|
|
DOCKER_COMPOSE_FLAGS ?= -f docker-compose.yml
|
|
DOCKER_COMPOSE := cd ../../ && \
|
|
MODULE_DIR=$(MODULE_DIR) \
|
|
BUILD_NUMBER=$(BUILD_NUMBER) \
|
|
BRANCH_NAME=$(BRANCH_NAME) \
|
|
PROJECT_NAME=$(PROJECT_NAME) \
|
|
MOCHA_GREP=${MOCHA_GREP} \
|
|
docker-compose ${DOCKER_COMPOSE_FLAGS}
|
|
|
|
DOCKER_COMPOSE_TEST_ACCEPTANCE := \
|
|
export COMPOSE_PROJECT_NAME=acceptance_test_$(BUILD_DIR_NAME)_$(MODULE_NAME) \
|
|
&& $(DOCKER_COMPOSE)
|
|
|
|
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:
|
|
|
|
else
|
|
test_unit:
|
|
${DOCKER_COMPOSE_TEST_UNIT} run --rm test_unit npm -q run test:unit:run_dir -- ${MOCHA_ARGS} $(MODULE_DIR)/test/unit/src
|
|
${DOCKER_COMPOSE_TEST_UNIT} down
|
|
|
|
endif
|
|
|
|
ALL_TEST_ACCEPTANCE_VARIANTS := \
|
|
test_acceptance \
|
|
test_acceptance_saas \
|
|
test_acceptance_server_ce \
|
|
test_acceptance_server_pro \
|
|
|
|
ifeq (,$(wildcard test/acceptance))
|
|
$(ALL_TEST_ACCEPTANCE_VARIANTS) test_acceptance_merged_inner:
|
|
@echo
|
|
@echo Module $(MODULE_NAME) does not have acceptance tests.
|
|
@echo
|
|
|
|
clean_test_acceptance:
|
|
|
|
else
|
|
test_acceptance_saas: export BASE_CONFIG = $(CFG_SAAS)
|
|
test_acceptance_server_ce: export BASE_CONFIG = $(CFG_SERVER_CE)
|
|
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
|
|
|
|
test_acceptance_merged_inner:
|
|
cd ../../ && \
|
|
npm -q run test:acceptance:run_dir -- ${MOCHA_ARGS} $(MODULE_DIR)/test/acceptance/src
|
|
|
|
clean_test_acceptance:
|
|
${DOCKER_COMPOSE_TEST_ACCEPTANCE} down -v -t 0
|
|
|
|
endif
|