PYTHON-3884 Replace uses of run-test.sh with tox (#1333)
This commit is contained in:
parent
e0b8b36f41
commit
b8c1364368
@ -359,7 +359,8 @@ functions:
|
||||
script: |
|
||||
set -o xtrace
|
||||
${PREPARE_SHELL}
|
||||
bash ${PROJECT_DIRECTORY}/.evergreen/tox.sh ${PYTHON_BINARY} -m test-mockupdb
|
||||
export PYTHON_BINARY=${PYTHON_BINARY}
|
||||
bash ${PROJECT_DIRECTORY}/.evergreen/tox.sh -m test-mockupdb
|
||||
|
||||
"run doctests":
|
||||
- command: shell.exec
|
||||
@ -379,7 +380,7 @@ functions:
|
||||
if [ -n "${test_encryption}" ]; then
|
||||
${PREPARE_SHELL}
|
||||
cd ${DRIVERS_TOOLS}/.evergreen/csfle
|
||||
. ./activate_venv.sh
|
||||
. ./activate-kmstlsvenv.sh
|
||||
fi
|
||||
# Run in the background so the mock servers don't block the EVG task.
|
||||
- command: shell.exec
|
||||
@ -389,7 +390,7 @@ functions:
|
||||
if [ -n "${test_encryption}" ]; then
|
||||
${PREPARE_SHELL}
|
||||
cd ${DRIVERS_TOOLS}/.evergreen/csfle
|
||||
. ./activate_venv.sh
|
||||
. ./activate-kmstlsvenv.sh
|
||||
# The -u options forces the stdout and stderr streams to be unbuffered.
|
||||
# TMPDIR is required to avoid "AF_UNIX path too long" errors.
|
||||
TMPDIR="$(dirname $DRIVERS_TOOLS)" python -u kms_kmip_server.py --ca_file ../x509gen/ca.pem --cert_file ../x509gen/server.pem --port 5698 &
|
||||
@ -404,7 +405,7 @@ functions:
|
||||
if [ -n "${test_encryption}" ]; then
|
||||
${PREPARE_SHELL}
|
||||
cd ${DRIVERS_TOOLS}/.evergreen/csfle
|
||||
. ./activate_venv.sh
|
||||
. ./activate-kmstlsvenv.sh
|
||||
for i in $(seq 1 1 10); do
|
||||
sleep 1
|
||||
if python -u kms_kmip_client.py; then
|
||||
@ -441,8 +442,8 @@ functions:
|
||||
params:
|
||||
working_dir: "src"
|
||||
script: |
|
||||
set -o xtrace
|
||||
if [ -n "${set_xtrace_on}" ]; then
|
||||
set -o xtrace
|
||||
export SET_XTRACE_ON="${set_xtrace_on}"
|
||||
fi
|
||||
${PREPARE_SHELL}
|
||||
@ -488,17 +489,20 @@ functions:
|
||||
export MULTI_MONGOS_LB_URI="${MONGODB_URI}"
|
||||
fi
|
||||
|
||||
MONGODB_VERSION=${VERSION} \
|
||||
PYTHON_BINARY=${PYTHON_BINARY} \
|
||||
GREEN_FRAMEWORK=${GREEN_FRAMEWORK} \
|
||||
export PYTHON_BINARY=${PYTHON_BINARY}
|
||||
if [ -z "$PYTHON_BINARY" ]; then
|
||||
export PYTHON_BINARY=${python3_binary}
|
||||
fi
|
||||
|
||||
GREEN_FRAMEWORK=${GREEN_FRAMEWORK} \
|
||||
C_EXTENSIONS=${C_EXTENSIONS} \
|
||||
COVERAGE=${COVERAGE} \
|
||||
COMPRESSORS=${COMPRESSORS} \
|
||||
AUTH=${AUTH} \
|
||||
SSL=${SSL} \
|
||||
DATA_LAKE=${DATA_LAKE} \
|
||||
TEST_DATA_LAKE=${TEST_DATA_LAKE} \
|
||||
MONGODB_API_VERSION=${MONGODB_API_VERSION} \
|
||||
bash ${PROJECT_DIRECTORY}/.evergreen/run-tests.sh
|
||||
bash ${PROJECT_DIRECTORY}/.evergreen/tox.sh -m test-eg
|
||||
|
||||
"run enterprise auth tests":
|
||||
- command: shell.exec
|
||||
@ -1198,6 +1202,7 @@ task_groups:
|
||||
SERVERLESS_API_PRIVATE_KEY=${SERVERLESS_API_PRIVATE_KEY} \
|
||||
SERVERLESS_INSTANCE_NAME=${SERVERLESS_INSTANCE_NAME} \
|
||||
bash ${DRIVERS_TOOLS}/.evergreen/serverless/delete-instance.sh
|
||||
- func: "upload test results"
|
||||
tasks:
|
||||
- ".serverless"
|
||||
|
||||
@ -1235,52 +1240,54 @@ task_groups:
|
||||
export GCPKMS_ZONE=${GCPKMS_ZONE}
|
||||
export GCPKMS_INSTANCENAME=${GCPKMS_INSTANCENAME}
|
||||
$DRIVERS_TOOLS/.evergreen/csfle/gcpkms/delete-instance.sh
|
||||
- func: "upload test results"
|
||||
tasks:
|
||||
- testgcpkms-task
|
||||
|
||||
- name: testazurekms_task_group
|
||||
setup_group:
|
||||
- func: fetch source
|
||||
- func: prepare resources
|
||||
- func: fix absolute paths
|
||||
- func: make files executable
|
||||
- command: shell.exec
|
||||
params:
|
||||
silent: true
|
||||
shell: bash
|
||||
script: |-
|
||||
set -o errexit
|
||||
${PREPARE_SHELL}
|
||||
echo '${testazurekms_publickey}' > /tmp/testazurekms_publickey
|
||||
echo '${testazurekms_privatekey}' > /tmp/testazurekms_privatekey
|
||||
# Set 600 permissions on private key file. Otherwise ssh / scp may error with permissions "are too open".
|
||||
chmod 600 /tmp/testazurekms_privatekey
|
||||
export AZUREKMS_CLIENTID="${testazurekms_clientid}"
|
||||
export AZUREKMS_TENANTID="${testazurekms_tenantid}"
|
||||
export AZUREKMS_SECRET="${testazurekms_secret}"
|
||||
export AZUREKMS_DRIVERS_TOOLS="$DRIVERS_TOOLS"
|
||||
export AZUREKMS_RESOURCEGROUP="${testazurekms_resourcegroup}"
|
||||
export AZUREKMS_PUBLICKEYPATH="/tmp/testazurekms_publickey"
|
||||
export AZUREKMS_PRIVATEKEYPATH="/tmp/testazurekms_privatekey"
|
||||
export AZUREKMS_SCOPE="${testazurekms_scope}"
|
||||
export AZUREKMS_VMNAME_PREFIX="PYTHON_DRIVER"
|
||||
$DRIVERS_TOOLS/.evergreen/csfle/azurekms/create-and-setup-vm.sh
|
||||
- command: expansions.update
|
||||
params:
|
||||
file: testazurekms-expansions.yml
|
||||
- func: fetch source
|
||||
- func: prepare resources
|
||||
- func: fix absolute paths
|
||||
- func: make files executable
|
||||
- command: shell.exec
|
||||
params:
|
||||
silent: true
|
||||
shell: bash
|
||||
script: |-
|
||||
set -o errexit
|
||||
${PREPARE_SHELL}
|
||||
echo '${testazurekms_publickey}' > /tmp/testazurekms_publickey
|
||||
echo '${testazurekms_privatekey}' > /tmp/testazurekms_privatekey
|
||||
# Set 600 permissions on private key file. Otherwise ssh / scp may error with permissions "are too open".
|
||||
chmod 600 /tmp/testazurekms_privatekey
|
||||
export AZUREKMS_CLIENTID="${testazurekms_clientid}"
|
||||
export AZUREKMS_TENANTID="${testazurekms_tenantid}"
|
||||
export AZUREKMS_SECRET="${testazurekms_secret}"
|
||||
export AZUREKMS_DRIVERS_TOOLS="$DRIVERS_TOOLS"
|
||||
export AZUREKMS_RESOURCEGROUP="${testazurekms_resourcegroup}"
|
||||
export AZUREKMS_PUBLICKEYPATH="/tmp/testazurekms_publickey"
|
||||
export AZUREKMS_PRIVATEKEYPATH="/tmp/testazurekms_privatekey"
|
||||
export AZUREKMS_SCOPE="${testazurekms_scope}"
|
||||
export AZUREKMS_VMNAME_PREFIX="PYTHON_DRIVER"
|
||||
$DRIVERS_TOOLS/.evergreen/csfle/azurekms/create-and-setup-vm.sh
|
||||
- command: expansions.update
|
||||
params:
|
||||
file: testazurekms-expansions.yml
|
||||
teardown_group:
|
||||
# Load expansions again. The setup task may have failed before running `expansions.update`.
|
||||
- command: expansions.update
|
||||
params:
|
||||
file: testazurekms-expansions.yml
|
||||
- command: shell.exec
|
||||
params:
|
||||
shell: bash
|
||||
script: |-
|
||||
${PREPARE_SHELL}
|
||||
export AZUREKMS_VMNAME=${AZUREKMS_VMNAME}
|
||||
export AZUREKMS_RESOURCEGROUP=${testazurekms_resourcegroup}
|
||||
$DRIVERS_TOOLS/.evergreen/csfle/azurekms/delete-vm.sh
|
||||
# Load expansions again. The setup task may have failed before running `expansions.update`.
|
||||
- command: expansions.update
|
||||
params:
|
||||
file: testazurekms-expansions.yml
|
||||
- command: shell.exec
|
||||
params:
|
||||
shell: bash
|
||||
script: |-
|
||||
${PREPARE_SHELL}
|
||||
export AZUREKMS_VMNAME=${AZUREKMS_VMNAME}
|
||||
export AZUREKMS_RESOURCEGROUP=${testazurekms_resourcegroup}
|
||||
$DRIVERS_TOOLS/.evergreen/csfle/azurekms/delete-vm.sh
|
||||
- func: "upload test results"
|
||||
setup_group_can_fail_task: true
|
||||
setup_group_timeout_secs: 1800
|
||||
tasks:
|
||||
@ -1716,7 +1723,7 @@ tasks:
|
||||
- func: "bootstrap data lake"
|
||||
- func: "run tests"
|
||||
vars:
|
||||
DATA_LAKE: "true"
|
||||
TEST_DATA_LAKE: "true"
|
||||
|
||||
- name: test-ocsp-rsa-valid-cert-server-staples
|
||||
tags: ["ocsp", "ocsp-rsa", "ocsp-staple"]
|
||||
@ -2229,7 +2236,7 @@ tasks:
|
||||
export GCPKMS_PROJECT=${GCPKMS_PROJECT}
|
||||
export GCPKMS_ZONE=${GCPKMS_ZONE}
|
||||
export GCPKMS_INSTANCENAME=${GCPKMS_INSTANCENAME}
|
||||
GCPKMS_CMD="SUCCESS=true TEST_FLE_GCP_AUTO=1 LIBMONGOCRYPT_URL=https://s3.amazonaws.com/mciuploads/libmongocrypt/debian10/master/latest/libmongocrypt.tar.gz ./.evergreen/run-tests.sh" $DRIVERS_TOOLS/.evergreen/csfle/gcpkms/run-command.sh
|
||||
GCPKMS_CMD="SUCCESS=true TEST_FLE_GCP_AUTO=1 LIBMONGOCRYPT_URL=https://s3.amazonaws.com/mciuploads/libmongocrypt/debian10/master/latest/libmongocrypt.tar.gz ./.evergreen/tox.sh -m test-eg" $DRIVERS_TOOLS/.evergreen/csfle/gcpkms/run-command.sh
|
||||
|
||||
- name: "testgcpkms-fail-task"
|
||||
# testgcpkms-fail-task runs in a non-GCE environment.
|
||||
@ -2248,7 +2255,7 @@ tasks:
|
||||
${PREPARE_SHELL}
|
||||
export PYTHON_BINARY=/opt/mongodbtoolchain/v4/bin/python3
|
||||
export LIBMONGOCRYPT_URL=https://s3.amazonaws.com/mciuploads/libmongocrypt/debian10/master/latest/libmongocrypt.tar.gz
|
||||
SUCCESS=false TEST_FLE_GCP_AUTO=1 ./.evergreen/run-tests.sh
|
||||
SUCCESS=false TEST_FLE_GCP_AUTO=1 ./.evergreen/tox.sh -m test-eg
|
||||
|
||||
- name: testazurekms-task
|
||||
commands:
|
||||
@ -2282,7 +2289,7 @@ tasks:
|
||||
export AZUREKMS_RESOURCEGROUP=${testazurekms_resourcegroup}
|
||||
export AZUREKMS_VMNAME=${AZUREKMS_VMNAME}
|
||||
export AZUREKMS_PRIVATEKEYPATH=/tmp/testazurekms_privatekey
|
||||
AZUREKMS_CMD="KEY_NAME='${testazurekms_keyname}' KEY_VAULT_ENDPOINT='${testazurekms_keyvaultendpoint}' LIBMONGOCRYPT_URL=https://s3.amazonaws.com/mciuploads/libmongocrypt/debian10/master/latest/libmongocrypt.tar.gz SUCCESS=true TEST_FLE_AZURE_AUTO=1 ./.evergreen/run-tests.sh" \
|
||||
AZUREKMS_CMD="KEY_NAME='${testazurekms_keyname}' KEY_VAULT_ENDPOINT='${testazurekms_keyvaultendpoint}' LIBMONGOCRYPT_URL=https://s3.amazonaws.com/mciuploads/libmongocrypt/debian10/master/latest/libmongocrypt.tar.gz SUCCESS=true TEST_FLE_AZURE_AUTO=1 ./.evergreen/tox.sh -m test-eg" \
|
||||
$DRIVERS_TOOLS/.evergreen/csfle/azurekms/run-command.sh
|
||||
|
||||
- name: testazurekms-fail-task
|
||||
@ -2306,7 +2313,7 @@ tasks:
|
||||
KEY_VAULT_ENDPOINT='${testazurekms_keyvaultendpoint}' \
|
||||
LIBMONGOCRYPT_URL=https://s3.amazonaws.com/mciuploads/libmongocrypt/debian10/master/latest/libmongocrypt.tar.gz \
|
||||
SUCCESS=false TEST_FLE_AZURE_AUTO=1 \
|
||||
./.evergreen/run-tests.sh
|
||||
./.evergreen/tox.sh -m test-eg
|
||||
|
||||
axes:
|
||||
# Choice of distro
|
||||
|
||||
@ -1,17 +1,26 @@
|
||||
#!/bin/bash
|
||||
set -o errexit # Exit the script with error if any of the commands fail
|
||||
|
||||
# Note: It is assumed that you have already set up a virtual environment before running this file.
|
||||
|
||||
# Supported/used environment variables:
|
||||
# SET_XTRACE_ON Set to non-empty to write all commands first to stderr.
|
||||
# AUTH Set to enable authentication. Defaults to "noauth"
|
||||
# SSL Set to enable SSL. Defaults to "nossl"
|
||||
# PYTHON_BINARY The Python version to use. Defaults to whatever is available
|
||||
# GREEN_FRAMEWORK The green framework to test with, if any.
|
||||
# C_EXTENSIONS Pass --no_ext to setup.py, or not.
|
||||
# COVERAGE If non-empty, run the test suite with coverage.
|
||||
# TEST_ENCRYPTION If non-empty, install pymongocrypt.
|
||||
# LIBMONGOCRYPT_URL The URL to download libmongocrypt.
|
||||
# TEST_CRYPT_SHARED If non-empty, install crypt_shared lib.
|
||||
# SET_XTRACE_ON Set to non-empty to write all commands first to stderr.
|
||||
# AUTH Set to enable authentication. Defaults to "noauth"
|
||||
# SSL Set to enable SSL. Defaults to "nossl"
|
||||
# GREEN_FRAMEWORK The green framework to test with, if any.
|
||||
# C_EXTENSIONS If non-empty, c extensions are enabled.
|
||||
# COVERAGE If non-empty, run the test suite with coverage.
|
||||
# COMPRESSORS If non-empty, install appropriate compressor.
|
||||
# LIBMONGOCRYPT_URL The URL to download libmongocrypt.
|
||||
# TEST_DATA_LAKE If non-empty, run data lake tests.
|
||||
# TEST_ENCRYPTION If non-empty, run encryption tests.
|
||||
# TEST_CRYPT_SHARED If non-empty, install crypt_shared lib.
|
||||
# TEST_SERVERLESS If non-empy, test on serverless.
|
||||
# TEST_LOADBALANCER If non-empy, test load balancing.
|
||||
# TEST_FLE_AZURE_AUTO If non-empy, test auto FLE on Azure
|
||||
# TEST_FLE_GCP_AUTO If non-empy, test auto FLE on GCP
|
||||
# TEST_PYOPENSSL If non-empy, test with PyOpenSSL
|
||||
# TEST_ENCRYPTION_PYOPENSSL If non-empy, test encryption with PyOpenSSL
|
||||
|
||||
if [ -n "${SET_XTRACE_ON}" ]; then
|
||||
set -o xtrace
|
||||
@ -21,29 +30,13 @@ fi
|
||||
|
||||
AUTH=${AUTH:-noauth}
|
||||
SSL=${SSL:-nossl}
|
||||
PYTHON_BINARY=${PYTHON_BINARY:-}
|
||||
GREEN_FRAMEWORK=${GREEN_FRAMEWORK:-}
|
||||
C_EXTENSIONS=${C_EXTENSIONS:-}
|
||||
COVERAGE=${COVERAGE:-}
|
||||
COMPRESSORS=${COMPRESSORS:-}
|
||||
MONGODB_VERSION=${MONGODB_VERSION:-}
|
||||
MONGODB_API_VERSION=${MONGODB_API_VERSION:-}
|
||||
TEST_ENCRYPTION=${TEST_ENCRYPTION:-}
|
||||
CRYPT_SHARED_LIB_PATH=${CRYPT_SHARED_LIB_PATH:-}
|
||||
LIBMONGOCRYPT_URL=${LIBMONGOCRYPT_URL:-}
|
||||
DATA_LAKE=${DATA_LAKE:-}
|
||||
TEST_ARGS=""
|
||||
TEST_ARGS="$1"
|
||||
PYTHON=$(which python)
|
||||
|
||||
if [ -n "$COMPRESSORS" ]; then
|
||||
export COMPRESSORS=$COMPRESSORS
|
||||
fi
|
||||
|
||||
if [ -n "$MONGODB_API_VERSION" ]; then
|
||||
export MONGODB_API_VERSION=$MONGODB_API_VERSION
|
||||
fi
|
||||
python -c "import sys; sys.exit(sys.prefix == sys.base_prefix)" || (echo "Not inside a virtual env!"; exit 1)
|
||||
|
||||
if [ "$AUTH" != "noauth" ]; then
|
||||
if [ ! -z "$DATA_LAKE" ]; then
|
||||
if [ ! -z "$TEST_DATA_LAKE" ]; then
|
||||
export DB_USER="mhuser"
|
||||
export DB_PASSWORD="pencil"
|
||||
elif [ ! -z "$TEST_SERVERLESS" ]; then
|
||||
@ -65,47 +58,31 @@ if [ "$SSL" != "nossl" ]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
# For createvirtualenv.
|
||||
. .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=$(command -v python3)
|
||||
elif is_python_37 "$(command -v /opt/mongodbtoolchain/v3/bin/python3)"; then
|
||||
PYTHON=$(command -v /opt/mongodbtoolchain/v3/bin/python3)
|
||||
else
|
||||
echo "Cannot test without python3.7+ installed!"
|
||||
fi
|
||||
elif [ "$COMPRESSORS" = "snappy" ]; then
|
||||
createvirtualenv $PYTHON_BINARY snappytest
|
||||
trap "deactivate; rm -rf snappytest" EXIT HUP
|
||||
python -m pip install python-snappy
|
||||
if [ "$COMPRESSORS" = "snappy" ]; then
|
||||
pip install '.[snappy]'
|
||||
PYTHON=python
|
||||
elif [ "$COMPRESSORS" = "zstd" ]; then
|
||||
createvirtualenv $PYTHON_BINARY zstdtest
|
||||
trap "deactivate; rm -rf zstdtest" EXIT HUP
|
||||
python -m pip install zstandard
|
||||
PYTHON=python
|
||||
else
|
||||
PYTHON="$PYTHON_BINARY"
|
||||
pip install zstandard
|
||||
fi
|
||||
|
||||
# PyOpenSSL test setup.
|
||||
if [ -n "$TEST_PYOPENSSL" ]; then
|
||||
createvirtualenv $PYTHON pyopenssltest
|
||||
trap "deactivate; rm -rf pyopenssltest" EXIT HUP
|
||||
PYTHON=python
|
||||
|
||||
python -m pip install --prefer-binary pyopenssl requests service_identity
|
||||
pip install '.[ocsp]'
|
||||
fi
|
||||
|
||||
if [ -n "$TEST_ENCRYPTION" ] || [ -n "$TEST_FLE_AZURE_AUTO" ] || [ -n "$TEST_FLE_GCP_AUTO" ]; then
|
||||
|
||||
createvirtualenv $PYTHON venv-encryption
|
||||
trap "deactivate; rm -rf venv-encryption" EXIT HUP
|
||||
PYTHON=python
|
||||
# Work around for root certifi not being installed.
|
||||
# TODO: Remove after PYTHON-3827
|
||||
if [ "$(uname -s)" = "Darwin" ]; then
|
||||
pip install certifi
|
||||
CERT_PATH=$(python -c "import certifi; print(certifi.where())")
|
||||
export SSL_CERT_FILE=${CERT_PATH}
|
||||
export REQUESTS_CA_BUNDLE=${CERT_PATH}
|
||||
export AWS_CA_BUNDLE=${CERT_PATH}
|
||||
fi
|
||||
|
||||
pip install '.[encryption]'
|
||||
|
||||
if [ "Windows_NT" = "$OS" ]; then # Magic variable in cygwin
|
||||
# PYTHON-2808 Ensure this machine has the CA cert for google KMS.
|
||||
@ -150,11 +127,8 @@ if [ -n "$TEST_ENCRYPTION" ] || [ -n "$TEST_FLE_AZURE_AUTO" ] || [ -n "$TEST_FLE
|
||||
fi
|
||||
|
||||
if [ -n "$TEST_ENCRYPTION" ]; then
|
||||
# Need aws dependency for On-Demand KMS Credentials.
|
||||
if [ -n "$TEST_ENCRYPTION_PYOPENSSL" ]; then
|
||||
python -m pip install '.[aws,ocsp]'
|
||||
else
|
||||
python -m pip install '.[aws]'
|
||||
pip install '.[ocsp]'
|
||||
fi
|
||||
|
||||
# Get access to the AWS temporary credentials:
|
||||
@ -169,7 +143,9 @@ if [ -n "$TEST_ENCRYPTION" ]; then
|
||||
export PATH=$CRYPT_SHARED_DIR:$PATH
|
||||
fi
|
||||
# Only run the encryption tests.
|
||||
TEST_ARGS="-s test.test_encryption"
|
||||
if [ -z "$TEST_ARGS" ]; then
|
||||
TEST_ARGS="test/test_encryption.py"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "$TEST_FLE_AZURE_AUTO" ] || [ -n "$TEST_FLE_GCP_AUTO" ]; then
|
||||
@ -183,27 +159,17 @@ if [ -n "$TEST_FLE_AZURE_AUTO" ] || [ -n "$TEST_FLE_GCP_AUTO" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
TEST_ARGS="-s test.test_on_demand_csfle"
|
||||
fi
|
||||
|
||||
if [ -n "$DATA_LAKE" ]; then
|
||||
TEST_ARGS="-s test.test_data_lake"
|
||||
fi
|
||||
|
||||
# Don't download unittest-xml-reporting from pypi, which often fails.
|
||||
if $PYTHON -c "import xmlrunner"; then
|
||||
# The xunit output dir must be a Python style absolute path.
|
||||
XUNIT_DIR="$(pwd)/xunit-results"
|
||||
if [ "Windows_NT" = "$OS" ]; then # Magic variable in cygwin
|
||||
XUNIT_DIR=$(cygpath -m $XUNIT_DIR)
|
||||
if [ -z "$TEST_ARGS" ]; then
|
||||
TEST_ARGS="test/test_on_demand_csfle.py"
|
||||
fi
|
||||
OUTPUT="--xunit-output=${XUNIT_DIR}"
|
||||
else
|
||||
OUTPUT=""
|
||||
fi
|
||||
|
||||
if [ -n "$TEST_DATA_LAKE" ] && [ -z "$TEST_ARGS" ]; then
|
||||
TEST_ARGS="test/test_data_lake.py"
|
||||
fi
|
||||
|
||||
echo "Running $AUTH tests over $SSL with python $PYTHON"
|
||||
$PYTHON -c 'import sys; print(sys.version)'
|
||||
python -c 'import sys; print(sys.version)'
|
||||
|
||||
# Run the tests, and store the results in Evergreen compatible XUnit XML
|
||||
# files in the xunit-results/ directory.
|
||||
@ -211,32 +177,21 @@ $PYTHON -c 'import sys; print(sys.version)'
|
||||
# Run the tests with coverage if requested and coverage is installed.
|
||||
# Only cover CPython. PyPy reports suspiciously low coverage.
|
||||
PYTHON_IMPL=$($PYTHON -c "import platform; print(platform.python_implementation())")
|
||||
COVERAGE_ARGS=""
|
||||
if [ -n "$COVERAGE" ] && [ "$PYTHON_IMPL" = "CPython" ]; then
|
||||
if $PYTHON -m coverage --version; then
|
||||
echo "INFO: coverage is installed, running tests with coverage..."
|
||||
COVERAGE_ARGS="-m coverage run --branch"
|
||||
else
|
||||
echo "INFO: coverage is not installed, running tests without coverage..."
|
||||
fi
|
||||
python -m pip install pytest-cov
|
||||
TEST_ARGS="$TEST_ARGS --cov pymongo --cov-branch --cov-report term-missing:skip-covered"
|
||||
fi
|
||||
|
||||
$PYTHON setup.py clean
|
||||
if [ -z "$GREEN_FRAMEWORK" ]; then
|
||||
if [ -z "$C_EXTENSIONS" ] && [ "$PYTHON_IMPL" = "CPython" ]; then
|
||||
# Fail if the C extensions fail to build.
|
||||
|
||||
# This always sets 0 for exit status, even if the build fails, due
|
||||
# to our hack to install PyMongo without C extensions when build
|
||||
# deps aren't available.
|
||||
$PYTHON setup.py build_ext -i
|
||||
python setup.py build_ext -i
|
||||
# This will set a non-zero exit status if either import fails,
|
||||
# causing this script to exit.
|
||||
$PYTHON -c "from bson import _cbson; from pymongo import _cmessage"
|
||||
python -c "from bson import _cbson; from pymongo import _cmessage"
|
||||
fi
|
||||
|
||||
$PYTHON $COVERAGE_ARGS setup.py $C_EXTENSIONS test $TEST_ARGS $OUTPUT
|
||||
python -m pytest $TEST_ARGS
|
||||
else
|
||||
# --no_ext has to come before "test" so there is no way to toggle extensions here.
|
||||
$PYTHON green_framework_test.py $GREEN_FRAMEWORK $OUTPUT
|
||||
python -m pip install $GREEN_FRAMEWORK
|
||||
python green_framework_test.py $GREEN_FRAMEWORK
|
||||
fi
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
cffi>=1.12.0,<2
|
||||
cryptography>=2.5
|
||||
# boto3 is required by drivers-evergreen-tools/.evergreen/csfle/set-temp-creds.sh
|
||||
boto3<2
|
||||
|
||||
@ -1,10 +1,20 @@
|
||||
#!/bin/bash
|
||||
set -o errexit # Exit the script with error if any of the commands fail
|
||||
|
||||
PYTHON_BINARY="$1"
|
||||
|
||||
. .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
|
||||
fi
|
||||
|
||||
if $PYTHON_BINARY -m tox --version; then
|
||||
run_tox() {
|
||||
$PYTHON_BINARY -m tox "$@"
|
||||
@ -18,4 +28,4 @@ else # No toolchain present, set up virtualenv before installing tox
|
||||
}
|
||||
fi
|
||||
|
||||
run_tox "${@:2}"
|
||||
run_tox "${@:1}"
|
||||
|
||||
@ -30,7 +30,7 @@ createvirtualenv () {
|
||||
fi
|
||||
|
||||
python -m pip install --upgrade pip
|
||||
python -m pip install --upgrade setuptools wheel
|
||||
python -m pip install --upgrade setuptools wheel tox
|
||||
# lxml only has wheels for macos 10.15+
|
||||
python -m pip install unittest-xml-reporting || true
|
||||
}
|
||||
|
||||
@ -17,6 +17,8 @@
|
||||
import getopt
|
||||
import sys
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
def run_gevent():
|
||||
"""Prepare to run tests with Gevent. Can raise ImportError."""
|
||||
@ -58,8 +60,7 @@ def run(framework_name, *args):
|
||||
FRAMEWORKS[framework_name]()
|
||||
|
||||
# Run the tests.
|
||||
sys.argv[:] = ["setup.py", "test"] + list(args)
|
||||
import setup # noqa
|
||||
sys.exit(pytest.main(list(args)))
|
||||
|
||||
|
||||
def main():
|
||||
@ -100,7 +101,7 @@ python %s --help-frameworks.""" % (
|
||||
|
||||
run(
|
||||
args[0], *args[1:] # Framework name.
|
||||
) # Command line args to setup.py, like what test to run.
|
||||
) # Command line args to pytest, like what test to run.
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@ -15,6 +15,7 @@
|
||||
"""A CPython compatible SSLContext implementation wrapping PyOpenSSL's
|
||||
context.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import socket as _socket
|
||||
import ssl as _stdlibssl
|
||||
|
||||
@ -50,6 +50,7 @@ aws = [
|
||||
encryption = [
|
||||
"pymongo[aws]",
|
||||
"pymongocrypt>=1.6.0,<2.0.0",
|
||||
"certifi;os.name=='nt' or sys_platform=='darwin'",
|
||||
]
|
||||
gssapi = [
|
||||
"pykerberos;os.name!='nt'",
|
||||
|
||||
2
setup.py
2
setup.py
@ -175,7 +175,7 @@ ext_modules = [
|
||||
]
|
||||
|
||||
|
||||
if "--no_ext" in sys.argv or "NO_EXT" in os.environ:
|
||||
if "--no_ext" in sys.argv or os.environ.get("NO_EXT"):
|
||||
sys.argv.remove("--no_ext")
|
||||
ext_modules = []
|
||||
elif sys.platform.startswith("java") or sys.platform == "cli" or "PyPy" in sys.version:
|
||||
|
||||
@ -34,9 +34,9 @@ _TEST_PATH = os.path.join(os.path.dirname(os.path.realpath(__file__)), "data_lak
|
||||
|
||||
class TestDataLakeMustConnect(IntegrationTest):
|
||||
def test_connected_to_data_lake(self):
|
||||
data_lake = os.environ.get("DATA_LAKE")
|
||||
data_lake = os.environ.get("TEST_DATA_LAKE")
|
||||
if not data_lake:
|
||||
self.skipTest("DATA_LAKE is not set")
|
||||
self.skipTest("TEST_DATA_LAKE is not set")
|
||||
|
||||
self.assertTrue(
|
||||
client_context.is_data_lake,
|
||||
|
||||
22
tox.ini
22
tox.ini
@ -1,11 +1,12 @@
|
||||
[tox]
|
||||
requires =
|
||||
tox>=4
|
||||
|
||||
envlist =
|
||||
# Test using the system Python.
|
||||
test,
|
||||
# Test the extra encryption functionality.
|
||||
test-encryption,
|
||||
# Test using the run-tests Evergreen script.
|
||||
test-eg,
|
||||
# Run pre-commit on all files.
|
||||
lint,
|
||||
# Run pre-commit on all files, including stages that require manual fixes.
|
||||
@ -27,7 +28,7 @@ envlist =
|
||||
|
||||
labels = # Use labels and -m instead of -e so that tox -m <label> fails instantly if the label does not exist
|
||||
test = test
|
||||
test-encryption = test-encryption
|
||||
test-eg = test-eg
|
||||
lint = lint
|
||||
lint-manual = lint-manual
|
||||
typecheck-mypy = typecheck-mypy
|
||||
@ -48,13 +49,16 @@ commands =
|
||||
python --version
|
||||
pytest -v {posargs}
|
||||
|
||||
[testenv:test-encryption]
|
||||
description = run base unit tests with encryption enabled
|
||||
deps = {[testenv:test]deps}
|
||||
extras = encryption
|
||||
[testenv:test-eg]
|
||||
description = run tests using run-tests.sh Evergreen script
|
||||
passenv = *
|
||||
deps =
|
||||
pytest>=7
|
||||
setuptools
|
||||
allowlist_externals =
|
||||
bash
|
||||
commands =
|
||||
python --version
|
||||
pytest -v {posargs}
|
||||
bash ./.evergreen/run-tests.sh {posargs}
|
||||
|
||||
[testenv:lint]
|
||||
description = run pre-commit
|
||||
|
||||
Loading…
Reference in New Issue
Block a user