Skip to content

Add 8.0 and Auth + SSL Testing #220

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 24 commits into from
Jan 25, 2025
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 51 additions & 14 deletions .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,20 @@ 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
type: test
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

Expand All @@ -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
13 changes: 13 additions & 0 deletions .github/workflows/mongodb_settings.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
import os

from django_mongodb_backend import parse_uri

PARSED_URI = parse_uri(os.getenv("MONGODB_URI")) if os.getenv("MONGODB_URI") else {}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While it's a bit more verbose, I think it would be clearer to separate the two paths.

if uri := os.getenv("MONGODB_URI"):
    # Settings for the evergreen builds.
    databases_settings = parse_uri(uri)
    # Workaround for https://github.com/mongodb-labs/mongo-orchestration/issues/268
    if databases_settings["USER"] and databases_settings["PASSWORD"]:
        databases_settings["OPTIONS"].update({"tls": True, "tlsAllowInvalidCertificates": True})
    DATABASES["default"] = DATABASES["other"] = databases_settings
    DATABASES["default"]["NAME"] = "djangotests"
    DATABASES["other"]["NAME"] = "djangotests-other"
else:
    # Settings for the Github actions build.
    DATABASES = {...existing code...}

My only question is whether it's necessary to check both username and password since it seems unlikely one would be set without the either (or at least a password without a user).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure


# 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",
},
}

DEFAULT_AUTO_FIELD = "django_mongodb_backend.fields.ObjectIdAutoField"
PASSWORD_HASHERS = ("django.contrib.auth.hashers.MD5PasswordHasher",)
SECRET_KEY = "django_tests_secret_key"
Expand Down
Loading