diff options
| author | Robert Collins <robertc@robertcollins.net> | 2012-12-20 13:18:18 +1300 |
|---|---|---|
| committer | Robert Collins <robertc@robertcollins.net> | 2012-12-20 13:18:18 +1300 |
| commit | 81d7539dbce802eed0023d5b7340109f8460ceb1 (patch) | |
| tree | 9b228eb2a00a5c1c60d08014103f1f422490aa2e /nova/tests | |
| parent | 4e1634df7f47a181db80c709abaf60652b4a7e11 (diff) | |
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
Diffstat (limited to 'nova/tests')
| -rw-r--r-- | nova/tests/compute/test_compute.py | 3 | ||||
| -rw-r--r-- | nova/tests/compute/test_compute_utils.py | 5 | ||||
| -rw-r--r-- | nova/tests/test_notifications.py | 5 |
3 files changed, 4 insertions, 9 deletions
diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py index 079a25d27..87271a634 100644 --- a/nova/tests/compute/test_compute.py +++ b/nova/tests/compute/test_compute.py @@ -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() diff --git a/nova/tests/compute/test_compute_utils.py b/nova/tests/compute/test_compute_utils.py index 83ed90ef0..b3f7ea3df 100644 --- a/nova/tests/compute/test_compute_utils.py +++ b/nova/tests/compute/test_compute_utils.py @@ -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 = {} diff --git a/nova/tests/test_notifications.py b/nova/tests/test_notifications.py index 7374a72cd..a300028a0 100644 --- a/nova/tests/test_notifications.py +++ b/nova/tests/test_notifications.py @@ -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 |
