From f1f4bb30cd8ad930ddb7a232b2744b48e35a0480 Mon Sep 17 00:00:00 2001 From: Christian Schwede Date: Tue, 2 Jun 2015 19:51:39 +0000 Subject: [PATCH] Fix testing issues When functional tests are run in tox and an exception is raised when connecting to Swift (for example: Swift not running, missing python-keystoneclient package used by python-swiftclient) 0 tests are executed, but tox returns a success. An exception is raised during tests, caused by a missing python-keystoneclient in python-swiftclient. Instead of adding python-keystoneclient as a dependency in python-swiftclient the package is added to the test-requirements.txt in Swift itself. Note that adding python-keystoneclient to the test-requirements in python-swiftclient is not sufficient (it's already in there). The exception in setup_package() is catched by the openstack.nose_plugin, thus disabling this plugin for now as well. Also fixing two test errors seen on the gate regarding the tempurl middleware. There was also an update to tox, environment variables were no longer passed with versions >= 2.0 (http://tox.readthedocs.org/en/latest/changelog.html). Swift test environment variables have been added to the passenv to re-enable the former behavior, as well as environment variables required to pass proxy settings. This also led to skipped tempauth tests, and together with the missing python-keystoneclient no tests were executed. Related-Bug: 1461440 Related-Bug: 1455102 Co-Authored-By: Alistair Coles Change-Id: Ideea071017d04912c60ed0bc76532adbb446c31d --- doc/source/development_guidelines.rst | 15 +++++++++++++-- test-requirements.txt | 2 +- test/functional/tests.py | 4 +++- tox.ini | 7 +------ 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/doc/source/development_guidelines.rst b/doc/source/development_guidelines.rst index 1da8457682..29d9f35a41 100644 --- a/doc/source/development_guidelines.rst +++ b/doc/source/development_guidelines.rst @@ -44,13 +44,24 @@ To execute the unit tests: If you installed using: `cd ~/swift; sudo python setup.py develop`, you may need to do: `cd ~/swift; sudo chown -R swift:swift swift.egg-info` prior to running tox. - If you ever encounter DistributionNotFound, try to use `tox --recreate` - or removing .tox directory to force tox to recreate the dependency list * Optionally, run only specific tox builds: - `tox -e pep8,py27` +.. note:: + As of tox version 2.0.0, most environment variables are not automatically + passed to the test environment. Swift's tox.ini overrides this default + behavior so that variable names matching SWIFT_* and *_proxy will be passed, + but you may need to run tox --recreate for this to take effect after + upgrading from tox<2.0.0. + + Conversely, if you do not want those environment variables to be passed to + the test environment then you will need to unset them before calling tox. + + Also, if you ever encounter DistributionNotFound, try to use `tox --recreate` + or remove the .tox directory to force tox to recreate the dependency list. + The functional tests may be executed against a :doc:`development_saio` or other running Swift cluster using the command: diff --git a/test-requirements.txt b/test-requirements.txt index 8c617baacb..b3f7eed5be 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -7,9 +7,9 @@ hacking>=0.8.0,<0.9 coverage nose nosexcover -openstack.nose_plugin nosehtmloutput oslosphinx sphinx>=1.1.2,<1.2 mock>=1.0 python-swiftclient +python-keystoneclient>=1.3.0 diff --git a/test/functional/tests.py b/test/functional/tests.py index 63d6aae91e..aa3d440c2b 100644 --- a/test/functional/tests.py +++ b/test/functional/tests.py @@ -31,7 +31,7 @@ from nose import SkipTest from swift.common.http import is_success, is_client_error from test.functional import normalized_urls, load_constraint, cluster_info -from test.functional import check_response, retry +from test.functional import check_response, retry, requires_acls import test.functional as tf from test.functional.swift_test_client import Account, Connection, File, \ ResponseError @@ -3136,6 +3136,7 @@ class TestContainerTempurl(Base): parms=parms) self.assert_status([401]) + @requires_acls def test_tempurl_keys_visible_to_account_owner(self): if not tf.cluster_info.get('tempauth'): raise SkipTest('TEMP AUTH SPECIFIC TEST') @@ -3143,6 +3144,7 @@ class TestContainerTempurl(Base): self.assertEqual(metadata.get('tempurl_key'), self.env.tempurl_key) self.assertEqual(metadata.get('tempurl_key2'), self.env.tempurl_key2) + @requires_acls def test_tempurl_keys_hidden_from_acl_readonly(self): if not tf.cluster_info.get('tempauth'): raise SkipTest('TEMP AUTH SPECIFIC TEST') diff --git a/tox.ini b/tox.ini index de72f26950..8b7061a026 100644 --- a/tox.ini +++ b/tox.ini @@ -7,18 +7,13 @@ skipsdist = True usedevelop = True install_command = pip install --allow-external netifaces --allow-insecure netifaces -U {opts} {packages} setenv = VIRTUAL_ENV={envdir} - NOSE_WITH_OPENSTACK=1 - NOSE_OPENSTACK_COLOR=1 - NOSE_OPENSTACK_RED=0.05 - NOSE_OPENSTACK_YELLOW=0.025 - NOSE_OPENSTACK_SHOW_ELAPSED=1 - NOSE_OPENSTACK_STDOUT=1 NOSE_WITH_COVERAGE=1 NOSE_COVER_BRANCHES=1 deps = -r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt commands = nosetests {posargs:test/unit} +passenv = SWIFT_* *_proxy [testenv:cover] setenv = VIRTUAL_ENV={envdir}