Skip to content

Commit 8025271

Browse files
committed
add files
1 parent e6e8650 commit 8025271

File tree

12 files changed

+139
-104
lines changed

12 files changed

+139
-104
lines changed

.evergreen/config.yml

Lines changed: 1 addition & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -293,27 +293,7 @@ functions:
293293
- command: ec2.assume_role
294294
params:
295295
role_arn: ${aws_test_secrets_role}
296-
297-
"setup atlas":
298-
- command: subprocess.exec
299-
params:
300-
binary: bash
301-
include_expansions_in_env: ["task_id", "execution"]
302-
env:
303-
MONGODB_VERSION: "7.0"
304-
LAMBDA_STACK_NAME: dbx-python-lambda
305-
args:
306-
- ${DRIVERS_TOOLS}/.evergreen/atlas/setup-atlas-cluster.sh
307-
- command: expansions.update
308-
params:
309-
file: atlas-expansion.yml
310-
311-
"teardown atlas":
312-
- command: subprocess.exec
313-
params:
314-
binary: bash
315-
args:
316-
- ${DRIVERS_TOOLS}/.evergreen/atlas/teardown-atlas-cluster.sh
296+
duration_seconds: 3600
317297

318298
"run perf tests":
319299
- command: subprocess.exec
@@ -350,31 +330,6 @@ post:
350330
- func: "upload test results"
351331
- func: "cleanup"
352332

353-
task_groups:
354-
- name: test_aws_lambda_task_group
355-
setup_group:
356-
- func: fetch source
357-
- func: setup system
358-
- func: setup atlas
359-
teardown_task:
360-
- func: teardown atlas
361-
setup_group_can_fail_task: true
362-
setup_group_timeout_secs: 1800
363-
tasks:
364-
- test-aws-lambda-deployed
365-
366-
- name: test_atlas_task_group_search_indexes
367-
setup_group:
368-
- func: fetch source
369-
- func: setup system
370-
- func: setup atlas
371-
teardown_task:
372-
- func: teardown atlas
373-
setup_group_can_fail_task: true
374-
setup_group_timeout_secs: 1800
375-
tasks:
376-
- test-search-index-helpers
377-
378333
tasks:
379334
# Wildcard task. Do you need to find out what tools are available and where?
380335
# Throw it here, and execute this task on all buildvariants
@@ -401,17 +356,6 @@ tasks:
401356
- func: "run server"
402357
- func: "run doctests"
403358

404-
- name: "test-search-index-helpers"
405-
commands:
406-
- func: "run server"
407-
vars:
408-
VERSION: "6.0"
409-
TOPOLOGY: "replica_set"
410-
- func: "run tests"
411-
vars:
412-
TEST_NAME: index_management
413-
AUTH: "auth"
414-
415359
- name: "mod-wsgi-standalone"
416360
tags: ["mod_wsgi"]
417361
commands:
@@ -467,22 +411,6 @@ tasks:
467411
vars:
468412
TEST_NAME: "data_lake"
469413

470-
- name: "test-aws-lambda-deployed"
471-
commands:
472-
- command: ec2.assume_role
473-
params:
474-
role_arn: ${LAMBDA_AWS_ROLE_ARN}
475-
duration_seconds: 3600
476-
- command: subprocess.exec
477-
params:
478-
working_dir: src
479-
binary: bash
480-
add_expansions_to_env: true
481-
args:
482-
- .evergreen/run-deployed-lambda-aws-tests.sh
483-
env:
484-
TEST_LAMBDA_DIRECTORY: ${PROJECT_DIRECTORY}/test/lambda
485-
486414
# }}}
487415
- name: "coverage-report"
488416
tags: ["coverage"]
@@ -637,12 +565,6 @@ buildvariants:
637565
batchtime: 10080 # 7 days
638566
- name: test-azurekms-fail
639567

640-
- name: rhel8-test-lambda
641-
display_name: FaaS Lambda
642-
run_on: rhel87-small
643-
tasks:
644-
- name: test_aws_lambda_task_group
645-
646568
- name: rhel8-import-time
647569
display_name: Import Time
648570
run_on: rhel87-small

