diff --git a/.testr.conf b/.testr.conf index e9f70e1d..23c7d4f8 100644 --- a/.testr.conf +++ b/.testr.conf @@ -2,7 +2,7 @@ test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \ OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \ OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-160} \ - ${PYTHON:-python} -m subunit.run discover -t ./ ${OS_TEST_PATH:-./tests} $LISTOPT $IDOPTION + ${PYTHON:-python} -m subunit.run discover -t ./ ${OS_TEST_PATH:-./tests/unit} $LISTOPT $IDOPTION test_id_option=--load-list $IDFILE test_list_option=--list diff --git a/poppy/provider/maxcdn/services.py b/poppy/provider/maxcdn/services.py index 80c1a471..2f29001a 100644 --- a/poppy/provider/maxcdn/services.py +++ b/poppy/provider/maxcdn/services.py @@ -129,6 +129,8 @@ class ServiceController(base.ServiceBase): Map a poppy service name to a provider's service name so it can comply provider's naming convention. """ + if isinstance(service_name, bytes): + service_name = service_name.decode("utf-8") if MAXCDN_NAMING_REGEX.match(service_name): return service_name else: diff --git a/setup.cfg b/setup.cfg index 2b2c26fb..2886db24 100644 --- a/setup.cfg +++ b/setup.cfg @@ -76,17 +76,6 @@ poppy.provider.akamai.cert_info_storage = [wheel] universal = 1 -[nosetests] -cover-branches = true -cover-erase = true -cover-inclusive = true -#cover-min-percentage = 100 -cover-package = poppy -#match = ^test -where = tests -with-coverage = true -verbosity=2 - ; Disabled: Causes a bug in testtools to manifest. ; Trigger: self.assertX(condition), where condition == False. ; diff --git a/tests/test-requirements.txt b/tests/test-requirements.txt index 029b58a1..c25bedd0 100644 --- a/tests/test-requirements.txt +++ b/tests/test-requirements.txt @@ -4,9 +4,9 @@ dnspython fixtures hacking mock -nose openstack.nose_plugin oslotest>=1.9.0 +os-testr>=0.7.0 # Apache-2.0 requests-mock testrepository testtools diff --git a/tests/unit/distributed_task/taskflow/test_flows.py b/tests/unit/distributed_task/taskflow/test_flows.py index ea91db20..48cff374 100644 --- a/tests/unit/distributed_task/taskflow/test_flows.py +++ b/tests/unit/distributed_task/taskflow/test_flows.py @@ -312,6 +312,8 @@ class TestFlowRuns(base.TestCase): self.patch_delete_flow(service_controller, storage_controller, dns_controller) + storage_controller.get_service = mock.Mock( + return_value=service_obj) engines.run(delete_service.delete_service(), store=kwargs) def test_purge_flow_normal(self): diff --git a/tests/unit/manager/default/test_flavors.py b/tests/unit/manager/default/test_flavors.py index 02754c66..faeaaf4d 100644 --- a/tests/unit/manager/default/test_flavors.py +++ b/tests/unit/manager/default/test_flavors.py @@ -19,6 +19,7 @@ import uuid import mock from oslo_config import cfg +from poppy import bootstrap from poppy.manager.default import driver from poppy.manager.default import flavors from poppy.model import flavor @@ -42,6 +43,9 @@ class DefaultManagerFlavorTests(base.TestCase): os.path.dirname(os.path.dirname(__file__))))) conf_path = os.path.join(tests_path, 'etc', 'default_functional.conf') cfg.CONF(args=[], default_config_files=[conf_path]) + cfg.CONF.register_opts(bootstrap._DEFAULT_OPTIONS) + cfg.CONF.register_opts(bootstrap._DRIVER_OPTIONS, + group=bootstrap._DRIVER_GROUP) manager_driver = driver.DefaultManagerDriver(cfg.CONF, mock_driver, diff --git a/tests/unit/model/helpers/test_domain.py b/tests/unit/model/helpers/test_domain.py index 9c244a1b..2db691c5 100644 --- a/tests/unit/model/helpers/test_domain.py +++ b/tests/unit/model/helpers/test_domain.py @@ -27,8 +27,8 @@ class TestDomain(base.TestCase): @ddt.unpack @ddt.data({'domain_name': 'www.mydomain.com', 'changed_domain_name': 'www.changed-domain.com'}, - {'domain_name': u'www.düsseldorf-Lörick.com', - 'changed_domain_name': u'www.düsseldorf.com' + {'domain_name': u'www.düsseldorf-Lörick.com'.encode("utf-8"), + 'changed_domain_name': u'www.düsseldorf.com'.encode("utf-8") }, {'domain_name': u'WWW.UPPERCASE.COM', 'changed_domain_name': u'WWW.UPPERCASE-CHANGED.COM' diff --git a/tests/unit/model/helpers/test_origin.py b/tests/unit/model/helpers/test_origin.py index 85ebfbb2..2274ad77 100644 --- a/tests/unit/model/helpers/test_origin.py +++ b/tests/unit/model/helpers/test_origin.py @@ -27,8 +27,8 @@ class TestOrigin(base.TestCase): @ddt.unpack @ddt.data({'origin_url': 'www.mydomain.com', 'changed_origin_url': 'www.changed-domain.com'}, - {'origin_url': u'www.düsseldorf-Lörick.com', - 'changed_origin_url': u'www.düsseldorf.com'}) + {'origin_url': u'www.düsseldorf-Lörick.com'.encode("utf-8"), + 'changed_origin_url': u'www.düsseldorf.com'.encode("utf-8")}) def test_origin(self, origin_url, changed_origin_url): port = 80 diff --git a/tests/unit/provider/maxcdn/test_services.py b/tests/unit/provider/maxcdn/test_services.py index 70403d37..d929a3a0 100644 --- a/tests/unit/provider/maxcdn/test_services.py +++ b/tests/unit/provider/maxcdn/test_services.py @@ -289,7 +289,8 @@ class TestServices(base.TestCase): self.assertEqual(controller._map_service_name(service_name), service_name) - @ddt.data(u'www.düsseldorf-Lörick.com', 'yahoo%_notvalid') + @ddt.data(u'www.düsseldorf-Lörick.com'.encode("utf-8"), + 'yahoo%_notvalid') @mock.patch.object(driver.CDNProvider, 'client', new=fake_maxcdn_api_client()) def test_map_service_name_with_hash(self, service_name): diff --git a/tests/unit/provider/mock/test_services.py b/tests/unit/provider/mock/test_services.py index 8f632c74..7e4d92a1 100644 --- a/tests/unit/provider/mock/test_services.py +++ b/tests/unit/provider/mock/test_services.py @@ -74,7 +74,8 @@ class MockProviderServicesTest(base.TestCase): response = self.sc.create(service_obj) self.assertTrue(response is not None) - @ddt.data("my_mock_service.com", u'www.düsseldorf-Lörick.com') + @ddt.data("my_mock_service.com", + u'www.düsseldorf-Lörick.com'.encode('utf-8')) def test__map_service_name(self, service_name): self.assertTrue(self.sc._map_service_name(service_name), service_name) diff --git a/tests/unit/provider/sample/__init__.py b/tests/unit/provider/sample/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/tools/ostestr_compat_shim.sh b/tools/ostestr_compat_shim.sh new file mode 100755 index 00000000..a483ed1a --- /dev/null +++ b/tools/ostestr_compat_shim.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +# preserve old behavior of using an arg as a regex when '--' is not present +case $@ in + (*--*) ostestr $@;; + ('') ostestr;; + (*) ostestr --regex "$@" +esac diff --git a/tox.ini b/tox.ini index 1d16ec21..476fda8f 100644 --- a/tox.ini +++ b/tox.ini @@ -1,25 +1,38 @@ [tox] minversion = 1.6 -envlist = py34,py27,pypy,pep8 +envlist = py34,py27,functional,functional-py34,pypy,pep8 skipsdist = True [testenv] usedevelop = True # Customize pip command, add -U to force updates. -install_command = pip install -U {opts} {packages} setenv = VIRTUAL_ENV={envdir} LC_ALL = en_US.UTF-8 - 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 - PYTHONDONTWRITEBYTECODE=1 +install_command = pip install -U {opts} {packages} +passenv = TRACE_FAILONLY GENERATE_HASHES http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY deps = -r{toxinidir}/requirements/requirements.txt -r{toxinidir}/tests/test-requirements.txt commands = pip install git+https://github.com/stackforge/opencafe.git#egg=cafe - nosetests unit functional {posargs:--nologcapture} + {toxinidir}/tools/ostestr_compat_shim.sh {posargs} + +[testenv:common] +# Fake job to define environment variables shared between dsvm/non-dsvm jobs +setenv = OS_TEST_TIMEOUT=180 + +[testenv:functional] +basepython = python2.7 +setenv = {[testenv]setenv} + {[testenv:common]setenv} + OS_TEST_PATH=./tests/functional + OS_LOG_PATH={env:OS_LOG_PATH:{homedir}/.poppy/logs} +deps = + {[testenv]deps} + +[testenv:functional-py34] +basepython = python3.4 +setenv = {[testenv:functional]setenv} +deps = + {[testenv:functional]deps} [testenv:pep8] commands = flake8 @@ -47,7 +60,11 @@ commands = python setup.py build_sphinx -E -a -b coverage [testenv:cover] -setenv = NOSE_WITH_COVERAGE=1 +install_command = pip install -U {opts} {packages} +basepython = python2.7 +commands = + python setup.py testr --coverage --testr-args='{posargs}' + coverage report [testenv:venv] commands = {posargs} @@ -66,15 +83,11 @@ setenv = CAFE_CONFIG_FILE_PATH={homedir}/.poppy/tests.conf CAFE_ROOT_LOG_PATH={homedir}/.poppy/logs CAFE_TEST_LOG_PATH={homedir}/.poppy/logs - 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 + OS_TEST_PATH=./tests/api + OS_LOG_PATH={env:OS_LOG_PATH:{homedir}/.poppy/logs} commands = pip install git+https://github.com/openstack/opencafe.git#egg=cafe - ./run_poppy.sh -d + #./run_poppy.sh -d - nosetests api --nologcapture + {toxinidir}/tools/ostestr_compat_shim.sh