Merge branch 'master' of github.com:mongodb/mongo-python-driver

This commit is contained in:
Steven Silvester 2025-03-13 10:19:17 -05:00
commit dbf2bda922
No known key found for this signature in database
GPG Key ID: B1BF5EC3A8B32F91
10 changed files with 73 additions and 60 deletions

View File

@ -372,29 +372,6 @@ post:
- func: "cleanup"
task_groups:
- name: serverless_task_group
setup_group_can_fail_task: true
setup_group_timeout_secs: 1800 # 30 minutes
setup_group:
- func: "fetch source"
- func: "setup system"
- command: subprocess.exec
params:
binary: bash
env:
VAULT_NAME: ${VAULT_NAME}
args:
- ${DRIVERS_TOOLS}/.evergreen/serverless/create-instance.sh
teardown_task:
- command: subprocess.exec
params:
binary: bash
args:
- ${DRIVERS_TOOLS}/.evergreen/serverless/delete-instance.sh
- func: "upload test results"
tasks:
- ".serverless"
- name: test_aws_lambda_task_group
setup_group:
- func: fetch source
@ -445,13 +422,6 @@ tasks:
- func: "run server"
- func: "run doctests"
- name: "test-serverless"
tags: ["serverless"]
commands:
- func: "run tests"
vars:
TEST_NAME: serverless
- name: "test-enterprise-auth"
tags: ["enterprise-auth"]
commands:

View File

@ -5866,3 +5866,13 @@ tasks:
- noauth
- nossl
- sync_async
# Serverless tests
- name: test-serverless
commands:
- func: run tests
vars:
TEST_NAME: serverless
AUTH: auth
SSL: ssl
tags: [serverless]

View File

@ -1235,27 +1235,21 @@ buildvariants:
# Serverless tests
- name: serverless-rhel8-python3.9
tasks:
- name: serverless_task_group
- name: .serverless
display_name: Serverless RHEL8 Python3.9
run_on:
- rhel87-small
batchtime: 10080
expansions:
TEST_NAME: serverless
AUTH: auth
SSL: ssl
PYTHON_BINARY: /opt/python/3.9/bin/python3
- name: serverless-rhel8-python3.13
tasks:
- name: serverless_task_group
- name: .serverless
display_name: Serverless RHEL8 Python3.13
run_on:
- rhel87-small
batchtime: 10080
expansions:
TEST_NAME: serverless
AUTH: auth
SSL: ssl
PYTHON_BINARY: /opt/python/3.13/bin/python3
# Stable api tests

View File

@ -92,3 +92,24 @@ cat <<EOT > expansion.yml
DRIVERS_TOOLS: "$DRIVERS_TOOLS"
PROJECT_DIRECTORY: "$PROJECT_DIRECTORY"
EOT
# If the toolchain is available, symlink binaries to the bin dir. This has to be done
# after drivers-tools is cloned, since we might be using its binary dir.
_bin_path=""
if [ "Windows_NT" == "${OS:-}" ]; then
_bin_path="/cygdrive/c/Python/Current/Scripts"
elif [ "$(uname -s)" != "Darwin" ]; then
_bin_path="/Library/Frameworks/Python.Framework/Versions/Current/bin"
else
_bin_path="/opt/python/Current/bin"
fi
if [ -d "${_bin_path}" ]; then
_suffix=""
if [ "Windows_NT" == "${OS:-}" ]; then
_suffix=".exe"
fi
mkdir -p $PYMONGO_BIN_DIR
ln -s ${_bin_path}/just${_suffix} $PYMONGO_BIN_DIR/just${_suffix}
ln -s ${_bin_path}/uv${_suffix} $PYMONGO_BIN_DIR/uv${_suffix}
ln -s ${_bin_path}/uvx${_suffix} $PYMONGO_BIN_DIR/uvx${_suffix}
fi

View File

