Browse Source

Merge pull request #12814 from overleaf/jpa-modules-rs-init

[web] initialize mongo replicaset for individual modules

GitOrigin-RevId: 9f8934ae58b21a99f466093617449f5e792d39cd
Jakob Ackermann 3 years ago
parent
commit
46fb6f7c83
2 changed files with 12 additions and 0 deletions
  1. 1 0
      services/web/Makefile
  2. 11 0
      services/web/Makefile.module

+ 1 - 0
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 ' \

+ 11 - 0
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