Skip to content

Commit 1db5240

Browse files
committed
PYTHON-2608 Fix KMS TLS testing on Python <3.5
1 parent 4d531d1 commit 1db5240

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-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} \
@@ -1695,6 +1696,7 @@ axes:
16951696
run_on: rhel70-small
16961697
batchtime: 10080 # 7 days
16971698
variables:
1699+
python3_binary: "/opt/python/3.6/bin/python3"
16981700
libmongocrypt_url: https://s3.amazonaws.com/mciuploads/libmongocrypt/rhel-70-64-bit/master/latest/libmongocrypt.tar.gz
16991701
- id: suse12-x86-64-test
17001702
display_name: "SUSE 12 (x86_64)"

.evergreen/run-tests.sh

Lines changed: 19 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:-}
@@ -167,11 +169,28 @@ if [ -n "$TEST_ENCRYPTION" ]; then
167169

168170
# Start the mock KMS servers.
169171
if [ "$OS" != "Windows_NT" ]; then
172+
# The mock KMS server requires Python 3.5 with boto3.
173+
IS_PRE_35=$(python -c "import sys; sys.stdout.write('1' if sys.version_info < (3, 5) else '0')")
174+
if [ $IS_PRE_35 = "1" ]; then
175+
echo "PYTHON3_BINARY: $PYTHON3_BINARY"
176+
deactivate
177+
createvirtualenv $PYTHON3_BINARY venv-kms
178+
python -m pip install boto3
179+
fi
170180
pushd ${DRIVERS_TOOLS}/.evergreen/csfle
171181
python -u lib/kms_http_server.py --ca_file ../x509gen/ca.pem --cert_file ../x509gen/expired.pem --port 8000 &
172182
python -u lib/kms_http_server.py --ca_file ../x509gen/ca.pem --cert_file ../x509gen/wrong-host.pem --port 8001 &
173183
trap 'kill $(jobs -p)' EXIT HUP
174184
popd
185+
# Restore the test virtualenv.
186+
if [ $IS_PRE_35 = "1" ]; then
187+
deactivate
188+
if [ "Windows_NT" = "$OS" ]; then
189+
. venv-encryption/Scripts/activate
190+
else
191+
. venv-encryption/bin/activate
192+
fi
193+
fi
175194
fi
176195
fi
177196

0 commit comments

Comments
 (0)