Skip to content

Commit a8f626d

Browse files
authored
PYTHON-2608 Fix KMS TLS testing on Python <3.5 (#671)
1 parent d5aa6d9 commit a8f626d

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

.evergreen/config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,7 @@ functions:
426426
fi
427427
428428
PYTHON_BINARY=${PYTHON_BINARY} \
429+
PYTHON3_BINARY=${python3_binary} \
429430
GREEN_FRAMEWORK=${GREEN_FRAMEWORK} \
430431
C_EXTENSIONS=${C_EXTENSIONS} \
431432
COVERAGE=${COVERAGE} \
@@ -1697,6 +1698,7 @@ axes:
16971698
run_on: rhel70-small
16981699
batchtime: 10080 # 7 days
16991700
variables:
1701+
python3_binary: "/opt/python/3.6/bin/python3"
17001702
libmongocrypt_url: https://s3.amazonaws.com/mciuploads/libmongocrypt/rhel-70-64-bit/master/latest/libmongocrypt.tar.gz
17011703
- id: suse12-x86-64-test
17021704
display_name: "SUSE 12 (x86_64)"

.evergreen/run-tests.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ set -o errexit # Exit the script with error if any of the commands fail
66
# AUTH Set to enable authentication. Defaults to "noauth"
77
# SSL Set to enable SSL. Defaults to "nossl"
88
# PYTHON_BINARY The Python version to use. Defaults to whatever is available
9+
# PYTHON3_BINARY Path to a working Python 3.5+ binary.
910
# GREEN_FRAMEWORK The green framework to test with, if any.
1011
# C_EXTENSIONS Pass --no_ext to setup.py, or not.
1112
# COVERAGE If non-empty, run the test suite with coverage.
@@ -22,6 +23,7 @@ fi
2223
AUTH=${AUTH:-noauth}
2324
SSL=${SSL:-nossl}
2425
PYTHON_BINARY=${PYTHON_BINARY:-}
26+
PYTHON3_BINARY=${PYTHON3_BINARY:-python3}
2527
GREEN_FRAMEWORK=${GREEN_FRAMEWORK:-}
2628
C_EXTENSIONS=${C_EXTENSIONS:-}
2729
COVERAGE=${COVERAGE:-}
@@ -170,11 +172,27 @@ if [ -n "$TEST_ENCRYPTION" ]; then
170172
# Remove after BUILD-13574.
171173
python -m pip install certifi
172174
fi
175+
# The mock KMS server requires Python >=3.5 with boto3.
176+
IS_PRE_35=$(python -c "import sys; sys.stdout.write('1' if sys.version_info < (3, 5) else '0')")
177+
if [ $IS_PRE_35 = "1" ]; then
178+
deactivate
179+
createvirtualenv $PYTHON3_BINARY venv-kms
180+
python -m pip install boto3
181+
fi
173182
pushd ${DRIVERS_TOOLS}/.evergreen/csfle
174183
python -u lib/kms_http_server.py --ca_file ../x509gen/ca.pem --cert_file ../x509gen/expired.pem --port 8000 &
175184
python -u lib/kms_http_server.py --ca_file ../x509gen/ca.pem --cert_file ../x509gen/wrong-host.pem --port 8001 &
176185
trap 'kill $(jobs -p)' EXIT HUP
177186
popd
187+
# Restore the test virtualenv.
188+
if [ $IS_PRE_35 = "1" ]; then
189+
deactivate
190+
if [ "Windows_NT" = "$OS" ]; then
191+
. venv-encryption/Scripts/activate
192+
else
193+
. venv-encryption/bin/activate
194+
fi
195+
fi
178196
fi
179197

180198
PYTHON_IMPL=$($PYTHON -c "import platform, sys; sys.stdout.write(platform.python_implementation())")

0 commit comments

Comments
 (0)