PYTHON-1198 Test PyMongo v2.9 on Evergreen.
Install nose via setup_requires to produce XML test output. Add Python 2.4, 2.5, Jython 2.5 testing. Only run the SSL test suite when SSL is enabled. test_ssl.py should not fail when auth_context.client does not exist. Work around the nosetests command and verbosity flag on Python 3.
This commit is contained in:
parent
d5a7120e6a
commit
489ef3676e
@ -307,7 +307,7 @@ functions:
|
||||
file_location: "${DRIVERS_TOOLS}/results.json"
|
||||
- command: attach.xunit_results
|
||||
params:
|
||||
file: "src/xunit-results/TEST-*.xml"
|
||||
file: "src/nosetests.xml"
|
||||
|
||||
"bootstrap mongo-orchestration":
|
||||
- command: shell.exec
|
||||
@ -780,6 +780,14 @@ axes:
|
||||
- id: python-version
|
||||
display_name: "Python"
|
||||
values:
|
||||
- id: "2.4"
|
||||
display_name: "Python 2.4"
|
||||
variables:
|
||||
PYTHON_BINARY: "/opt/python/2.4/bin/python"
|
||||
- id: "2.5"
|
||||
display_name: "Python 2.5"
|
||||
variables:
|
||||
PYTHON_BINARY: "/opt/python/2.5/bin/python"
|
||||
- id: "2.6"
|
||||
display_name: "Python 2.6"
|
||||
variables:
|
||||
@ -812,6 +820,10 @@ axes:
|
||||
display_name: "PyPy 3"
|
||||
variables:
|
||||
PYTHON_BINARY: "/opt/python/pypy3/bin/pypy3"
|
||||
- id: "jython2.5"
|
||||
display_name: "Jython 2.5"
|
||||
variables:
|
||||
PYTHON_BINARY: "/opt/python/jython2.5/bin/jython"
|
||||
- id: "jython2.7"
|
||||
display_name: "Jython 2.7"
|
||||
variables:
|
||||
@ -931,7 +943,7 @@ buildvariants:
|
||||
matrix_spec: {"python-version": "*", auth: "*", ssl: "ssl" }
|
||||
exclude_spec:
|
||||
# PYTHON-498: disable Jython SSL tests
|
||||
python-version: "jython2.7"
|
||||
python-version: ["jython2.5", "jython2.7"]
|
||||
# EVG-1410: exlcude_spec must specifiy values for all axes
|
||||
auth: "*"
|
||||
ssl: "ssl"
|
||||
|
||||
@ -20,11 +20,6 @@ if [ "$AUTH" != "noauth" ]; then
|
||||
export DB_PASSWORD="pwd123"
|
||||
fi
|
||||
|
||||
if [ "$SSL" != "nossl" ]; then
|
||||
export CLIENT_PEM="$DRIVERS_TOOLS/.evergreen/x509gen/client.pem"
|
||||
export CA_PEM="$DRIVERS_TOOLS/.evergreen/x509gen/ca.pem"
|
||||
fi
|
||||
|
||||
if [ -z "$PYTHON_BINARY" ]; then
|
||||
PYTHON=$(command -v python || command -v python3)
|
||||
if [ -z "$PYTHON" ]; then
|
||||
@ -35,6 +30,34 @@ else
|
||||
PYTHON="$PYTHON_BINARY"
|
||||
fi
|
||||
|
||||
PYTHON_VERSION=$($PYTHON -c 'import sys; sys.stdout.write(str(sys.version_info[0]))')
|
||||
|
||||
if [ "$SSL" = "ssl" ]; then
|
||||
if [ "$PYTHON_VERSION" = "3" ]; then
|
||||
# We cannot pass arguments to the "nosetests" command with Python 3
|
||||
# because of the hacks in setup.py to work around nose/2to3 usage.
|
||||
# Instead, use the "test" command directly to run only test/test_ssl.py.
|
||||
# Unfortunately, this does not produce XML output.
|
||||
TEST_CMD="test --test-suite test.test_ssl"
|
||||
else
|
||||
# With Python 2 we use the nosetests command
|
||||
# Run only test/test_ssl.py and produces nosetests.xml output.
|
||||
TEST_CMD="nosetests --tests test/test_ssl.py"
|
||||
fi
|
||||
else
|
||||
# Run all the tests and produces nosetests.xml output.
|
||||
TEST_CMD="nosetests"
|
||||
fi
|
||||
|
||||
# Set verbose test output flag.
|
||||
if [ "$PYTHON_VERSION" = "3" ]; then
|
||||
# With Python 3, the tests do not accept a "--verbosity=2" flag.
|
||||
TEST_VERBOSITY="-v"
|
||||
else
|
||||
# With Python 2, the tests accepts a "-v" flag but only "--verbosity=2"
|
||||
# causes the verbose output we want.
|
||||
TEST_VERBOSITY="--verbosity=2"
|
||||
fi
|
||||
|
||||
echo "Running $AUTH tests over $SSL with python $PYTHON, connecting to $MONGODB_URI"
|
||||
$PYTHON -c 'import sys; print(sys.version)'
|
||||
@ -43,4 +66,4 @@ $PYTHON -c 'import sys; print(sys.version)'
|
||||
# files in the xunit-results/ directory.
|
||||
|
||||
$PYTHON setup.py clean
|
||||
$PYTHON setup.py test --xunit-output=xunit-results
|
||||
$PYTHON setup.py $TEST_CMD $TEST_VERBOSITY
|
||||
|
||||
13
setup.py
13
setup.py
@ -315,6 +315,19 @@ Performance may be degraded.\n
|
||||
else:
|
||||
extra_opts['ext_modules'] = ext_modules
|
||||
|
||||
# The nosetests command requires nose be available, otherwise the xunit
|
||||
# plugin will not work.
|
||||
# Note: projects listed in setup_requires will NOT be automatically installed
|
||||
# on the system where the setup script is being run. They are simply
|
||||
# downloaded to the ./.eggs directory if they're not locally available
|
||||
# already.
|
||||
# See:
|
||||
# https://nose.readthedocs.io/en/latest/api/commands.html#bootstrapping
|
||||
# https://nose.readthedocs.io/en/latest/setuptools_integration.html
|
||||
# https://setuptools.readthedocs.io/en/latest/setuptools.html#new-and-changed-setup-keywords
|
||||
if "nosetests" in sys.argv:
|
||||
extra_opts["setup_requires"] = ["nose"]
|
||||
|
||||
if PY3:
|
||||
extra_opts["use_2to3"] = True
|
||||
if should_run_tests:
|
||||
|
||||
@ -148,6 +148,8 @@ def setup():
|
||||
|
||||
def teardown():
|
||||
client = auth_context.client
|
||||
if not client:
|
||||
return
|
||||
if auth_context.auth_enabled:
|
||||
auth_context.add_user_and_log_in()
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user