.evergreen/generated_configs/tasks.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@ tasks:
88
TEST_NAME: atlas_connect
99
tags: [atlas_connect]
1010

11+
# Aws lambda tests
12+
- name: test-aws-lambda-deployed
13+
commands:
14+
- func: assume ec2 role
15+
- func: setup atlas
16+
- func: run tests
17+
vars:
18+
TEST_NAME: aws_lambda
19+
tags: [aws_lambda]
20+
1121
# Aws tests
1222
- name: test-auth-aws-4.4-regular
1323
commands:
@@ -696,11 +706,13 @@ tasks:
696706
vars:
697707
TEST_NAME: enterprise_auth
698708
AUTH: auth
709+
FOO: ${THIS THING}
699710
- func: assume ec2 role
700711
- func: run tests
701712
vars:
702713
TEST_NAME: enterprise_auth
703714
AUTH: auth
715+
FOO: ${THIS THING}
704716
tags: [enterprise_auth]
705717

706718
# Kms tests
@@ -1109,6 +1121,19 @@ tasks:
11091121
SUB_TEST_NAME: gke
11101122
tags: [auth_oidc, auth_oidc_remote]
11111123

1124+
# Search index tests
1125+
- name: test-search-index-helpers
1126+
commands:
1127+
- func: assume ec2 role
1128+
- func: setup atlas
1129+
- func: run server
1130+
vars:
1131+
TEST_NAME: index_management
1132+
- func: run tests
1133+
vars:
1134+
TEST_NAME: index_management
1135+
tags: [index_managment]
1136+
11121137
# Server tests
11131138
- name: test-4.0-standalone-auth-ssl-sync
11141139
commands:

.evergreen/generated_configs/variants.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,14 @@ buildvariants:
154154
expansions:
155155
PYTHON_BINARY: /Library/Frameworks/Python.Framework/Versions/3.13/bin/python3
156156

157+
# Aws lambda tests
158+
- name: faas-lambda
159+
tasks:
160+
- name: .aws_lambda
161+
display_name: FaaS Lambda
162+
run_on:
163+
- rhel87-small
164+
157165
# Compression tests
158166
- name: compression-snappy-rhel8-python3.9-no-c
159167
tasks:
@@ -1005,7 +1013,7 @@ buildvariants:
10051013
# Search index tests
10061014
- name: search-index-helpers-rhel8-python3.9
10071015
tasks:
1008-
- name: test_atlas_task_group_search_indexes
1016+
- name: .index_management
10091017
display_name: Search Index Helpers RHEL8 Python3.9
10101018
run_on:
10111019
- rhel87-small

.evergreen/run-deployed-lambda-aws-tests.sh

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

