Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
19dd40b
clean up python binary handling
blink1073 Sep 29, 2023
dac5f7a
fix paths
blink1073 Sep 29, 2023
f6c2a81
clean up
blink1073 Sep 29, 2023
c416506
clean up
blink1073 Sep 29, 2023
be17b0d
clean up
blink1073 Sep 29, 2023
90f62c4
clean up
blink1073 Sep 29, 2023
bc24f0b
clean up
blink1073 Sep 29, 2023
c3c9c3a
debug
blink1073 Sep 29, 2023
e02b0ba
clean up
blink1073 Sep 29, 2023
db2ab54
clean up
blink1073 Sep 29, 2023
870f531
fix aws
blink1073 Sep 29, 2023
1004553
use python3
blink1073 Sep 29, 2023
4e66acb
more cleanup
blink1073 Sep 29, 2023
423c0d2
try again
blink1073 Sep 29, 2023
93246dc
try again
blink1073 Sep 29, 2023
306c34c
try a fix for aws
blink1073 Sep 29, 2023
28efe45
try with our own functions
blink1073 Sep 30, 2023
46172b0
cleanup
blink1073 Sep 30, 2023
85a0f33
fix handling of venv
blink1073 Sep 30, 2023
a43b34c
cleanup
blink1073 Sep 30, 2023
d87e653
fixups
blink1073 Sep 30, 2023
dfbca6e
more cleanup
blink1073 Sep 30, 2023
b3fde22
more cleanup
blink1073 Sep 30, 2023
f2fd053
try virtualenv again
blink1073 Sep 30, 2023
c0a7f7c
more venv cleanup
blink1073 Sep 30, 2023
b8f86c7
more venv cleanup
blink1073 Sep 30, 2023
3c66cdb
fix use of virtualenv on macos
blink1073 Oct 3, 2023
3577a22
syntax
blink1073 Oct 3, 2023
db0346e
Merge branch 'master' of github.com:mongodb/mongo-python-driver into …
blink1073 Oct 3, 2023
4ff5a4d
fixup
blink1073 Oct 3, 2023
d39a5a0
fixup
blink1073 Oct 3, 2023
44a41ed
fixup
blink1073 Oct 3, 2023
b534e50
try this approach
blink1073 Oct 3, 2023
cfdf1be
Merge branch 'master' of github.com:mongodb/mongo-python-driver into …
blink1073 Oct 3, 2023
8d228a7
try all fixups
blink1073 Oct 4, 2023
e898c7e
fixups
blink1073 Oct 4, 2023
dcb4d22
More fixups
blink1073 Oct 4, 2023
42a956f
Merge branch 'master' of github.com:mongodb/mongo-python-driver into …
blink1073 Oct 6, 2023
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
40 changes: 1 addition & 39 deletions .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,6 @@ functions:
export PATH="$MONGODB_BINARIES:$PATH"
export PROJECT="${project}"
export PIP_QUIET=1
ENSURE_TOOLCHAIN_PYTHON_BINARY: |
# Make sure PYTHON_BINARY is set to a suitable toolchain python.
if [ -z "$PYTHON_BINARY" ]; then
if [ "$(uname -s)" = "Darwin" ]; then
export PYTHON_BINARY=/Library/Frameworks/Python.Framework/Versions/3.9/bin/python3
elif [ "Windows_NT" = "$OS" ]; then # Magic variable in cygwin
export PYTHON_BINARY=/cygdrive/c/python/Python39/python
else
export PYTHON_BINARY=/opt/python/3.9/bin/python3
fi
fi
EOT

# Load the expansion file to make an evergreen variable with the current unique version
Expand Down Expand Up @@ -502,12 +491,8 @@ functions:
export DB_PASSWORD="${DRIVERS_ATLAS_LAMBDA_PASSWORD}"
fi

