Skip to content

Commit 5e055ee

Browse files
blink1073NoahStapp
andauthored
PYTHON-5206 Convert Atlas Connect and Enterprise Auth tests to use new test scripts (#2201)
Co-authored-by: Noah Stapp <[email protected]>
1 parent 8274db2 commit 5e055ee

File tree

12 files changed

+91
-97
lines changed

12 files changed

+91
-97
lines changed

.evergreen/config.yml

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -267,28 +267,6 @@ functions:
267267
binary: bash
268268
args: [.evergreen/just.sh, run-tests]
269269

270-
"run enterprise auth tests":
271-
- command: subprocess.exec
272-
type: test
273-
params:
274-
binary: bash
275-
working_dir: "src"
276-
include_expansions_in_env: ["AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "AWS_SESSION_TOKEN", "PYTHON_BINARY"]
277-
args:
278-
- .evergreen/scripts/run-with-env.sh
279-
- .evergreen/scripts/run-enterprise-auth-tests.sh
280-
281-
"run atlas tests":
282-
- command: subprocess.exec
283-
type: test
284-
params:
285-
binary: bash
286-
include_expansions_in_env: ["AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "AWS_SESSION_TOKEN", "PYTHON_BINARY"]
287-
working_dir: "src"
288-
args:
289-
- .evergreen/scripts/run-with-env.sh
290-
- .evergreen/scripts/run-atlas-tests.sh
291-
292270
"cleanup":
293271
- command: subprocess.exec
294272
params:
@@ -422,13 +400,6 @@ tasks:
422400
- func: "run server"
423401
- func: "run doctests"
424402

425-
- name: "test-enterprise-auth"
426-
tags: ["enterprise-auth"]
427-
commands:
428-
- func: "run server"
429-
- func: "assume ec2 role"
430-
- func: "run enterprise auth tests"
431-
432403
- name: "test-search-index-helpers"
433404
commands:
434405
- func: "run server"
@@ -488,12 +459,6 @@ tasks:
488459
TOPOLOGY: "replica_set"
489460
- func: "run tests"
490461

491-
- name: "atlas-connect"
492-
tags: ["atlas-connect"]
493-
commands:
494-
- func: "assume ec2 role"
495-
- func: "run atlas tests"
496-
497462
- name: atlas-data-lake-tests
498463
commands:
499464
- func: "bootstrap data lake"

.evergreen/generated_configs/tasks.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
tasks:
2+
# Atlas connect tests
3+
- name: test-atlas-connect
4+
commands:
5+
- func: assume ec2 role
6+
- func: run tests
7+
vars:
8+
TEST_NAME: atlas_connect
9+
tags: [atlas_connect]
10+
211
# Aws tests
312
- name: test-auth-aws-4.4-regular
413
commands:
@@ -680,6 +689,20 @@ tasks:
680689
AWS_ROLE_SESSION_NAME: test
681690
tags: [auth-aws, auth-aws-web-identity]
682691

692+
# Enterprise auth tests
693+
- name: test-enterprise-auth
694+
commands:
695+
- func: run server
696+
vars:
697+
TEST_NAME: enterprise_auth
698+
AUTH: auth
699+
- func: assume ec2 role
700+
- func: run tests
701+
vars:
702+
TEST_NAME: enterprise_auth
703+
AUTH: auth
704+
tags: [enterprise_auth]
705+
683706
# Kms tests
684707
- name: test-gcpkms
685708
commands:

.evergreen/generated_configs/variants.yml

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,15 @@ buildvariants:
4949
# Atlas connect tests
5050
- name: atlas-connect-rhel8-python3.9
5151
tasks:
52-
- name: atlas-connect
52+
- name: .atlas_connect
5353
display_name: Atlas connect RHEL8 Python3.9
5454
run_on:
5555
- rhel87-small
5656
expansions:
5757
PYTHON_BINARY: /opt/python/3.9/bin/python3
5858
- name: atlas-connect-rhel8-python3.13
5959
tasks:
60-
- name: atlas-connect
60+
- name: .atlas_connect
6161
display_name: Atlas connect RHEL8 Python3.13
6262
run_on:
6363
- rhel87-small
@@ -510,59 +510,53 @@ buildvariants:
510510
tags: [encryption_tag]
511511

512512
# Enterprise auth tests
513-
- name: auth-enterprise-macos-python3.9-auth
513+
- name: auth-enterprise-macos-python3.9
514514
tasks:
515-
- name: test-enterprise-auth
516-
display_name: Auth Enterprise macOS Python3.9 Auth
515+
- name: .enterprise_auth
516+
display_name: Auth Enterprise macOS Python3.9
517517
run_on:
518518
- macos-14
519519
expansions:
520-
AUTH: auth
521520
PYTHON_BINARY: /Library/Frameworks/Python.Framework/Versions/3.9/bin/python3
522-
- name: auth-enterprise-rhel8-python3.10-auth
521+
- name: auth-enterprise-rhel8-python3.10
523522
tasks:
524-
- name: test-enterprise-auth
525-
display_name: Auth Enterprise RHEL8 Python3.10 Auth
523+
- name: .enterprise_auth
524+
display_name: Auth Enterprise RHEL8 Python3.10
526525
run_on:
527526
- rhel87-small
528527
expansions:
529-
AUTH: auth
530528
PYTHON_BINARY: /opt/python/3.10/bin/python3
531-
- name: auth-enterprise-rhel8-python3.11-auth
529+
- name: auth-enterprise-rhel8-python3.11
532530
tasks:
533-
- name: test-enterprise-auth
534-
display_name: Auth Enterprise RHEL8 Python3.11 Auth
531+
- name: .enterprise_auth
532+
display_name: Auth Enterprise RHEL8 Python3.11
535533
run_on:
536534
- rhel87-small
537535
expansions:
538-
AUTH: auth
539536
PYTHON_BINARY: /opt/python/3.11/bin/python3
540-
- name: auth-enterprise-rhel8-python3.12-auth
537+
- name: auth-enterprise-rhel8-python3.12
541538
tasks:
542-
- name: test-enterprise-auth
543-
display_name: Auth Enterprise RHEL8 Python3.12 Auth
539+
- name: .enterprise_auth
540+
display_name: Auth Enterprise RHEL8 Python3.12
544541
run_on:
545542
- rhel87-small
546543
expansions:
547-
AUTH: auth
548544
PYTHON_BINARY: /opt/python/3.12/bin/python3
549-
- name: auth-enterprise-win64-python3.13-auth
545+
- name: auth-enterprise-win64-python3.13
550546
tasks:
551-
- name: test-enterprise-auth
552-
display_name: Auth Enterprise Win64 Python3.13 Auth
547+
- name: .enterprise_auth
548+
display_name: Auth Enterprise Win64 Python3.13
553549
run_on:
554550
- windows-64-vsMulti-small
555551
expansions:
556-
AUTH: auth
557552
PYTHON_BINARY: C:/python/Python313/python.exe
558-
- name: auth-enterprise-rhel8-pypy3.10-auth
553+
- name: auth-enterprise-rhel8-pypy3.10
559554
tasks:
560-
- name: test-enterprise-auth
561-
display_name: Auth Enterprise RHEL8 PyPy3.10 Auth
555+
- name: .enterprise_auth
556+
display_name: Auth Enterprise RHEL8 PyPy3.10
562557
run_on:
563558
- rhel87-small
564559
expansions:
565-
AUTH: auth
566560
PYTHON_BINARY: /opt/python/pypy3.10/bin/python3
567561

568562
# Free threaded tests

.evergreen/scripts/generate_config.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,6 @@ def create_compression_variants():
464464

465465

466466
def create_enterprise_auth_variants():
467-
expansions = dict(AUTH="auth")
468467
variants = []
469468

470469
# All python versions across platforms.
@@ -475,10 +474,8 @@ def create_enterprise_auth_variants():
475474
host = HOSTS["win64"]
476475
else:
477476
host = DEFAULT_HOST
478-
display_name = get_display_name("Auth Enterprise", host, python=python, **expansions)
479-
variant = create_variant(
480-
["test-enterprise-auth"], display_name, host=host, python=python, expansions=expansions
481-
)
477+
display_name = get_display_name("Auth Enterprise", host, python=python)
478+
variant = create_variant([".enterprise_auth"], display_name, host=host, python=python)
482479
variants.append(variant)
483480

484481
return variants
@@ -721,7 +718,7 @@ def create_atlas_connect_variants():
721718
host = DEFAULT_HOST
722719
return [
723720
create_variant(
724-
["atlas-connect"],
721+
[".atlas_connect"],
725722
get_display_name("Atlas connect", host, python=python),
726723
python=python,
727724
host=host,
@@ -913,6 +910,25 @@ def _create_ocsp_task(algo, variant, server_type, base_task_name):
913910
return EvgTask(name=task_name, tags=tags, commands=commands)
914911

915912

913+
def create_atlas_connect_tasks():
914+
vars = dict(TEST_NAME="atlas_connect")
915+
assume_func = FunctionCall(func="assume ec2 role")
916+
test_func = FunctionCall(func="run tests", vars=vars)
917+
task_name = "test-atlas-connect"
918+
tags = ["atlas_connect"]
919+
return [EvgTask(name=task_name, tags=tags, commands=[assume_func, test_func])]
920+
921+
922+
def create_enterprise_auth_tasks():
923+
vars = dict(TEST_NAME="enterprise_auth", AUTH="auth")
924+
server_func = FunctionCall(func="run server", vars=vars)
925+
assume_func = FunctionCall(func="assume ec2 role")
926+
test_func = FunctionCall(func="run tests", vars=vars)
927+
task_name = "test-enterprise-auth"
928+
tags = ["enterprise_auth"]
929+
return [EvgTask(name=task_name, tags=tags, commands=[server_func, assume_func, test_func])]
930+
931+
916932
def create_ocsp_tasks():
917933
tasks = []
918934
tests = [

.evergreen/scripts/run-atlas-tests.sh

Lines changed: 0 additions & 8 deletions
This file was deleted.

.evergreen/scripts/run-direct-tests.sh

Lines changed: 0 additions & 10 deletions
This file was deleted.

.evergreen/scripts/run-enterprise-auth-tests.sh

Lines changed: 0 additions & 9 deletions
This file was deleted.

.evergreen/scripts/setup_tests.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@ def setup_libmongocrypt():
112112
run_command("chmod +x libmongocrypt/nocrypto/bin/mongocrypt.dll")
113113

114114

115+
def get_secrets(name: str) -> None:
116+
run_command(f"bash {DRIVERS_TOOLS}/.evergreen/secrets_handling/setup-secrets.sh {name}")
117+
118+
115119
def handle_test_env() -> None:
116120
opts, _ = get_test_options("Set up the test environment and services.")
117121
test_name = opts.test_name
@@ -203,6 +207,7 @@ def handle_test_env() -> None:
203207
write_env("PYMONGO_DISABLE_TEST_COMMANDS", "1")
204208

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

354+
if test_name == "atlas_connect":
355+
get_secrets("drivers/atlas_connect")
356+
# We do not want the default client_context to be initialized.
357+
write_env("DISABLE_CONTEXT")
358+
349359
if test_name == "perf":
350360
# PYTHON-4769 Run perf_test.py directly otherwise pytest's test collection negatively
351361
# affects the benchmark results.

.evergreen/scripts/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class Distro:
3030

3131
# Map the test name to a test suite.
3232
TEST_SUITE_MAP = {
33-
"atlas": "atlas",
33+
"atlas_connect": "atlas_connect",
3434
"auth_aws": "auth_aws",
3535
"auth_oidc": "auth_oidc",
3636
"data_lake": "data_lake",

CONTRIBUTING.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,19 @@ For KMS tests that run remotely and are expected to pass, in this case using `gc
262262
- Run `just setup-tests kms gcp`.
263263
- Run `just run-tests`.
264264

265+
### Enterprise Auth tests
266+
267+
Note: these tests can only be run from an Evergreen host.
268+
269+
- Run `just run-server enterprise_auth`.
270+
- Run `just setup-tests enterprise_auth`.
271+
- Run `just run-tests`.
272+
273+
### Atlas Connect tests
274+
275+
- Run `just setup-tests atlas_connect`.
276+
- Run `just run-tests`.
277+
265278
### OCSP tests
266279

267280
- Export the orchestration file, e.g. `export ORCHESTRATION_FILE=rsa-basic-tls-ocsp-disableStapling.json`.

0 commit comments

Comments
 (0)