@ -645,8 +645,7 @@ def create_disable_test_commands_variants():
def create_serverless_variants():
host = DEFAULT_HOST
batchtime = BATCHTIME_WEEK
expansions = dict(TEST_NAME="serverless", AUTH="auth", SSL="ssl")
tasks = ["serverless_task_group"]
tasks = [".serverless"]
base_name = "Serverless"
return [
create_variant(
@ -654,7 +653,6 @@ def create_serverless_variants():
get_display_name(base_name, host, python=python),
host=host,
python=python,
expansions=expansions,
batchtime=batchtime,
)
for python in MIN_MAX_PYTHON
@ -951,6 +949,14 @@ def create_ocsp_tasks():
return tasks
def create_serverless_tasks():
vars = dict(TEST_NAME="serverless", AUTH="auth", SSL="ssl")
test_func = FunctionCall(func="run tests", vars=vars)
tags = ["serverless"]
task_name = "test-serverless"
return [EvgTask(name=task_name, tags=tags, commands=[test_func])]
##################
# Generate Config
##################

View File

@ -24,10 +24,14 @@ function _pip_install() {
echo "Installing $2 using pip..."
createvirtualenv "$(find_python3)" $_VENV_PATH
python -m pip install $1
_suffix=""
if [ "Windows_NT" = "${OS:-}" ]; then
ln -s "$(which $2)" $_BIN_DIR/$2.exe
else
ln -s "$(which $2)" $_BIN_DIR/$2
_suffix=".exe"
fi
ln -s "$(which $2)" $_BIN_DIR/${2}${_suffix}
# uv also comes with a uvx binary.
if [ $2 == "uv" ]; then
ln -s "$(which uvx)" $_BIN_DIR/uvx${_suffix}
fi
echo "Installed to ${_BIN_DIR}"
echo "Installing $2 using pip... done."

View File

@ -174,6 +174,7 @@ def handle_test_env() -> None:
DB_USER = config["ADL_USERNAME"]
DB_PASSWORD = config["ADL_PASSWORD"]
elif test_name == "serverless":
run_command(f"bash {DRIVERS_TOOLS}/.evergreen/serverless/setup.sh")
config = read_env(f"{DRIVERS_TOOLS}/.evergreen/serverless/secrets-export.sh")
DB_USER = config["SERVERLESS_ATLAS_USER"]
DB_PASSWORD = config["SERVERLESS_ATLAS_PASSWORD"]

View File

@ -32,7 +32,11 @@ elif TEST_NAME == "auth_oidc":
# Tear down ocsp if applicable.
elif TEST_NAME == "ocsp":
run_command(f"bash {DRIVERS_TOOLS}/.evergreen/teardown.sh")
run_command(f"bash {DRIVERS_TOOLS}/.evergreen/ocsp/teardown.sh")
# Tear down serverless if applicable.
elif TEST_NAME == "serverless":
run_command(f"bash {DRIVERS_TOOLS}/.evergreen/serverless/teardown.sh")
# Tear down auth_aws if applicable.
# We do not run web-identity hosts on macos, because the hosts lack permissions,

View File

@ -137,7 +137,12 @@ def run_command(cmd: str | list[str], **kwargs: Any) -> None:
cmd = " ".join(cmd)
LOGGER.info("Running command '%s'...", cmd)
kwargs.setdefault("check", True)
subprocess.run(shlex.split(cmd), **kwargs) # noqa: PLW1510, S603
try:
subprocess.run(shlex.split(cmd), **kwargs) # noqa: PLW1510, S603
except subprocess.CalledProcessError as e:
LOGGER.error(e.output)
LOGGER.error(str(e))
sys.exit(e.returncode)
LOGGER.info("Running command '%s'... done.", cmd)

View File

@ -4,31 +4,29 @@ set -eu
find_python3() {
PYTHON=""
# Add a fallback system python3 if it is available and Python 3.9+.
if is_python_39 "$(command -v python3)"; then
PYTHON="$(command -v python3)"
fi
# Find a suitable toolchain version, if available.
if [ "$(uname -s)" = "Darwin" ]; then
# macos 11.00
if [ -d "/Library/Frameworks/Python.Framework/Versions/3.10" ]; then
PYTHON="/Library/Frameworks/Python.Framework/Versions/3.10/bin/python3"
# macos 10.14
elif [ -d "/Library/Frameworks/Python.Framework/Versions/3.9" ]; then
PYTHON="/Library/Frameworks/Python.Framework/Versions/3.9/bin/python3"
fi
PYTHON="/Library/Frameworks/Python.Framework/Versions/Current/bin/python3"
elif [ "Windows_NT" = "${OS:-}" ]; then # Magic variable in cygwin
PYTHON="C:/python/Python39/python.exe"
PYTHON="C:/python/Current/python.exe"
else
# Prefer our own toolchain, fall back to mongodb toolchain if it has Python 3.9+.
if [ -f "/opt/python/3.9/bin/python3" ]; then
PYTHON="/opt/python/3.9/bin/python3"
if [ -f "/opt/python/Current/bin/python3" ]; then
PYTHON="/opt/python/Current/bin/python3"
elif is_python_39 "$(command -v /opt/mongodbtoolchain/v5/bin/python3)"; then
PYTHON="/opt/mongodbtoolchain/v5/bin/python3"
elif is_python_39 "$(command -v /opt/mongodbtoolchain/v4/bin/python3)"; then
PYTHON="/opt/mongodbtoolchain/v4/bin/python3"
elif is_python_39 "$(command -v /opt/mongodbtoolchain/v3/bin/python3)"; then
PYTHON="/opt/mongodbtoolchain/v3/bin/python3"
fi
fi
# Add a fallback system python3 if it is available and Python 3.9+.
if [ -z "$PYTHON" ]; then
if is_python_39 "$(command -v python3)"; then
PYTHON="$(command -v python3)"
fi
fi
if [ -z "$PYTHON" ]; then
echo "Cannot test without python3.9+ installed!"
exit 1