export PYTHON_BINARY=${PYTHON_BINARY}
if [ -z "$PYTHON_BINARY" ]; then
export PYTHON_BINARY=${python3_binary}
fi

GREEN_FRAMEWORK=${GREEN_FRAMEWORK} \
PYTHON_BINARY=${PYTHON_BINARY} \
C_EXTENSIONS=${C_EXTENSIONS} \
COVERAGE=${COVERAGE} \
COMPRESSORS=${COMPRESSORS} \
Expand Down Expand Up @@ -678,7 +663,6 @@ functions:
include_expansions_in_env: ["AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "AWS_SESSION_TOKEN"]
script: |
${PREPARE_SHELL}
${ENSURE_TOOLCHAIN_PYTHON_BINARY}
bash .evergreen/run-mongodb-oidc-test.sh

"run aws auth test with aws credentials as environment variables":
Expand Down Expand Up @@ -1630,8 +1614,6 @@ tasks:
tags: ["no-server"]
commands:
- func: "run tests"
vars:
PYTHON_BINARY: /opt/python/3.7/bin/python3

- name: "atlas-connect"
tags: ["atlas-connect"]
Expand Down Expand Up @@ -2108,7 +2090,6 @@ tasks:
vars:
VERSION: "latest"
TOPOLOGY: "server"
PYTHON_BINARY: "/opt/mongodbtoolchain/v3/bin/python3"
- func: "run tests"
# }}}
- name: "coverage-report"
Expand Down Expand Up @@ -2260,7 +2241,6 @@ axes:
skip_EC2_auth_test: true
skip_ECS_auth_test: true
skip_web_identity_auth_test: true
python3_binary: /Library/Frameworks/Python.framework/Versions/3.8/bin/python3
libmongocrypt_url: https://s3.amazonaws.com/mciuploads/libmongocrypt/macos/master/latest/libmongocrypt.tar.gz
- id: macos-1100
display_name: "macOS 11.00"
Expand All @@ -2269,7 +2249,6 @@ axes:
skip_EC2_auth_test: true
skip_ECS_auth_test: true
skip_web_identity_auth_test: true
python3_binary: /Library/Frameworks/Python.framework/Versions/3.8/bin/python3
libmongocrypt_url: https://s3.amazonaws.com/mciuploads/libmongocrypt/macos/master/latest/libmongocrypt.tar.gz
- id: macos-1100-arm64
display_name: "macOS 11.00 Arm64"
Expand All @@ -2278,21 +2257,18 @@ axes:
skip_EC2_auth_test: true
skip_ECS_auth_test: true
skip_web_identity_auth_test: true
python3_binary: /Library/Frameworks/Python.framework/Versions/3.8/bin/python3
libmongocrypt_url: https://s3.amazonaws.com/mciuploads/libmongocrypt/macos/master/latest/libmongocrypt.tar.gz
- id: rhel7
display_name: "RHEL 7.x"
run_on: rhel79-small
batchtime: 10080 # 7 days
variables:
python3_binary: "/opt/python/3.8/bin/python3"
libmongocrypt_url: https://s3.amazonaws.com/mciuploads/libmongocrypt/rhel-70-64-bit/master/latest/libmongocrypt.tar.gz
- id: rhel8
display_name: "RHEL 8.x"
run_on: rhel87-small
batchtime: 10080 # 7 days
variables:
python3_binary: "/opt/python/3.8/bin/python3"
libmongocrypt_url: https://s3.amazonaws.com/mciuploads/libmongocrypt/rhel-80-64-bit/master/latest/libmongocrypt.tar.gz
- id: rhel80-fips
display_name: "RHEL 8.0 FIPS"
Expand All @@ -2304,14 +2280,10 @@ axes:
display_name: "Ubuntu 22.04"
run_on: ubuntu2204-small
batchtime: 10080 # 7 days
variables:
python3_binary: python3
- id: ubuntu-18.04
display_name: "Ubuntu 18.04"
run_on: ubuntu1804-small
batchtime: 10080 # 7 days
variables:
python3_binary: python3
- id: rhel83-zseries
display_name: "RHEL 8.3 (zSeries)"
run_on: rhel83-zseries-small
Expand All @@ -2334,7 +2306,6 @@ axes:
skip_ECS_auth_test: true
skip_EC2_auth_test: true
skip_web_identity_auth_test: true
python3_binary: "C:/python/Python38/python.exe"
venv_bin_dir: "Scripts"
libmongocrypt_url: https://s3.amazonaws.com/mciuploads/libmongocrypt/windows-test/master/latest/libmongocrypt.tar.gz

Expand Down Expand Up @@ -2476,14 +2447,6 @@ axes:
variables:
PYTHON_BINARY: "/opt/python/pypy3.10/bin/pypy3"

- id: python-version-mac
display_name: "Python"
values:
- id: "system-python3"
display_name: "Python3"
variables:
PYTHON_BINARY: "python3"

- id: python-version-windows
display_name: "Python"
values:
Expand Down Expand Up @@ -3166,7 +3129,6 @@ buildvariants:
- matrix_name: "aws-auth-test-mac"
matrix_spec:
platform: [macos-1014]
python-version-mac: ["system-python3"]
display_name: "MONGODB-AWS Auth ${platform} ${python-version-mac}"
tasks:
- name: "aws-auth-test-4.4"
Expand Down
3 changes: 3 additions & 0 deletions .evergreen/run-mongodb-aws-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ echo "Running MONGODB-AWS authentication tests"
# ensure no secrets are printed in log files
set +x

. ./.evergreen/utils.sh
PYTHON_BINARY=$(find_python3)

# Try to source exported AWS Secrets
if [ -f ./secrets-export.sh ]; then
source ./secrets-export.sh
Expand Down
4 changes: 2 additions & 2 deletions .evergreen/run-mongodb-oidc-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ fi

# Get the drivers secrets. Use an existing secrets file first.
if [ ! -f "./secrets-export.sh" ]; then
bash .evergreen/tox.sh -m aws-secrets -- drivers/oidc
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the rationale behind directly calling setup_secrets.sh instead of using tox?

Copy link
Member Author

Choose a reason for hiding this comment

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

Our tox env replicates the env requirements in DRIVERS_TOOLS, I think we should migrate away from it.

Copy link
Contributor

Choose a reason for hiding this comment

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

If we migrate away from the tox env, what process do we envision for running these tests locally?

Copy link
Member Author

Choose a reason for hiding this comment

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

By running the script in DET to get the secrets file, which would only have to be done infrequently.

Copy link
Contributor

Choose a reason for hiding this comment

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

Good point! Can we add that step to the local testing documentation?

Copy link
Member Author

Choose a reason for hiding this comment

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

bash ${DRIVERS_TOOLS}/.evergreen/auth_aws/setup_secrets.sh drivers/oidc
fi
source ./secrets-export.sh

# # If the file did not have our creds, get them from the vault.
if [ -z "$OIDC_ATLAS_URI_SINGLE" ]; then
bash .evergreen/tox.sh -m aws-secrets -- drivers/oidc
bash ${DRIVERS_TOOLS}/.evergreen/auth_aws/setup_secrets.sh drivers/oidc
source ./secrets-export.sh
fi

Expand Down
11 changes: 2 additions & 9 deletions .evergreen/tox.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
#!/bin/bash
set -o errexit # Exit the script with error if any of the commands fail
set -x

. .evergreen/utils.sh

if [ -z "$PYTHON_BINARY" ]; then
# Use Python 3 from the server toolchain to test on ARM, POWER or zSeries if a
# system python3 doesn't exist or exists but is older than 3.7.
if is_python_37 "$(command -v python3)"; then
PYTHON_BINARY=$(command -v python3)
elif is_python_37 "$(command -v /opt/mongodbtoolchain/v3/bin/python3)"; then
PYTHON_BINARY=$(command -v /opt/mongodbtoolchain/v3/bin/python3)
else
echo "Cannot test without python3.7+ installed!"
fi
PYTHON_BINARY=$(find_python3)
fi

if $PYTHON_BINARY -m tox --version; then
Expand Down
53 changes: 44 additions & 9 deletions .evergreen/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,59 @@

set -o xtrace

find_python3() {
PYTHON=""
# Add a fallback system python3 if it is available and Python 3.7+.
if is_python_37 "$(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.7" ]; then
PYTHON="/Library/Frameworks/Python.Framework/Versions/3.7/bin/python3"
fi
elif [ "Windows_NT" = "$OS" ]; then # Magic variable in cygwin
PYTHON="C:/python/Python37/python.exe"
else
# Prefer our own toolchain, fall back to mongodb toolchain if it has Python 3.7+.
if [ -f "/opt/python/3.7/bin/python3" ]; then
PYTHON="/opt/python/3.7/bin/python3"
elif is_python_37 "$(command -v /opt/mongodbtoolchain/v4/bin/python3)"; then
PYTHON="/opt/mongodbtoolchain/v4/bin/python3"
elif is_python_37 "$(command -v /opt/mongodbtoolchain/v3/bin/python3)"; then
PYTHON="/opt/mongodbtoolchain/v3/bin/python3"
fi
fi
if [ -z "$PYTHON" ]; then
echo "Cannot test without python3.7+ installed!"
exit 1
fi
echo "$PYTHON"
}

