diff --git a/.evergreen/config.yml b/.evergreen/config.yml index c2964c763..576d994ae 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -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" diff --git a/.evergreen/run-tests.sh b/.evergreen/run-tests.sh index 7cbc69cad..359e7b504 100755 --- a/.evergreen/run-tests.sh +++ b/.evergreen/run-tests.sh @@ -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 diff --git a/setup.py b/setup.py index 2a5f97bcb..6e1944fdb 100755 --- a/setup.py +++ b/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: diff --git a/test/__init__.py b/test/__init__.py index e20c3983e..d8f7aa05c 100644 --- a/test/__init__.py +++ b/test/__init__.py @@ -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()