Browse Source

Switching Poppy test to use ostestr (OpenStack Testr)

Change-Id: Iec921d21f3325e92462c7a2b40d748db8f85cdff
tags/1.0.13
tonytan4ever 3 years ago
parent
commit
2140f6def0

+ 1
- 1
.testr.conf View File

@@ -2,7 +2,7 @@
2 2
 test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \
3 3
              OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \
4 4
              OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-160} \
5
-             ${PYTHON:-python} -m subunit.run discover -t ./ ${OS_TEST_PATH:-./tests} $LISTOPT $IDOPTION
5
+             ${PYTHON:-python} -m subunit.run discover -t ./ ${OS_TEST_PATH:-./tests/unit} $LISTOPT $IDOPTION
6 6
 
7 7
 test_id_option=--load-list $IDFILE
8 8
 test_list_option=--list

+ 2
- 0
poppy/provider/maxcdn/services.py View File

@@ -129,6 +129,8 @@ class ServiceController(base.ServiceBase):
129 129
         Map a poppy service name to a provider's service name so it
130 130
         can comply provider's naming convention.
131 131
         """
132
+        if isinstance(service_name, bytes):
133
+            service_name = service_name.decode("utf-8")
132 134
         if MAXCDN_NAMING_REGEX.match(service_name):
133 135
             return service_name
134 136
         else:

+ 0
- 11
setup.cfg View File

@@ -76,17 +76,6 @@ poppy.provider.akamai.cert_info_storage =
76 76
 [wheel]
77 77
 universal = 1
78 78
 
79
-[nosetests]
80
-cover-branches = true
81
-cover-erase = true
82
-cover-inclusive = true
83
-#cover-min-percentage = 100
84
-cover-package = poppy
85
-#match = ^test
86
-where = tests
87
-with-coverage = true
88
-verbosity=2
89
-
90 79
 ; Disabled: Causes a bug in testtools to manifest.
91 80
 ; Trigger: self.assertX(condition), where condition == False.
92 81
 ;

+ 1
- 1
tests/test-requirements.txt View File

@@ -4,9 +4,9 @@ dnspython
4 4
 fixtures
5 5
 hacking
6 6
 mock
7
-nose
8 7
 openstack.nose_plugin
9 8
 oslotest>=1.9.0
9
+os-testr>=0.7.0 # Apache-2.0
10 10
 requests-mock
11 11
 testrepository
12 12
 testtools

+ 2
- 0
tests/unit/distributed_task/taskflow/test_flows.py View File

@@ -312,6 +312,8 @@ class TestFlowRuns(base.TestCase):
312 312
 
313 313
             self.patch_delete_flow(service_controller, storage_controller,
314 314
                                    dns_controller)
315
+            storage_controller.get_service = mock.Mock(
316
+                return_value=service_obj)
315 317
             engines.run(delete_service.delete_service(), store=kwargs)
316 318
 
317 319
     def test_purge_flow_normal(self):

+ 4
- 0
tests/unit/manager/default/test_flavors.py View File

@@ -19,6 +19,7 @@ import uuid
19 19
 import mock
20 20
 from oslo_config import cfg
21 21
 
22
+from poppy import bootstrap
22 23
 from poppy.manager.default import driver
23 24
 from poppy.manager.default import flavors
24 25
 from poppy.model import flavor
@@ -42,6 +43,9 @@ class DefaultManagerFlavorTests(base.TestCase):
42 43
                 os.path.dirname(os.path.dirname(__file__)))))
43 44
         conf_path = os.path.join(tests_path, 'etc', 'default_functional.conf')
44 45
         cfg.CONF(args=[], default_config_files=[conf_path])
46
+        cfg.CONF.register_opts(bootstrap._DEFAULT_OPTIONS)
47
+        cfg.CONF.register_opts(bootstrap._DRIVER_OPTIONS,
48
+                               group=bootstrap._DRIVER_GROUP)
45 49
 
46 50
         manager_driver = driver.DefaultManagerDriver(cfg.CONF,
47 51
                                                      mock_driver,

+ 2
- 2
tests/unit/model/helpers/test_domain.py View File

@@ -27,8 +27,8 @@ class TestDomain(base.TestCase):
27 27
     @ddt.unpack
28 28
     @ddt.data({'domain_name': 'www.mydomain.com',
29 29
                'changed_domain_name': 'www.changed-domain.com'},
30
-              {'domain_name': u'www.düsseldorf-Lörick.com',
31
-               'changed_domain_name': u'www.düsseldorf.com'
30
+              {'domain_name': u'www.düsseldorf-Lörick.com'.encode("utf-8"),
31
+               'changed_domain_name': u'www.düsseldorf.com'.encode("utf-8")
32 32
                },
33 33
               {'domain_name': u'WWW.UPPERCASE.COM',
34 34
                'changed_domain_name': u'WWW.UPPERCASE-CHANGED.COM'

+ 2
- 2
tests/unit/model/helpers/test_origin.py View File

@@ -27,8 +27,8 @@ class TestOrigin(base.TestCase):
27 27
     @ddt.unpack
28 28
     @ddt.data({'origin_url': 'www.mydomain.com',
29 29
               'changed_origin_url': 'www.changed-domain.com'},
30
-              {'origin_url': u'www.düsseldorf-Lörick.com',
31
-              'changed_origin_url': u'www.düsseldorf.com'})
30
+              {'origin_url': u'www.düsseldorf-Lörick.com'.encode("utf-8"),
31
+              'changed_origin_url': u'www.düsseldorf.com'.encode("utf-8")})
32 32
     def test_origin(self, origin_url, changed_origin_url):
33 33
 
34 34
         port = 80

+ 2
- 1
tests/unit/provider/maxcdn/test_services.py View File

@@ -289,7 +289,8 @@ class TestServices(base.TestCase):
289 289
         self.assertEqual(controller._map_service_name(service_name),
290 290
                          service_name)
291 291
 
292
-    @ddt.data(u'www.düsseldorf-Lörick.com', 'yahoo%_notvalid')
292
+    @ddt.data(u'www.düsseldorf-Lörick.com'.encode("utf-8"),
293
+              'yahoo%_notvalid')
293 294
     @mock.patch.object(driver.CDNProvider, 'client',
294 295
                        new=fake_maxcdn_api_client())
295 296
     def test_map_service_name_with_hash(self, service_name):

+ 2
- 1
tests/unit/provider/mock/test_services.py View File

@@ -74,7 +74,8 @@ class MockProviderServicesTest(base.TestCase):
74 74
         response = self.sc.create(service_obj)
75 75
         self.assertTrue(response is not None)
76 76
 
77
-    @ddt.data("my_mock_service.com", u'www.düsseldorf-Lörick.com')
77
+    @ddt.data("my_mock_service.com",
78
+              u'www.düsseldorf-Lörick.com'.encode('utf-8'))
78 79
     def test__map_service_name(self, service_name):
79 80
         self.assertTrue(self.sc._map_service_name(service_name),
80 81
                         service_name)

+ 0
- 0
tests/unit/provider/sample/__init__.py View File


+ 8
- 0
tools/ostestr_compat_shim.sh View File

@@ -0,0 +1,8 @@
1
+#!/bin/sh
2
+
3
+# preserve old behavior of using an arg as a regex when '--' is not present
4
+case $@ in
5
+  (*--*) ostestr $@;;
6
+  ('') ostestr;;
7
+  (*) ostestr --regex "$@"
8
+esac

+ 32
- 19
tox.ini View File

@@ -1,25 +1,38 @@
1 1
 [tox]
2 2
 minversion = 1.6
3
-envlist = py34,py27,pypy,pep8
3
+envlist = py34,py27,functional,functional-py34,pypy,pep8
4 4
 skipsdist = True
5 5
 
6 6
 [testenv]
7 7
 usedevelop = True
8 8
 # Customize pip command, add -U to force updates.
9
-install_command = pip install -U {opts} {packages}
10 9
 setenv = VIRTUAL_ENV={envdir}
11 10
          LC_ALL = en_US.UTF-8
12
-         NOSE_WITH_OPENSTACK=1
13
-         NOSE_OPENSTACK_COLOR=1
14
-         NOSE_OPENSTACK_RED=0.05
15
-         NOSE_OPENSTACK_YELLOW=0.025
16
-         NOSE_OPENSTACK_SHOW_ELAPSED=1
17
-         NOSE_OPENSTACK_STDOUT=1
18
-         PYTHONDONTWRITEBYTECODE=1
11
+install_command = pip install -U {opts} {packages}
12
+passenv = TRACE_FAILONLY GENERATE_HASHES http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY
19 13
 deps = -r{toxinidir}/requirements/requirements.txt
20 14
        -r{toxinidir}/tests/test-requirements.txt
21 15
 commands = pip install git+https://github.com/stackforge/opencafe.git#egg=cafe
22
-           nosetests unit functional {posargs:--nologcapture}
16
+           {toxinidir}/tools/ostestr_compat_shim.sh {posargs}
17
+
18
+[testenv:common]
19
+# Fake job to define environment variables shared between dsvm/non-dsvm jobs
20
+setenv = OS_TEST_TIMEOUT=180
21
+
22
+[testenv:functional]
23
+basepython = python2.7
24
+setenv = {[testenv]setenv}
25
+         {[testenv:common]setenv}
26
+         OS_TEST_PATH=./tests/functional
27
+         OS_LOG_PATH={env:OS_LOG_PATH:{homedir}/.poppy/logs}
28
+deps =
29
+  {[testenv]deps}
30
+
31
+[testenv:functional-py34]
32
+basepython = python3.4
33
+setenv = {[testenv:functional]setenv}
34
+deps =
35
+  {[testenv:functional]deps}
23 36
 
24 37
 [testenv:pep8]
25 38
 commands = flake8
@@ -47,7 +60,11 @@ commands =
47 60
     python setup.py build_sphinx -E -a -b coverage
48 61
 
49 62
 [testenv:cover]
50
-setenv = NOSE_WITH_COVERAGE=1
63
+install_command = pip install -U {opts} {packages}
64
+basepython = python2.7
65
+commands =
66
+  python setup.py testr --coverage --testr-args='{posargs}'
67
+  coverage report
51 68
 
52 69
 [testenv:venv]
53 70
 commands = {posargs}
@@ -66,15 +83,11 @@ setenv = CAFE_CONFIG_FILE_PATH={homedir}/.poppy/tests.conf
66 83
          CAFE_ROOT_LOG_PATH={homedir}/.poppy/logs
67 84
          CAFE_TEST_LOG_PATH={homedir}/.poppy/logs
68 85
 
69
-         NOSE_WITH_OPENSTACK=1
70
-         NOSE_OPENSTACK_COLOR=1
71
-         NOSE_OPENSTACK_RED=0.05
72
-         NOSE_OPENSTACK_YELLOW=0.025
73
-         NOSE_OPENSTACK_SHOW_ELAPSED=1
74
-         NOSE_OPENSTACK_STDOUT=1
86
+         OS_TEST_PATH=./tests/api
87
+         OS_LOG_PATH={env:OS_LOG_PATH:{homedir}/.poppy/logs}
75 88
 
76 89
 commands =
77 90
     pip install git+https://github.com/openstack/opencafe.git#egg=cafe
78
-    ./run_poppy.sh -d
91
+    #./run_poppy.sh -d
79 92
 
80
-    nosetests api --nologcapture
93
+    {toxinidir}/tools/ostestr_compat_shim.sh

Loading…
Cancel
Save