diff options
Diffstat (limited to 'nova/test.py')
-rw-r--r-- | nova/test.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/nova/test.py b/nova/test.py index 689d5ba291..e37967b06d 100644 --- a/nova/test.py +++ b/nova/test.py @@ -62,6 +62,7 @@ from nova import objects from nova.objects import base as objects_base from nova import quota from nova.scheduler.client import report +from nova.scheduler import utils as scheduler_utils from nova.tests import fixtures as nova_fixtures from nova.tests.unit import matchers from nova import utils @@ -171,6 +172,12 @@ class TestCase(base.BaseTestCase): # base class when USES_DB is True. NUMBER_OF_CELLS = 1 + # The stable compute id stuff is intentionally singleton-ish, which makes + # it a nightmare for testing multiple host/node combinations in tests like + # we do. So, mock it out by default, unless the test is specifically + # designed to handle it. + STUB_COMPUTE_ID = True + def setUp(self): """Run before each test method to initialize test environment.""" # Ensure BaseTestCase's ConfigureLogging fixture is disabled since @@ -288,6 +295,10 @@ class TestCase(base.BaseTestCase): self.useFixture(nova_fixtures.GenericPoisonFixture()) self.useFixture(nova_fixtures.SysFsPoisonFixture()) + # Additional module names can be added to this set if needed + self.useFixture(nova_fixtures.ImportModulePoisonFixture( + set(['guestfs', 'libvirt']))) + # make sure that the wsgi app is fully initialized for all testcase # instead of only once initialized for test worker wsgi_app.init_global_data.reset() @@ -295,6 +306,17 @@ class TestCase(base.BaseTestCase): # Reset the placement client singleton report.PLACEMENTCLIENT = None + # Reset our local node uuid cache (and avoid writing to the + # local filesystem when we generate a new one). + if self.STUB_COMPUTE_ID: + self.useFixture(nova_fixtures.ComputeNodeIdFixture()) + + # Reset globals indicating affinity filter support. Some tests may set + # self.flags(enabled_filters=...) which could make the affinity filter + # support globals get set to a non-default configuration which affects + # all other tests. + scheduler_utils.reset_globals() + def _setup_cells(self): """Setup a normal cellsv2 environment. @@ -683,6 +705,7 @@ class SubclassSignatureTestCase(testtools.TestCase, metaclass=abc.ABCMeta): raise NotImplementedError() def setUp(self): + self.useFixture(nova_fixtures.ConfFixture(CONF)) self.base = self._get_base_class() super(SubclassSignatureTestCase, self).setUp() |