Skip to content

Commit 2a1affe

Browse files
committed
add more files
1 parent 8025271 commit 2a1affe

File tree

4 files changed

+33
-46
lines changed

4 files changed

+33
-46
lines changed

.evergreen/scripts/run_tests.py

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@
66
import platform
77
import shutil
88
import sys
9-
import tarfile
10-
import tempfile
119
from datetime import datetime
10+
from pathlib import Path
1211
from shutil import which
1312

1413
import pytest
15-
from utils import DRIVERS_TOOLS, LOGGER, ROOT, create_archive, run_command
14+
from utils import DRIVERS_TOOLS, LOGGER, ROOT, run_command
1615

1716
AUTH = os.environ.get("AUTH", "noauth")
1817
SSL = os.environ.get("SSL", "nossl")
@@ -89,19 +88,33 @@ def handle_aws_lambda() -> None:
8988
env = os.environ.copy()
9089
target_dir = ROOT / "test/lambda"
9190
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")
91+
env.setdefault("AWS_REGION", "us-east-1")
92+
dirs = ["pymongo", "gridfs", "bson"]
93+
# Store the original .so files.
94+
before_sos = []
95+
for dname in dirs:
96+
before_sos.extend(f"{f.parent.name}/{f.name}" for f in (ROOT / dname).glob("*.so"))
97+
# Build the c extensions.
98+
docker = which("docker") or which("podman")
99+
if not docker:
100+
raise ValueError("Could not find docker!")
101+
image = "quay.io/pypa/manylinux2014_x86_64:latest"
102+
run_command(
103+
f'{docker} run --rm -v "{ROOT}:/src" --platform linux/amd64 {image} /src/test/lambda/build_internal.sh'
104+
)
105+
for dname in dirs:
106+
target = ROOT / "test/lambda/mongodb" / dname
107+
shutil.rmtree(target, ignore_errors=True)
108+
shutil.copytree(ROOT / dname, target)
109+
# Remove the original so files from the lambda directory.
110+
for so_path in before_sos:
111+
(ROOT / "test/lambda/mongodb" / so_path).unlink()
112+
# Remove the new so files from the ROOT directory.
113+
for dname in dirs:
114+
so_paths = [f"{f.parent.name}/{f.name}" for f in (ROOT / dname).glob("*.so")]
115+
for so_path in list(so_paths):
116+
if so_path not in before_sos:
117+
Path(so_path).unlink()
105118

106119
script_name = "run-deployed-lambda-aws-tests.sh"
107120
run_command(f"bash {DRIVERS_TOOLS}/.evergreen/aws_lambda/{script_name}", env=env)

.evergreen/scripts/setup_tests.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,9 @@ def handle_test_env() -> None:
182182
if test_name == "index_management":
183183
AUTH = "auth"
184184

185+
if test_name == "aws_lambda":
186+
UV_ARGS.append("--with pip")
187+
185188
if AUTH != "noauth":
186189
if test_name == "data_lake":
187190
config = read_env(f"{DRIVERS_TOOLS}/.evergreen/atlas_data_lake/secrets-export.sh")

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ mongocryptd.pid
1818
.idea/
1919
.vscode/
2020
.nova/
21+
.temp/
2122
venv/
2223
secrets-export.sh
2324
libmongocrypt.tar.gz

test/lambda/build.sh

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

0 commit comments

Comments
 (0)