Skip to content

Commit 4c56ead

Browse files
committed
PYTHON-2149 Test PyOpenSSL with all MongoDB versions
1 parent f058508 commit 4c56ead

File tree

3 files changed

+69
-85
lines changed

3 files changed

+69
-85
lines changed

.evergreen/config.yml

+34-31
Original file line numberDiff line numberDiff line change
@@ -339,19 +339,6 @@ functions:
339339
${PREPARE_SHELL}
340340
PYTHON_BINARY=${PYTHON_BINARY} sh ${PROJECT_DIRECTORY}/.evergreen/run-cdecimal-tests.sh
341341
342-
"run pyopenssl tests":
343-
- command: shell.exec
344-
type: test
345-
params:
346-
working_dir: "src"
347-
script: |
348-
set -o xtrace
349-
${PREPARE_SHELL}
350-
if [ -n "${MONGODB_STARTED}" ]; then
351-
export PYMONGO_MUST_CONNECT=1
352-
fi
353-
PYTHON_BINARY=${PYTHON_BINARY} sh ${PROJECT_DIRECTORY}/.evergreen/run-pyopenssl-tests.sh
354-
355342
"run doctests":
356343
- command: shell.exec
357344
type: test
@@ -399,6 +386,9 @@ functions:
399386
export LIBMONGOCRYPT_URL="${libmongocrypt_url}"
400387
export TEST_ENCRYPTION=1
401388
fi
389+
if [ -n "${test_pyopenssl}" ]; then
390+
export TEST_PYOPENSSL=1
391+
fi
402392
if [ -n "${SETDEFAULTENCODING}" ]; then
403393
export SETDEFAULTENCODING="${SETDEFAULTENCODING}"
404394
fi
@@ -1076,17 +1066,6 @@ tasks:
10761066
TOPOLOGY: "server"
10771067
- func: "run cdecimal tests"
10781068

1079-
# Use latest for this, since we're
1080-
# adding this to support OCSP stapling
1081-
- name: "pyopenssl"
1082-
tags: ["pyopenssl"]
1083-
commands:
1084-
- func: "bootstrap mongo-orchestration"
1085-
vars:
1086-
VERSION: "latest"
1087-
TOPOLOGY: "server"
1088-
- func: "run pyopenssl tests"
1089-
10901069
- name: "no-server"
10911070
tags: ["no-server"]
10921071
commands:
@@ -1632,6 +1611,17 @@ axes:
16321611
tags: ["encryption_tag"]
16331612
variables:
16341613
test_encryption: true
1614+
batchtime: 10080 # 7 days
1615+
1616+
# Run pyopenssl tests?
1617+
- id: pyopenssl
1618+
display_name: "PyOpenSSL"
1619+
values:
1620+
- id: "enabled"
1621+
display_name: "PyOpenSSL"
1622+
variables:
1623+
test_pyopenssl: true
1624+
batchtime: 10080 # 7 days
16351625

16361626
# Run setdefaultencoding before running the test suite?
16371627
- id: setdefaultencoding
@@ -1834,39 +1824,52 @@ buildvariants:
18341824
python-version: ["2.7", "3.4", "3.5", "3.6", "3.7", "pypy", "pypy3.5"]
18351825
auth: "*"
18361826
ssl: "ssl"
1827+
pyopenssl: "*"
1828+
# Only test "noauth" with Python 3.7.
1829+
exclude_spec:
1830+
platform: ubuntu-16.04
1831+
python-version: ["2.7", "3.4", "3.5", "3.6", "pypy", "pypy3.5"]
1832+
auth: "noauth"
1833+
ssl: "ssl"
1834+
pyopenssl: "*"
18371835
display_name: "PyOpenSSL ${platform} ${python-version} ${auth}"
18381836
tasks:
1839-
- "pyopenssl"
1837+
- '.replica_set !.2.6 !.3.0'
1838+
# Test standalone and sharded only on 4.4.
1839+
- '.4.4'
18401840

