Fix a test isolation error in compute.test_compute.
In the compute.test_compute tests the common notifier_api test_notifier was being used. However, to use it correctly requires that any existing drivers be reset, otherwise the newly configured notifier does not take effect. I converted the other call sites that were doing this to also use cleanups rather than teardowns to reset it after usage, which got rid of two boilerplate tearDown methods. Change-Id: I6573d4652bb96dcebf38ef17d429d47d8a0e6434
This commit is contained in:
parent
4e1634df7f
commit
81d7539dbc
|
@ -103,6 +103,8 @@ class BaseTestCase(test.TestCase):
|
|||
|
||||
def setUp(self):
|
||||
super(BaseTestCase, self).setUp()
|
||||
notifier_api._reset_drivers()
|
||||
self.addCleanup(notifier_api._reset_drivers)
|
||||
self.flags(compute_driver='nova.virt.fake.FakeDriver',
|
||||
notification_driver=[test_notifier.__name__],
|
||||
network_manager='nova.network.manager.FlatManager')
|
||||
|
@ -144,7 +146,6 @@ class BaseTestCase(test.TestCase):
|
|||
def tearDown(self):
|
||||
fake_image.FakeImageService_reset()
|
||||
instances = db.instance_get_all(self.context.elevated())
|
||||
notifier_api._reset_drivers()
|
||||
for instance in instances:
|
||||
db.instance_destroy(self.context.elevated(), instance['uuid'])
|
||||
fake.restore_nodes()
|
||||
|
|
|
@ -216,6 +216,7 @@ class UsageInfoTestCase(test.TestCase):
|
|||
fake_get_nw_info)
|
||||
|
||||
notifier_api._reset_drivers()
|
||||
self.addCleanup(notifier_api._reset_drivers)
|
||||
self.flags(use_local=True, group='conductor')
|
||||
self.flags(compute_driver='nova.virt.fake.FakeDriver',
|
||||
notification_driver=[test_notifier.__name__],
|
||||
|
@ -233,10 +234,6 @@ class UsageInfoTestCase(test.TestCase):
|
|||
'show', fake_show)
|
||||
fake_network.set_stub_network_methods(self.stubs)
|
||||
|
||||
def tearDown(self):
|
||||
notifier_api._reset_drivers()
|
||||
super(UsageInfoTestCase, self).tearDown()
|
||||
|
||||
def _create_instance(self, params={}):
|
||||
"""Create a test instance"""
|
||||
inst = {}
|
||||
|
|
|
@ -55,6 +55,7 @@ class NotificationsTestCase(test.TestCase):
|
|||
fake_network.set_stub_network_methods(self.stubs)
|
||||
|
||||
notifier_api._reset_drivers()
|
||||
self.addCleanup(notifier_api._reset_drivers)
|
||||
self.flags(compute_driver='nova.virt.fake.FakeDriver',
|
||||
notification_driver=[test_notifier.__name__],
|
||||
network_manager='nova.network.manager.FlatManager',
|
||||
|
@ -68,10 +69,6 @@ class NotificationsTestCase(test.TestCase):
|
|||
|
||||
self.instance = self._wrapped_create()
|
||||
|
||||
def tearDown(self):
|
||||
notifier_api._reset_drivers()
|
||||
super(NotificationsTestCase, self).tearDown()
|
||||
|
||||
def _wrapped_create(self, params=None):
|
||||
inst = {}
|
||||
inst['image_ref'] = 1
|
||||
|
|
Loading…
Reference in New Issue