diff options
author | Dan Smith <danms@us.ibm.com> | 2013-06-13 09:35:10 -0700 |
---|---|---|
committer | Dan Smith <danms@us.ibm.com> | 2013-06-13 11:23:00 -0700 |
commit | 9e60df30dc648b3eebe755bf389e6c017d87b22b (patch) | |
tree | d9ce48d8adb0acd157f2000c337c7485a4d34675 | |
parent | d0d330fe0cc7c7e395d9604704a9efb3e9442944 (diff) | |
download | nova-9e60df30dc648b3eebe755bf389e6c017d87b22b.tar.gz nova-9e60df30dc648b3eebe755bf389e6c017d87b22b.tar.xz nova-9e60df30dc648b3eebe755bf389e6c017d87b22b.zip |
Backup and restore object registry for tests
Without this, the object registry can become cluttered with test objects,
which may conflict with each other, depending on the order and pairing
of testr processes.
Related to unified-object-model
Change-Id: I77d3beebfb963cdc24c49eebb38ca8a768c69503
-rw-r--r-- | nova/test.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/nova/test.py b/nova/test.py index 85ba990c0..a8af00889 100644 --- a/nova/test.py +++ b/nova/test.py @@ -26,6 +26,7 @@ inline callbacks. import eventlet eventlet.monkey_patch(os=False) +import copy import os import shutil import sys @@ -234,8 +235,12 @@ class TestCase(testtools.TestCase): self.useFixture(_DB_CACHE) # NOTE(danms): Make sure to reset us back to non-remote objects - # for each test to avoid interactions. + # for each test to avoid interactions. Also, backup the object + # registry. objects_base.NovaObject.indirection_api = None + self._base_test_obj_backup = copy.copy( + objects_base.NovaObject._obj_classes) + self.addCleanup(self._restore_obj_registry) mox_fixture = self.useFixture(MoxStubout()) self.mox = mox_fixture.mox @@ -246,6 +251,9 @@ class TestCase(testtools.TestCase): CONF.set_override('fatal_exception_format_errors', True) CONF.set_override('enabled', True, 'osapi_v3') + def _restore_obj_registry(self): + objects_base.NovaObject._obj_classes = self._base_test_obj_backup + def _clear_attrs(self): # Delete attributes that don't start with _ so they don't pin # memory around unnecessarily for the duration of the test |