Skip to content

PYTHON-5206 Convert Atlas Connect and Enterprise Auth tests to use new test scripts #2201

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 7 commits into from
Mar 13, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
35 changes: 0 additions & 35 deletions .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -267,28 +267,6 @@ functions:
binary: bash
args: [.evergreen/just.sh, run-tests]

"run enterprise auth tests":
- command: subprocess.exec
type: test
params:
binary: bash
working_dir: "src"
include_expansions_in_env: ["AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "AWS_SESSION_TOKEN", "PYTHON_BINARY"]
args:
- .evergreen/scripts/run-with-env.sh
- .evergreen/scripts/run-enterprise-auth-tests.sh

"run atlas tests":
- command: subprocess.exec
type: test
params:
binary: bash
include_expansions_in_env: ["AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "AWS_SESSION_TOKEN", "PYTHON_BINARY"]
working_dir: "src"
args:
- .evergreen/scripts/run-with-env.sh
- .evergreen/scripts/run-atlas-tests.sh

"cleanup":
- command: subprocess.exec
params:
Expand Down Expand Up @@ -422,13 +400,6 @@ tasks:
- func: "run server"
- func: "run doctests"

- name: "test-enterprise-auth"
tags: ["enterprise-auth"]
commands:
- func: "run server"
- func: "assume ec2 role"
- func: "run enterprise auth tests"

- name: "test-search-index-helpers"
commands:
- func: "run server"
Expand Down Expand Up @@ -488,12 +459,6 @@ tasks:
TOPOLOGY: "replica_set"
- func: "run tests"

- name: "atlas-connect"
tags: ["atlas-connect"]
commands:
- func: "assume ec2 role"
- func: "run atlas tests"

- name: atlas-data-lake-tests
commands:
- func: "bootstrap data lake"
Expand Down
23 changes: 23 additions & 0 deletions .evergreen/generated_configs/tasks.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
tasks:
# Atlas connect tests
- name: test-atlas-connect
commands:
- func: assume ec2 role
- func: run tests
vars:
TEST_NAME: atlas_connect
tags: [atlas_connect]

# Aws tests
- name: test-auth-aws-4.4-regular
commands:
Expand Down Expand Up @@ -680,6 +689,20 @@ tasks:
AWS_ROLE_SESSION_NAME: test
tags: [auth-aws, auth-aws-web-identity]

# Enterprise auth tests
- name: test-enterprise-auth
commands:
- func: run server
vars:
TEST_NAME: enterprise_auth
AUTH: auth
- func: assume ec2 role
- func: run tests
vars:
TEST_NAME: enterprise_auth
AUTH: auth
tags: [enterprise_auth]

# Kms tests
- name: test-gcpkms
commands:
Expand Down
46 changes: 20 additions & 26 deletions .evergreen/generated_configs/variants.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ buildvariants:
# Atlas connect tests
- name: atlas-connect-rhel8-python3.9
tasks:
- name: atlas-connect
- name: .atlas_connect
display_name: Atlas connect RHEL8 Python3.9
run_on:
- rhel87-small
expansions:
PYTHON_BINARY: /opt/python/3.9/bin/python3
- name: atlas-connect-rhel8-python3.13
tasks:
- name: atlas-connect
- name: .atlas_connect
display_name: Atlas connect RHEL8 Python3.13
run_on:
- rhel87-small
Expand Down Expand Up @@ -510,59 +510,53 @@ buildvariants:
tags: [encryption_tag]

# Enterprise auth tests
- name: auth-enterprise-macos-python3.9-auth
- name: auth-enterprise-macos-python3.9
tasks:
- name: test-enterprise-auth
display_name: Auth Enterprise macOS Python3.9 Auth
- name: .enterprise_auth
display_name: Auth Enterprise macOS Python3.9
run_on:
- macos-14
expansions:
AUTH: auth
PYTHON_BINARY: /Library/Frameworks/Python.Framework/Versions/3.9/bin/python3
- name: auth-enterprise-rhel8-python3.10-auth
- name: auth-enterprise-rhel8-python3.10
tasks:
- name: test-enterprise-auth
display_name: Auth Enterprise RHEL8 Python3.10 Auth
- name: .enterprise_auth
display_name: Auth Enterprise RHEL8 Python3.10
run_on:
- rhel87-small
expansions:
AUTH: auth
PYTHON_BINARY: /opt/python/3.10/bin/python3
- name: auth-enterprise-rhel8-python3.11-auth
- name: auth-enterprise-rhel8-python3.11
tasks:
- name: test-enterprise-auth
display_name: Auth Enterprise RHEL8 Python3.11 Auth
- name: .enterprise_auth
display_name: Auth Enterprise RHEL8 Python3.11
run_on:
- rhel87-small
expansions:
AUTH: auth
PYTHON_BINARY: /opt/python/3.11/bin/python3
- name: auth-enterprise-rhel8-python3.12-auth
- name: auth-enterprise-rhel8-python3.12
tasks:
- name: test-enterprise-auth
display_name: Auth Enterprise RHEL8 Python3.12 Auth
- name: .enterprise_auth
display_name: Auth Enterprise RHEL8 Python3.12
run_on:
- rhel87-small
expansions:
AUTH: auth
PYTHON_BINARY: /opt/python/3.12/bin/python3
- name: auth-enterprise-win64-python3.13-auth
- name: auth-enterprise-win64-python3.13
tasks:
- name: test-enterprise-auth
display_name: Auth Enterprise Win64 Python3.13 Auth
- name: .enterprise_auth
display_name: Auth Enterprise Win64 Python3.13
run_on:
- windows-64-vsMulti-small
expansions:
AUTH: auth
PYTHON_BINARY: C:/python/Python313/python.exe
- name: auth-enterprise-rhel8-pypy3.10-auth
- name: auth-enterprise-rhel8-pypy3.10
tasks:
- name: test-enterprise-auth
display_name: Auth Enterprise RHEL8 PyPy3.10 Auth
- name: .enterprise_auth
display_name: Auth Enterprise RHEL8 PyPy3.10
run_on:
- rhel87-small
expansions:
AUTH: auth
PYTHON_BINARY: /opt/python/pypy3.10/bin/python3

# Free threaded tests
Expand Down
28 changes: 22 additions & 6 deletions .evergreen/scripts/generate_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,6 @@ def create_compression_variants():


def create_enterprise_auth_variants():
expansions = dict(AUTH="auth")
variants = []

# All python versions across platforms.
Expand All @@ -475,10 +474,8 @@ def create_enterprise_auth_variants():
host = HOSTS["win64"]
else:
host = DEFAULT_HOST
display_name = get_display_name("Auth Enterprise", host, python=python, **expansions)
variant = create_variant(
["test-enterprise-auth"], display_name, host=host, python=python, expansions=expansions
)
display_name = get_display_name("Auth Enterprise", host, python=python)
variant = create_variant([".enterprise_auth"], display_name, host=host, python=python)
variants.append(variant)

return variants
Expand Down Expand Up @@ -721,7 +718,7 @@ def create_atlas_connect_variants():
host = DEFAULT_HOST
return [
create_variant(
["atlas-connect"],
[".atlas_connect"],
get_display_name("Atlas connect", host, python=python),
python=python,
host=host,
Expand Down Expand Up @@ -913,6 +910,25 @@ def _create_ocsp_task(algo, variant, server_type, base_task_name):
return EvgTask(name=task_name, tags=tags, commands=commands)


def create_atlas_connect_tasks():
vars = dict(TEST_NAME="atlas_connect")
assume_func = FunctionCall(func="assume ec2 role")
test_func = FunctionCall(func="run tests", vars=vars)
task_name = "test-atlas-connect"
tags = ["atlas_connect"]
return [EvgTask(name=task_name, tags=tags, commands=[assume_func, test_func])]


def create_enterprise_auth_tasks():
vars = dict(TEST_NAME="enterprise_auth", AUTH="auth")
server_func = FunctionCall(func="run server", vars=vars)
assume_func = FunctionCall(func="assume ec2 role")
test_func = FunctionCall(func="run tests", vars=vars)
task_name = "test-enterprise-auth"
tags = ["enterprise_auth"]
return [EvgTask(name=task_name, tags=tags, commands=[server_func, assume_func, test_func])]


def create_ocsp_tasks():
tasks = []
tests = [
Expand Down
8 changes: 0 additions & 8 deletions .evergreen/scripts/run-atlas-tests.sh

This file was deleted.

10 changes: 0 additions & 10 deletions .evergreen/scripts/run-direct-tests.sh

This file was deleted.

9 changes: 0 additions & 9 deletions .evergreen/scripts/run-enterprise-auth-tests.sh

This file was deleted.

10 changes: 10 additions & 0 deletions .evergreen/scripts/setup_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ def setup_libmongocrypt():
run_command("chmod +x libmongocrypt/nocrypto/bin/mongocrypt.dll")


def get_secrets(name: str) -> None:
run_command(f"bash {DRIVERS_TOOLS}/.evergreen/secrets_handling/setup-secrets.sh {name}")


def handle_test_env() -> None:
opts, _ = get_test_options("Set up the test environment and services.")
test_name = opts.test_name
Expand Down Expand Up @@ -203,6 +207,7 @@ def handle_test_env() -> None:
write_env("PYMONGO_DISABLE_TEST_COMMANDS", "1")

if test_name == "enterprise_auth":
get_secrets("drivers/enterprise_auth")
config = read_env(f"{ROOT}/secrets-export.sh")
if PLATFORM == "windows":
LOGGER.info("Setting GSSAPI_PASS")
Expand Down Expand Up @@ -346,6 +351,11 @@ def handle_test_env() -> None:
else:
run_command(f"bash {auth_aws_dir}/setup-secrets.sh")

if test_name == "atlas_connect":
get_secrets("drivers/atlas_connect")
# We do not want the default client_context to be initialized.
write_env("DISABLE_CONTEXT")

if test_name == "perf":
# PYTHON-4769 Run perf_test.py directly otherwise pytest's test collection negatively
# affects the benchmark results.
Expand Down
2 changes: 1 addition & 1 deletion .evergreen/scripts/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Distro:

# Map the test name to a test suite.
TEST_SUITE_MAP = {
"atlas": "atlas",
"atlas_connect": "atlas_connect",
"auth_aws": "auth_aws",
"auth_oidc": "auth_oidc",
"data_lake": "data_lake",
Expand Down
13 changes: 13 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,19 @@ For KMS tests that run remotely and are expected to pass, in this case using `gc
- Run `just setup-tests kms gcp`.
- Run `just run-tests`.

### Enterprise Auth tests

Note: these tests can only be run from an Evergreen host.
Copy link
Contributor

Choose a reason for hiding this comment

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

Both enterprise auth and atlas connect, or just the first?

Copy link
Member Author

Choose a reason for hiding this comment

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

Just the first


- Run `just run-server enterprise_auth`.
- Run `just setup-tests enterprise_auth`.
- Run `just run-tests`.

### Atlas Connect tests

- Run `just setup-tests atlas_connect`.
- Run `just run-tests`.

### OCSP tests

- Export the orchestration file, e.g. `export ORCHESTRATION_FILE=rsa-basic-tls-ocsp-disableStapling.json`.
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ markers = [
"auth_oidc: tests that rely on oidc auth",
"auth: tests that rely on authentication",
"ocsp: tests that rely on ocsp",
"atlas: tests that rely on atlas",
"atlas_connect: tests that rely on an atlas connection",
"data_lake: tests that rely on atlas data lake",
"perf: benchmark tests",
"index_management: index management tests",
Expand Down
2 changes: 1 addition & 1 deletion test/atlas/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import pymongo
from pymongo.ssl_support import HAS_SNI

pytestmark = pytest.mark.atlas
pytestmark = pytest.mark.atlas_connect


URIS = {
Expand Down
Loading