From cd5a54eaed24a312e3f619f4d5de2dbb1cf5d4ac Mon Sep 17 00:00:00 2001 From: Jib Date: Thu, 16 Jan 2025 11:55:09 -0500 Subject: [PATCH 01/22] Add 8.0 and Auth + SSL Testing Adding tests: * MongoDB SERVER Version 8.0 * Auth SSL This creates 4 test variants total: * 5.0 -- NoAuth NoSSL * 5.0 -- Auth SSL * 8.0 -- NoAuth NoSSL * 8.0 -- Auth SSL --- .evergreen/config.yml | 48 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 41 insertions(+), 7 deletions(-) diff --git a/.evergreen/config.yml b/.evergreen/config.yml index 6490b069f..2d6f602c2 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -31,11 +31,6 @@ functions: - command: subprocess.exec params: binary: bash - env: - MONGODB_VERSION: "5.0" - TOPOLOGY: server - AUTH: "noauth" - SSL: "nossl" args: - ${DRIVERS_TOOLS}/.evergreen/run-orchestration.sh @@ -69,8 +64,47 @@ tasks: - func: "run unit tests" buildvariants: -- name: tests - display_name: Run Tests +- name: tests-5-noauth-nossl + display_name: Run Tests 5.0 NoAuth NoSSL run_on: rhel87-small + expansions: + MONGODB_VERSION: "5.0" + TOPOLOGY: server + AUTH: "noauth" + SSL: "nossl" tasks: - name: run-tests + +- name: tests-5-auth-ssl + display_name: Run Tests 5.0 Auth SSL + run_on: rhel87-small + expansions: + MONGODB_VERSION: "5.0" + TOPOLOGY: server + AUTH: "auth" + SSL: "ssl" + tasks: + - name: run-tests + +- name: tests-8-noauth-nossl + display_name: Run Tests 8.0 NoAuth NoSSL + run_on: rhel87-small + expansions: + MONGODB_VERSION: "8.0" + TOPOLOGY: server + AUTH: "noauth" + SSL: "nossl" + tasks: + - name: run-tests + +- name: tests-8-noauth-nossl + display_name: Run Tests 8.0 Auth SSL + run_on: rhel87-small + expansions: + MONGODB_VERSION: "8.0" + TOPOLOGY: server + AUTH: "auth" + SSL: "ssl" + tasks: + - name: run-tests + From ac7962b82a6fa420a00318ee0eb1d3763ba68f06 Mon Sep 17 00:00:00 2001 From: Jib Date: Thu, 16 Jan 2025 11:57:40 -0500 Subject: [PATCH 02/22] Remove EOF --- .evergreen/config.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.evergreen/config.yml b/.evergreen/config.yml index 2d6f602c2..1f4f9fa38 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -107,4 +107,3 @@ buildvariants: SSL: "ssl" tasks: - name: run-tests - From 3d2e4de6104af7bcce07c7a4253f4540e9069cb7 Mon Sep 17 00:00:00 2001 From: Jib Date: Thu, 16 Jan 2025 14:28:43 -0500 Subject: [PATCH 03/22] Update .evergreen/config.yml --- .evergreen/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.evergreen/config.yml b/.evergreen/config.yml index 1f4f9fa38..4b951aa6e 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -97,7 +97,7 @@ buildvariants: tasks: - name: run-tests -- name: tests-8-noauth-nossl +- name: tests-8-auth-ssl display_name: Run Tests 8.0 Auth SSL run_on: rhel87-small expansions: From 1ca8d1971e3162f23a4e4bf122bceb5f97ff2ce4 Mon Sep 17 00:00:00 2001 From: Jib Date: Fri, 17 Jan 2025 08:59:01 -0500 Subject: [PATCH 04/22] Update config.yml --- .evergreen/config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.evergreen/config.yml b/.evergreen/config.yml index 4b951aa6e..de1a2c72a 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -31,6 +31,7 @@ functions: - command: subprocess.exec params: binary: bash + add_expansions_to_env: true args: - ${DRIVERS_TOOLS}/.evergreen/run-orchestration.sh From 072a2e8bab5bc4eb9607c23ab81068df3ce922bd Mon Sep 17 00:00:00 2001 From: Jib Date: Fri, 17 Jan 2025 09:49:20 -0500 Subject: [PATCH 05/22] Update config.yml --- .evergreen/config.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.evergreen/config.yml b/.evergreen/config.yml index de1a2c72a..edef61edc 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -34,6 +34,10 @@ functions: add_expansions_to_env: true args: - ${DRIVERS_TOOLS}/.evergreen/run-orchestration.sh + - command: expansions.update + params: + file: ${DRIVERS_TOOLS}/expansion.yml + "run unit tests": - command: subprocess.exec @@ -41,7 +45,7 @@ functions: params: binary: bash working_dir: "src" - include_expansions_in_env: ["DRIVERS_TOOLS"] + include_expansions_in_env: ["DRIVERS_TOOLS", "MONGODB_URI"] args: - ./.evergreen/run-tests.sh From 4b0ee2d92354a0a215b462c877ec9137f08ab755 Mon Sep 17 00:00:00 2001 From: Jib Date: Fri, 17 Jan 2025 10:06:53 -0500 Subject: [PATCH 06/22] fetch MongoDB URI and use within settings.py --- .github/workflows/mongodb_settings.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/mongodb_settings.py b/.github/workflows/mongodb_settings.py index dc543a1e9..ea7079eac 100644 --- a/.github/workflows/mongodb_settings.py +++ b/.github/workflows/mongodb_settings.py @@ -1,9 +1,18 @@ +import os + +from django_mongodb_backend import parse_uri + +PARSED_URI = parse_uri(os.getenv("MONGODB_URI")) if os.getenv("MONGODB_URI") else {} + + DATABASES = { "default": { + **PARSED_URI, "ENGINE": "django_mongodb_backend", "NAME": "djangotests", }, "other": { + **PARSED_URI, "ENGINE": "django_mongodb_backend", "NAME": "djangotests-other", }, From 81a0035468612cdcb47ccbf1504fd53c61b7631c Mon Sep 17 00:00:00 2001 From: Jib Date: Fri, 17 Jan 2025 10:14:13 -0500 Subject: [PATCH 07/22] Update config.yml --- .evergreen/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.evergreen/config.yml b/.evergreen/config.yml index edef61edc..12e9f6df2 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -36,7 +36,7 @@ functions: - ${DRIVERS_TOOLS}/.evergreen/run-orchestration.sh - command: expansions.update params: - file: ${DRIVERS_TOOLS}/expansion.yml + file: ${DRIVERS_TOOLS}/mo-expansion.yml "run unit tests": From 55d431b40e564d2c4993b37c78bb3233c7062d84 Mon Sep 17 00:00:00 2001 From: Jib Date: Fri, 17 Jan 2025 10:24:56 -0500 Subject: [PATCH 08/22] route to .evergreen/mo-expansion.yml --- .evergreen/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.evergreen/config.yml b/.evergreen/config.yml index 12e9f6df2..03435ee72 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -36,7 +36,7 @@ functions: - ${DRIVERS_TOOLS}/.evergreen/run-orchestration.sh - command: expansions.update params: - file: ${DRIVERS_TOOLS}/mo-expansion.yml + file: ${DRIVERS_TOOLS}/.evergreen/mo-expansion.yml "run unit tests": From c59a6f8861a7e57ad6122bab8e29716ffeb405af Mon Sep 17 00:00:00 2001 From: Jib Date: Fri, 17 Jan 2025 12:19:55 -0500 Subject: [PATCH 09/22] Update config.yml --- .evergreen/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.evergreen/config.yml b/.evergreen/config.yml index 03435ee72..bcf59fea4 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -36,7 +36,7 @@ functions: - ${DRIVERS_TOOLS}/.evergreen/run-orchestration.sh - command: expansions.update params: - file: ${DRIVERS_TOOLS}/.evergreen/mo-expansion.yml + file: ${DRIVERS_TOOLS}/.evergreen/orchestration/mo-expansion.yml "run unit tests": From 199e734c0067370498ab36280365c11e8b1e3a47 Mon Sep 17 00:00:00 2001 From: Jib Date: Wed, 22 Jan 2025 15:26:23 -0500 Subject: [PATCH 10/22] debug check via tree . --- .evergreen/config.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.evergreen/config.yml b/.evergreen/config.yml index bcf59fea4..ae265b581 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -34,6 +34,11 @@ functions: add_expansions_to_env: true args: - ${DRIVERS_TOOLS}/.evergreen/run-orchestration.sh + - command: shell.exec + params: + binary: bash + run: | + tree ${DRIVERS_TOOLS}/ - command: expansions.update params: file: ${DRIVERS_TOOLS}/.evergreen/orchestration/mo-expansion.yml From 6abadff7c868f77c95d717984cd419433f20c2f7 Mon Sep 17 00:00:00 2001 From: Jib Date: Wed, 22 Jan 2025 15:36:18 -0500 Subject: [PATCH 11/22] tree check --- .evergreen/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.evergreen/config.yml b/.evergreen/config.yml index ae265b581..f7203c03e 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -37,7 +37,7 @@ functions: - command: shell.exec params: binary: bash - run: | + script: | tree ${DRIVERS_TOOLS}/ - command: expansions.update params: From f83de5d13dee7a83db06413cd470d4cba14c11ee Mon Sep 17 00:00:00 2001 From: Jib Date: Wed, 22 Jan 2025 15:41:44 -0500 Subject: [PATCH 12/22] more workaround debugging --- .evergreen/config.yml | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/.evergreen/config.yml b/.evergreen/config.yml index f7203c03e..9a893ba8f 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -38,7 +38,22 @@ functions: params: binary: bash script: | - tree ${DRIVERS_TOOLS}/ + ls -l ${DRIVERS_TOOLS}/ + - command: shell.exec + params: + binary: bash + script: | + ls -l ${DRIVERS_TOOLS}/.evergreen/ + - command: shell.exec + params: + binary: bash + script: | + ls -l ${DRIVERS_TOOLS}/.evergreen/orchestration/ + - command: shell.exec + params: + binary: bash + script: | + ls -l .evergreen/ - command: expansions.update params: file: ${DRIVERS_TOOLS}/.evergreen/orchestration/mo-expansion.yml From d07443efad37d07a29f3ad4eac6f0bc42bc3b3c7 Mon Sep 17 00:00:00 2001 From: Jib Date: Wed, 22 Jan 2025 15:48:45 -0500 Subject: [PATCH 13/22] use find --- .evergreen/config.yml | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/.evergreen/config.yml b/.evergreen/config.yml index 9a893ba8f..cf626e913 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -38,22 +38,12 @@ functions: params: binary: bash script: | - ls -l ${DRIVERS_TOOLS}/ + find ${DRIVERS_TOOLS} - command: shell.exec params: binary: bash script: | - ls -l ${DRIVERS_TOOLS}/.evergreen/ - - command: shell.exec - params: - binary: bash - script: | - ls -l ${DRIVERS_TOOLS}/.evergreen/orchestration/ - - command: shell.exec - params: - binary: bash - script: | - ls -l .evergreen/ + find . - command: expansions.update params: file: ${DRIVERS_TOOLS}/.evergreen/orchestration/mo-expansion.yml From b1addb9427f7e1fa0a04fa7d1ad7f1176e56f446 Mon Sep 17 00:00:00 2001 From: Jib Date: Wed, 22 Jan 2025 15:53:38 -0500 Subject: [PATCH 14/22] route to mo-expansion.yml --- .evergreen/config.yml | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/.evergreen/config.yml b/.evergreen/config.yml index cf626e913..3f90e31a0 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -34,19 +34,9 @@ functions: add_expansions_to_env: true args: - ${DRIVERS_TOOLS}/.evergreen/run-orchestration.sh - - command: shell.exec - params: - binary: bash - script: | - find ${DRIVERS_TOOLS} - - command: shell.exec - params: - binary: bash - script: | - find . - command: expansions.update params: - file: ${DRIVERS_TOOLS}/.evergreen/orchestration/mo-expansion.yml + file: mo-expansion.yml "run unit tests": From af672fc9550159d1c5f1fc2dcc3e5601299102a4 Mon Sep 17 00:00:00 2001 From: Jib Date: Wed, 22 Jan 2025 16:04:39 -0500 Subject: [PATCH 15/22] ensure environment variable is referenced --- .evergreen/config.yml | 92 ++++++++++++++------------- .github/workflows/mongodb_settings.py | 3 + 2 files changed, 51 insertions(+), 44 deletions(-) diff --git a/.evergreen/config.yml b/.evergreen/config.yml index 3f90e31a0..dcf423b6e 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -34,11 +34,15 @@ functions: add_expansions_to_env: true args: - ${DRIVERS_TOOLS}/.evergreen/run-orchestration.sh + - command: shell.exec + params: + binary: bash + script: | + cat mo-expansion.yml - command: expansions.update params: file: mo-expansion.yml - "run unit tests": - command: subprocess.exec type: test @@ -64,51 +68,51 @@ post: - func: teardown tasks: -- name: run-tests - commands: - - func: "run unit tests" + - name: run-tests + commands: + - func: "run unit tests" buildvariants: -- name: tests-5-noauth-nossl - display_name: Run Tests 5.0 NoAuth NoSSL - run_on: rhel87-small - expansions: - MONGODB_VERSION: "5.0" - TOPOLOGY: server - AUTH: "noauth" - SSL: "nossl" - tasks: - - name: run-tests + - name: tests-5-noauth-nossl + display_name: Run Tests 5.0 NoAuth NoSSL + run_on: rhel87-small + expansions: + MONGODB_VERSION: "5.0" + TOPOLOGY: server + AUTH: "noauth" + SSL: "nossl" + tasks: + - name: run-tests -- name: tests-5-auth-ssl - display_name: Run Tests 5.0 Auth SSL - run_on: rhel87-small - expansions: - MONGODB_VERSION: "5.0" - TOPOLOGY: server - AUTH: "auth" - SSL: "ssl" - tasks: - - name: run-tests + - name: tests-5-auth-ssl + display_name: Run Tests 5.0 Auth SSL + run_on: rhel87-small + expansions: + MONGODB_VERSION: "5.0" + TOPOLOGY: server + AUTH: "auth" + SSL: "ssl" + tasks: + - name: run-tests -- name: tests-8-noauth-nossl - display_name: Run Tests 8.0 NoAuth NoSSL - run_on: rhel87-small - expansions: - MONGODB_VERSION: "8.0" - TOPOLOGY: server - AUTH: "noauth" - SSL: "nossl" - tasks: - - name: run-tests + - name: tests-8-noauth-nossl + display_name: Run Tests 8.0 NoAuth NoSSL + run_on: rhel87-small + expansions: + MONGODB_VERSION: "8.0" + TOPOLOGY: server + AUTH: "noauth" + SSL: "nossl" + tasks: + - name: run-tests -- name: tests-8-auth-ssl - display_name: Run Tests 8.0 Auth SSL - run_on: rhel87-small - expansions: - MONGODB_VERSION: "8.0" - TOPOLOGY: server - AUTH: "auth" - SSL: "ssl" - tasks: - - name: run-tests + - name: tests-8-auth-ssl + display_name: Run Tests 8.0 Auth SSL + run_on: rhel87-small + expansions: + MONGODB_VERSION: "8.0" + TOPOLOGY: server + AUTH: "auth" + SSL: "ssl" + tasks: + - name: run-tests diff --git a/.github/workflows/mongodb_settings.py b/.github/workflows/mongodb_settings.py index ea7079eac..3cb8c07f6 100644 --- a/.github/workflows/mongodb_settings.py +++ b/.github/workflows/mongodb_settings.py @@ -2,8 +2,11 @@ from django_mongodb_backend import parse_uri + PARSED_URI = parse_uri(os.getenv("MONGODB_URI")) if os.getenv("MONGODB_URI") else {} +if not PARSED_URI: + print("MONGODB_URI not found; please check if environment variable set") DATABASES = { "default": { From e62a61acddae39bb65ebe02743d8848945794bec Mon Sep 17 00:00:00 2001 From: Jib Date: Wed, 22 Jan 2025 16:42:41 -0500 Subject: [PATCH 16/22] print localized DB output --- .github/workflows/mongodb_settings.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/mongodb_settings.py b/.github/workflows/mongodb_settings.py index 3cb8c07f6..629a6e46c 100644 --- a/.github/workflows/mongodb_settings.py +++ b/.github/workflows/mongodb_settings.py @@ -5,9 +5,6 @@ PARSED_URI = parse_uri(os.getenv("MONGODB_URI")) if os.getenv("MONGODB_URI") else {} -if not PARSED_URI: - print("MONGODB_URI not found; please check if environment variable set") - DATABASES = { "default": { **PARSED_URI, @@ -20,6 +17,7 @@ "NAME": "djangotests-other", }, } +print(DATABASES) DEFAULT_AUTO_FIELD = "django_mongodb_backend.fields.ObjectIdAutoField" PASSWORD_HASHERS = ("django.contrib.auth.hashers.MD5PasswordHasher",) SECRET_KEY = "django_tests_secret_key" From ec978c5cb2731c2420dccb9393e1c84012e07cb2 Mon Sep 17 00:00:00 2001 From: Jib Date: Thu, 23 Jan 2025 08:03:36 -0500 Subject: [PATCH 17/22] provided tls=true in auth/ssl uri --- .evergreen/config.yml | 5 ----- .github/workflows/mongodb_settings.py | 6 +++++- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.evergreen/config.yml b/.evergreen/config.yml index dcf423b6e..6aa2020ca 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -34,11 +34,6 @@ functions: add_expansions_to_env: true args: - ${DRIVERS_TOOLS}/.evergreen/run-orchestration.sh - - command: shell.exec - params: - binary: bash - script: | - cat mo-expansion.yml - command: expansions.update params: file: mo-expansion.yml diff --git a/.github/workflows/mongodb_settings.py b/.github/workflows/mongodb_settings.py index 629a6e46c..fed3cae1a 100644 --- a/.github/workflows/mongodb_settings.py +++ b/.github/workflows/mongodb_settings.py @@ -5,6 +5,10 @@ PARSED_URI = parse_uri(os.getenv("MONGODB_URI")) if os.getenv("MONGODB_URI") else {} +# Temporary fix for https://github.com/mongodb-labs/mongo-orchestration/issues/268 +if "USER" in PARSED_URI and "PASSWORD" in PARSED_URI: + PARSED_URI["OPTIONS"]["tls"] = True + DATABASES = { "default": { **PARSED_URI, @@ -17,7 +21,7 @@ "NAME": "djangotests-other", }, } -print(DATABASES) + DEFAULT_AUTO_FIELD = "django_mongodb_backend.fields.ObjectIdAutoField" PASSWORD_HASHERS = ("django.contrib.auth.hashers.MD5PasswordHasher",) SECRET_KEY = "django_tests_secret_key" From db872d9f61bb1aabd809b66e95983cda16246d6a Mon Sep 17 00:00:00 2001 From: Jib Date: Thu, 23 Jan 2025 08:10:32 -0500 Subject: [PATCH 18/22] organize ruff imports --- .github/workflows/mongodb_settings.py | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/mongodb_settings.py b/.github/workflows/mongodb_settings.py index fed3cae1a..b9e61557a 100644 --- a/.github/workflows/mongodb_settings.py +++ b/.github/workflows/mongodb_settings.py @@ -2,7 +2,6 @@ from django_mongodb_backend import parse_uri - PARSED_URI = parse_uri(os.getenv("MONGODB_URI")) if os.getenv("MONGODB_URI") else {} # Temporary fix for https://github.com/mongodb-labs/mongo-orchestration/issues/268 From 90b6b244191ff225424b7298de21b1518cb4bbd2 Mon Sep 17 00:00:00 2001 From: Jib Date: Thu, 23 Jan 2025 11:04:18 -0500 Subject: [PATCH 19/22] tlsAllowInvalidCertificates=True --- .github/workflows/mongodb_settings.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/mongodb_settings.py b/.github/workflows/mongodb_settings.py index b9e61557a..caf5d3dbf 100644 --- a/.github/workflows/mongodb_settings.py +++ b/.github/workflows/mongodb_settings.py @@ -5,8 +5,9 @@ PARSED_URI = parse_uri(os.getenv("MONGODB_URI")) if os.getenv("MONGODB_URI") else {} # Temporary fix for https://github.com/mongodb-labs/mongo-orchestration/issues/268 -if "USER" in PARSED_URI and "PASSWORD" in PARSED_URI: +if PARSED_URI["USER"] and PARSED_URI["PASSWORD"]: PARSED_URI["OPTIONS"]["tls"] = True + PARSED_URI["OPTIONS"]["tlsAllowInvalidCertificates"] = True DATABASES = { "default": { From 1ec9ce901bbe00346aabf0c1463533b465cd155e Mon Sep 17 00:00:00 2001 From: Jib Date: Thu, 23 Jan 2025 11:13:00 -0500 Subject: [PATCH 20/22] fix error on django test suite run --- .github/workflows/mongodb_settings.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/mongodb_settings.py b/.github/workflows/mongodb_settings.py index caf5d3dbf..69710f60d 100644 --- a/.github/workflows/mongodb_settings.py +++ b/.github/workflows/mongodb_settings.py @@ -5,9 +5,8 @@ PARSED_URI = parse_uri(os.getenv("MONGODB_URI")) if os.getenv("MONGODB_URI") else {} # Temporary fix for https://github.com/mongodb-labs/mongo-orchestration/issues/268 -if PARSED_URI["USER"] and PARSED_URI["PASSWORD"]: - PARSED_URI["OPTIONS"]["tls"] = True - PARSED_URI["OPTIONS"]["tlsAllowInvalidCertificates"] = True +if PARSED_URI.get("USER") and PARSED_URI.get("PASSWORD"): + PARSED_URI["OPTIONS"].update({"tls": True, "tlsAllowInvalidCertificates": True}) DATABASES = { "default": { From 2ef2136c663d081f711c2edf18248dbdeabbc60c Mon Sep 17 00:00:00 2001 From: Jib Date: Fri, 24 Jan 2025 09:39:46 -0500 Subject: [PATCH 21/22] reformatted to separate database constructions --- .github/workflows/mongodb_settings.py | 37 +++++++++++++++------------ 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/.github/workflows/mongodb_settings.py b/.github/workflows/mongodb_settings.py index 69710f60d..f6b73c55b 100644 --- a/.github/workflows/mongodb_settings.py +++ b/.github/workflows/mongodb_settings.py @@ -2,24 +2,27 @@ from django_mongodb_backend import parse_uri -PARSED_URI = parse_uri(os.getenv("MONGODB_URI")) if os.getenv("MONGODB_URI") else {} +if mongodb_uri := os.getenv("MONGODB_URI"): + db_settings = parse_uri(mongodb_uri) -# Temporary fix for https://github.com/mongodb-labs/mongo-orchestration/issues/268 -if PARSED_URI.get("USER") and PARSED_URI.get("PASSWORD"): - PARSED_URI["OPTIONS"].update({"tls": True, "tlsAllowInvalidCertificates": True}) - -DATABASES = { - "default": { - **PARSED_URI, - "ENGINE": "django_mongodb_backend", - "NAME": "djangotests", - }, - "other": { - **PARSED_URI, - "ENGINE": "django_mongodb_backend", - "NAME": "djangotests-other", - }, -} + # Workaround for https://github.com/mongodb-labs/mongo-orchestration/issues/268 + if db_settings["USER"] and db_settings["PASSWORD"]: + db_settings.update({"tls": True, "tlsAllowInvalidCertificates": True}) + DATABASES = { + "default": {**db_settings, "NAME": "djangotests"}, + "other": {**db_settings, "NAME": "djangotests-other"}, + } +else: + DATABASES = { + "default": { + "ENGINE": "django_mongodb_backend", + "NAME": "djangotests", + }, + "other": { + "ENGINE": "django_mongodb_backend", + "NAME": "djangotests-other", + }, + } DEFAULT_AUTO_FIELD = "django_mongodb_backend.fields.ObjectIdAutoField" PASSWORD_HASHERS = ("django.contrib.auth.hashers.MD5PasswordHasher",) From 3d7f52abd12a730b0655928a0635f9ebb7e02628 Mon Sep 17 00:00:00 2001 From: Jib Date: Fri, 24 Jan 2025 17:11:05 -0500 Subject: [PATCH 22/22] db_settings['OPTIONS'] --- .github/workflows/mongodb_settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/mongodb_settings.py b/.github/workflows/mongodb_settings.py index f6b73c55b..f33d458ac 100644 --- a/.github/workflows/mongodb_settings.py +++ b/.github/workflows/mongodb_settings.py @@ -7,7 +7,7 @@ # Workaround for https://github.com/mongodb-labs/mongo-orchestration/issues/268 if db_settings["USER"] and db_settings["PASSWORD"]: - db_settings.update({"tls": True, "tlsAllowInvalidCertificates": True}) + db_settings["OPTIONS"].update({"tls": True, "tlsAllowInvalidCertificates": True}) DATABASES = { "default": {**db_settings, "NAME": "djangotests"}, "other": {**db_settings, "NAME": "djangotests-other"},