From 051bf70fe846aa5b4771374cf2fab87736673374 Mon Sep 17 00:00:00 2001 From: Jakob Ackermann Date: Wed, 26 Apr 2023 13:11:55 +0100 Subject: [PATCH] Merge pull request #12814 from overleaf/jpa-modules-rs-init [web] initialize mongo replicaset for individual modules GitOrigin-RevId: 9f8934ae58b21a99f466093617449f5e792d39cd --- services/web/Makefile | 1 + services/web/Makefile.module | 11 +++++++++++ 2 files changed, 12 insertions(+) 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