.evergreen/scripts/generate_config.py

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ def create_search_index_variants():
680680
python = CPYTHONS[0]
681681
return [
682682
create_variant(
683-
["test_atlas_task_group_search_indexes"],
683+
[".index_management"],
684684
get_display_name("Search Index Helpers", host, python=python),
685685
python=python,
686686
host=host,
@@ -780,6 +780,11 @@ def create_alternative_hosts_variants():
780780
return variants
781781

782782

783+
def create_aws_lambda_variants():
784+
host = HOSTS["rhel8"]
785+
return [create_variant([".aws_lambda"], display_name="FaaS Lambda", host=host)]
786+
787+
783788
##############
784789
# Tasks
785790
##############
@@ -910,6 +915,29 @@ def _create_ocsp_task(algo, variant, server_type, base_task_name):
910915
return EvgTask(name=task_name, tags=tags, commands=commands)
911916

912917

918+
def create_aws_lambda_tasks():
919+
assume_func = FunctionCall(func="assume ec2 role")
920+
atlas_func = FunctionCall(func="setup atlas")
921+
vars = dict(TEST_NAME="aws_lambda")
922+
test_func = FunctionCall(func="run tests", vars=vars)
923+
task_name = "test-aws-lambda-deployed"
924+
tags = ["aws_lambda"]
925+
commands = [assume_func, atlas_func, test_func]
926+
return [EvgTask(name=task_name, tags=tags, commands=commands)]
927+
928+
929+
def create_search_index_tasks():
930+
assume_func = FunctionCall(func="assume ec2 role")
931+
atlas_func = FunctionCall(func="setup atlas")
932+
server_func = FunctionCall(func="run server", vars=dict(TEST_NAME="index_management"))
933+
vars = dict(TEST_NAME="index_management")
934+
test_func = FunctionCall(func="run tests", vars=vars)
935+
task_name = "test-search-index-helpers"
936+
tags = ["index_managment"]
937+
commands = [assume_func, atlas_func, server_func, test_func]
938+
return [EvgTask(name=task_name, tags=tags, commands=commands)]
939+
940+
913941
def create_atlas_connect_tasks():
914942
vars = dict(TEST_NAME="atlas_connect")
915943
assume_func = FunctionCall(func="assume ec2 role")
@@ -920,7 +948,7 @@ def create_atlas_connect_tasks():
920948

921949

922950
def create_enterprise_auth_tasks():
923-
vars = dict(TEST_NAME="enterprise_auth", AUTH="auth")
951+
vars = dict(TEST_NAME="enterprise_auth", AUTH="auth", FOO="${THIS THING}")
924952
server_func = FunctionCall(func="run server", vars=vars)
925953
assume_func = FunctionCall(func="assume ec2 role")
926954
test_func = FunctionCall(func="run tests", vars=vars)

.evergreen/scripts/run_server.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,6 @@ def start_server():
2222
if "VERSION" in os.environ:
2323
os.environ["MONGODB_VERSION"] = os.environ["VERSION"]
2424

25-
if opts.auth:
26-
extra_opts.append("--auth")
27-
28-
if opts.verbose:
29-
extra_opts.append("-v")
30-
elif opts.quiet:
31-
extra_opts.append("-q")
32-
3325
if test_name == "auth_aws":
3426
set_env("AUTH_AWS")
3527

@@ -51,6 +43,10 @@ def start_server():
5143
if not found:
5244
raise ValueError("Please provide an orchestration file")
5345

46+
elif test_name == "index_management":
47+
os.environ["TOPOLOGY"] = "replica_set"
48+
os.environ["MONGODB_VERSION"] = "6.0"
49+
5450
if not os.environ.get("TEST_CRYPT_SHARED"):
5551
set_env("SKIP_CRYPT_SHARED")
5652

@@ -62,6 +58,14 @@ def start_server():
6258
set_env("TLS_PEM_KEY_FILE", certs / "server.pem")
6359
set_env("TLS_CA_FILE", certs / "ca.pem")
6460

61+
if opts.auth:
62+
extra_opts.append("--auth")
63+
64+
if opts.verbose:
65+
extra_opts.append("-v")
66+
elif opts.quiet:
67+
extra_opts.append("-q")
68+
6569
cmd = ["bash", f"{DRIVERS_TOOLS}/.evergreen/run-orchestration.sh", *extra_opts]
6670
run_command(cmd, cwd=DRIVERS_TOOLS)
6771

.evergreen/scripts/run_tests.py

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@
66
import platform
77
import shutil
88
import sys
9+
import tarfile
10+
import tempfile
911
from datetime import datetime
12+
from shutil import which
1013

1114
import pytest
12-
from utils import DRIVERS_TOOLS, LOGGER, ROOT, run_command
15+
from utils import DRIVERS_TOOLS, LOGGER, ROOT, create_archive, run_command
1316

1417
AUTH = os.environ.get("AUTH", "noauth")
1518
SSL = os.environ.get("SSL", "nossl")
@@ -82,6 +85,28 @@ def handle_pymongocrypt() -> None:
8285
LOGGER.info(f"libmongocrypt version: {pymongocrypt.libmongocrypt_version()})")
8386

8487

88+
def handle_aws_lambda() -> None:
89+
env = os.environ.copy()
90+
target_dir = ROOT / "test/lambda"
91+
env["TEST_LAMBDA_DIRECTORY"] = str(target_dir)
92+
archive = create_archive()
93+
with tempfile.TemporaryDirectory() as td:
94+
# Unpack the archive
95+
fid = tarfile.open(archive)
96+
fid.extractall(td)
97+
fid.close()
98+
# Build the c extensions.
99+
docker = which("docker") or which("podman")
100+
if not docker:
101+
raise ValueError("Could not find docker!")
102+
image = "quay.io/pypa/manylinux2014_x86_64:latest"
103+
run_command(f'{docker} run --rm -v "{td}:/src" {image} /src/test/lambda/build_internal.sh')
104+
shutil.copytree(td, ROOT / "test/lambda/mongodb")
105+
106+
script_name = "run-deployed-lambda-aws-tests.sh"
107+
run_command(f"bash {DRIVERS_TOOLS}/.evergreen/aws_lambda/{script_name}", env=env)
108+
109+
85110
def run() -> None:
86111
# Handle green framework first so they can patch modules.
87112
if GREEN_FRAMEWORK:
@@ -123,6 +148,11 @@ def run() -> None:
123148
test_oidc_send_to_remote(SUB_TEST_NAME)
124149
return
125150

151+
# Run deployed aws lambda tests.
152+
if TEST_NAME == "aws_lambda":
153+
handle_aws_lambda()
154+
return
155+
126156
if os.environ.get("DEBUG_LOG"):
127157
TEST_ARGS.extend(f"-o log_cli_level={logging.DEBUG} -o log_cli=1".split())
128158

.evergreen/scripts/setup_tests.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,16 @@ def handle_test_env() -> None:
172172
if not config:
173173
AUTH = "noauth"
174174

175+
if test_name in ["aws_lambda", "index_management"]:
176+
env = os.environ.copy()
177+
env["MONGODB_VERSION"] = "7.0"
178+
env["LAMBDA_STACK_NAME"] = "dbx-python-lambda"
179+
write_env("LAMBDA_STACK_NAME", env["LAMBDA_STACK_NAME"])
180+
# run_command(f"bash {DRIVERS_TOOLS}/.evergreen/atlas/setup-atlas-cluster.sh", env=env, cwd=DRIVERS_TOOLS)
181+
182+
if test_name == "index_management":
183+
AUTH = "auth"
184+
175185
if AUTH != "noauth":
176186
if test_name == "data_lake":
177187
config = read_env(f"{DRIVERS_TOOLS}/.evergreen/atlas_data_lake/secrets-export.sh")
@@ -381,7 +391,7 @@ def handle_test_env() -> None:
381391
# Use --capture=tee-sys so pytest prints test output inline:
382392
# https://docs.pytest.org/en/stable/how-to/capture-stdout-stderr.html
383393
TEST_ARGS = f"-v --capture=tee-sys --durations=5 {TEST_ARGS}"
384-
TEST_SUITE = TEST_SUITE_MAP[test_name]
394+
TEST_SUITE = TEST_SUITE_MAP.get(test_name)
385395
if TEST_SUITE:
386396
TEST_ARGS = f"-m {TEST_SUITE} {TEST_ARGS}"
387397

.evergreen/scripts/teardown_tests.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@
3838
elif TEST_NAME == "serverless":
3939
run_command(f"bash {DRIVERS_TOOLS}/.evergreen/serverless/teardown.sh")
4040

41+
# Tear down atlas cluster if applicable.
42+
if TEST_NAME in ["aws_lambda", "index_management"]:
43+
run_command(f"bash {DRIVERS_TOOLS}/.evergreen/atlas/teardown-atlas-cluster.sh")
44+
4145
# Tear down auth_aws if applicable.
4246
# We do not run web-identity hosts on macos, because the hosts lack permissions,
4347
# so there is no reason to run the teardown, which would error with a 401.

0 commit comments

Comments
 (0)