Fixes cfapi unit test conflicting with other tests.

Backported from master branch.

Currently, test_cfapi appears to be conflicting with other
unit tests [1][2] (see gate-murano-python27-db-ubuntu-xenial
in each case).

This is because test_cfapi has a helper method called
_set_override that calls oslo_config.cfg.set_override without
using clearing the overrides during tearDown (i.e. by calling
self.addCleanup(oslo_config.cfg.clear_override) for all
the values that were overriden with set_override.

The tests are always run in random order (i.e. with tox -e py27)
so the conflict does not appear to be deterministic or
guaranteed across all test runs.

[1] https://review.openstack.org/#/c/433724/1
[2] https://review.openstack.org/#/c/429978/

Change-Id: Ia2730072eac5962c5eefd8209406b1b3903f15f5
(cherry picked from commit 9a90e9d443)
This commit is contained in:
Felipe Monteiro 2017-02-15 15:10:45 -05:00
parent fbee4043ee
commit 4f06ae69e1
1 changed files with 11 additions and 10 deletions

View File

@ -529,6 +529,7 @@ class TestController(base.MuranoTestCase):
def _override_conf(self, without_urls=False):
override = api.CONF.set_override
clear_override = api.CONF.clear_override
if without_urls:
override('url', None, group='glare',
enforce_type=True)
@ -539,16 +540,16 @@ class TestController(base.MuranoTestCase):
enforce_type=True)
override('url', 'foo_murano_url', group='murano',
enforce_type=True)
override('packages_service', 'glance', group='engine',
enforce_type=True)
override('insecure', True, group='glare',
enforce_type=True)
override('key_file', 'foo_key_file', group='glare',
enforce_type=True)
override('ca_file', 'foo_ca_file', group='glare',
enforce_type=True)
override('cert_file', 'foo_cert_file', group='glare',
enforce_type=True)
self.addCleanup(clear_override, 'url', group='glare')
self.addCleanup(clear_override, 'url', group='murano')
for arg, group, override_val in (
('packages_service', 'engine', 'glare'),
('insecure', 'glare', True),
('key_file', 'glare', 'foo_key_file'),
('ca_file', 'glare', 'foo_ca_file'),
('cert_file', 'glare', 'foo_cert_file')):
override(arg, override_val, group=group, enforce_type=True)
self.addCleanup(clear_override, arg, group=group)
def test_resource(self):
self.assertIsInstance(api.create_resource(), wsgi.Resource)