18411841
- matrix_name: "test-pyopenssl-old-py27"
18421842
matrix_spec:
18431843
platform:
18441844
# Supported OSes with pre-2.7.9 CPython versions.
18451845
- rhel70 # CPython 2.7.5
1846-
auth: "*"
1846+
auth: "auth"
18471847
ssl: "ssl"
1848+
pyopenssl: "*"
18481849
display_name: "PyOpenSSL ${platform} Pre-2.7.9 Python ${auth}"
18491850
tasks:
1850-
- "pyopenssl"
1851+
- '.replica_set'
18511852

18521853
- matrix_name: "tests-pyopenssl-macOS"
18531854
matrix_spec:
18541855
platform: macos-1014
1855-
auth: "*"
1856+
auth: "auth"
18561857
ssl: "ssl"
1858+
pyopenssl: "*"
18571859
display_name: "PyOpenSSL ${platform} ${auth}"
18581860
tasks:
1859-
- "pyopenssl"
1861+
- '.replica_set !.2.6 !.3.0'
18601862

18611863
- matrix_name: "tests-pyopenssl-windows"
18621864
matrix_spec:
18631865
platform: windows-64-vsMulti-small
18641866
python-version-windows: "*"
1865-
auth: "*"
1867+
auth: "auth"
18661868
ssl: "ssl"
1869+
pyopenssl: "*"
18671870
display_name: "PyOpenSSL ${platform} ${python-version-windows} ${auth}"
18681871
tasks:
1869-
- "pyopenssl"
1872+
- '.replica_set'
18701873

18711874
- matrix_name: "tests-python-version-rhel62-test-encryption"
18721875
matrix_spec:

.evergreen/run-pyopenssl-tests.sh

-54
This file was deleted.

.evergreen/run-tests.sh

+35
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,41 @@ else
8989
PYTHON="$PYTHON_BINARY"
9090
fi
9191

92+
# PyOpenSSL test setup.
93+
if [ -n "$TEST_PYOPENSSL" ]; then
94+
if $PYTHON -m virtualenv --version; then
95+
VIRTUALENV="$PYTHON -m virtualenv"
96+
elif command -v virtualenv; then
97+
# We can remove this fallback after:
98+
# https://github.com/10gen/mongo-python-toolchain/issues/8
99+
VIRTUALENV="$(command -v virtualenv) -p $PYTHON"
100+
else
101+
echo "Cannot test without virtualenv"
102+
exit 1
103+
fi
104+
105+
$VIRTUALENV pyopenssltest
106+
if [ "Windows_NT" = "$OS" ]; then
107+
. pyopenssltest/Scripts/activate
108+
else
109+
. pyopenssltest/bin/activate
110+
fi
111+
trap "deactivate; rm -rf pyopenssltest" EXIT HUP
112+
113+
IS_PYTHON_2=$(python -c "import sys; sys.stdout.write('1' if sys.version_info < (3,) else '0')")
114+
if [ $IS_PYTHON_2 = "1" ]; then
115+
echo "Using a Python 2"
116+
# Upgrade pip to install the cryptography wheel and not the tar.
117+
# <20.1 because 20.0.2 says a future release may drop support for 2.7.
118+
python -m pip install --upgrade 'pip<20.1'
119+
# Upgrade setuptools because cryptography requires 18.5+.
120+
# <45 because 45.0 dropped support for 2.7.
121+
python -m pip install --upgrade 'setuptools<45'
122+
fi
123+
124+
python -m pip install pyopenssl requests service_identity
125+
fi
126+
92127
if [ -n "$TEST_ENCRYPTION" ]; then
93128
if [ -z "$LIBMONGOCRYPT_URL" ]; then
94129
echo "Cannot test client side encryption without LIBMONGOCRYPT_URL!"

0 commit comments

Comments
 (0)