diff --git a/.evergreen/config.yml b/.evergreen/config.yml index 6490b069f..6aa2020ca 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -31,13 +31,12 @@ functions: - command: subprocess.exec params: binary: bash - env: - MONGODB_VERSION: "5.0" - TOPOLOGY: server - AUTH: "noauth" - SSL: "nossl" + add_expansions_to_env: true args: - ${DRIVERS_TOOLS}/.evergreen/run-orchestration.sh + - command: expansions.update + params: + file: mo-expansion.yml "run unit tests": - command: subprocess.exec @@ -45,7 +44,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 @@ -64,13 +63,51 @@ post: - func: teardown tasks: -- name: run-tests - commands: - - func: "run unit tests" + - name: run-tests + commands: + - func: "run unit tests" buildvariants: -- name: tests - display_name: Run Tests - run_on: rhel87-small - 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-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 diff --git a/.github/workflows/mongodb_settings.py b/.github/workflows/mongodb_settings.py index dc543a1e9..f33d458ac 100644 --- a/.github/workflows/mongodb_settings.py +++ b/.github/workflows/mongodb_settings.py @@ -1,13 +1,29 @@ -DATABASES = { - "default": { - "ENGINE": "django_mongodb_backend", - "NAME": "djangotests", - }, - "other": { - "ENGINE": "django_mongodb_backend", - "NAME": "djangotests-other", - }, -} +import os + +from django_mongodb_backend import parse_uri + +if mongodb_uri := os.getenv("MONGODB_URI"): + db_settings = parse_uri(mongodb_uri) + + # Workaround for https://github.com/mongodb-labs/mongo-orchestration/issues/268 + if db_settings["USER"] and db_settings["PASSWORD"]: + db_settings["OPTIONS"].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",) SECRET_KEY = "django_tests_secret_key"