# Usage:
# createvirtualenv /path/to/python /output/path/for/venv
# * param1: Python binary to use for the virtualenv
# * param2: Path to the virtualenv to create
createvirtualenv () {
PYTHON=$1
VENVPATH=$2
if $PYTHON -m virtualenv --version; then
# Prefer venv
VENV="$PYTHON -m venv"
if [ "$(uname -s)" = "Darwin" ]; then
VIRTUALENV="$PYTHON -m virtualenv"
elif $PYTHON -m venv -h > /dev/null; then
# System virtualenv might not be compatible with the python3 on our path
VIRTUALENV="$PYTHON -m venv"
else
echo "Cannot test without virtualenv"
exit 1
VIRTUALENV=$(command -v virtualenv 2>/dev/null || echo "$PYTHON -m virtualenv")
VIRTUALENV="$VIRTUALENV -p $PYTHON"
fi
if ! $VENV $VENVPATH 2>/dev/null; then
# Workaround for bug in older versions of virtualenv.
$VIRTUALENV $VENVPATH 2>/dev/null || $VIRTUALENV $VENVPATH
fi
# Workaround for bug in older versions of virtualenv.
$VIRTUALENV $VENVPATH || $PYTHON -m venv $VENVPATH
if [ "Windows_NT" = "$OS" ]; then
# Workaround https://bugs.python.org/issue32451:
# mongovenv/Scripts/activate: line 3: $'\r': command not found
Expand All @@ -31,7 +66,7 @@ createvirtualenv () {

export PIP_QUIET=1
python -m pip install --upgrade pip
python -m pip install --upgrade setuptools wheel tox
python -m pip install --upgrade setuptools tox
}

# Usage:
Expand Down
6 changes: 5 additions & 1 deletion test/test_index_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,13 @@ def setUpClass(cls) -> None:
password = os.environ["DB_PASSWORD"]
cls.client = MongoClient(url, username=username, password=password)
cls.client.drop_database(_NAME)
cls.addClassCleanup(cls.client.close)
cls.db = cls.client.test_search_index_prose

@classmethod
def tearDownClass(cls):
cls.client.drop_database(_NAME)
cls.client.close()

def wait_for_ready(self, coll, name=_NAME, predicate=None):
"""Wait for a search index to be ready."""
indices: list[Mapping[str, Any]] = []
Expand Down