diff --git a/nova/tests/functional/api/openstack/placement/db/test_allocation_candidates.py b/nova/tests/functional/api/openstack/placement/db/test_allocation_candidates.py index d113604fe3d3..d9fedc045611 100644 --- a/nova/tests/functional/api/openstack/placement/db/test_allocation_candidates.py +++ b/nova/tests/functional/api/openstack/placement/db/test_allocation_candidates.py @@ -62,11 +62,21 @@ class ProviderDBBase(test.NoDBTestCase): super(ProviderDBBase, self).setUp() self.useFixture(fixtures.Database()) self.api_db = self.useFixture(fixtures.Database(database='api')) + # Reset the _TRAITS_SYNCED global before we start and after + # we are done since other tests (notably the gabbi tests) + # may have caused it to change. + self._reset_traits_synced() + self.addCleanup(self._reset_traits_synced) self.ctx = context.RequestContext('fake-user', 'fake-project') # For debugging purposes, populated by _create_provider and used by # _validate_allocation_requests to make failure results more readable. self.rp_uuid_to_name = {} + @staticmethod + def _reset_traits_synced(): + """Reset the _TRAITS_SYNCED boolean to base state.""" + rp_obj._TRAITS_SYNCED = False + def _create_provider(self, name, *aggs, **kwargs): parent = kwargs.get('parent') rp = rp_obj.ResourceProvider(self.ctx, name=name, diff --git a/nova/tests/functional/api/openstack/placement/fixtures.py b/nova/tests/functional/api/openstack/placement/fixtures.py index e28f4a9a7d09..cbb6ee63973d 100644 --- a/nova/tests/functional/api/openstack/placement/fixtures.py +++ b/nova/tests/functional/api/openstack/placement/fixtures.py @@ -66,9 +66,10 @@ class APIFixture(fixture.GabbiFixture): config.parse_args([], default_config_files=[], configure_db=False, init_rpc=False) - # NOTE(cdent): api and main database are not used but we still need - # to manage them to make the fixtures work correctly and not cause + # NOTE(cdent): The main database is not used but we still need to + # manage it to make the fixtures work correctly and not cause # conflicts with other tests in the same process. + self._reset_db_flags() self.api_db_fixture = fixtures.Database('api') self.main_db_fixture = fixtures.Database('main') self.api_db_fixture.reset() @@ -95,14 +96,18 @@ class APIFixture(fixture.GabbiFixture): # flag to make sure the next run will recreate the traits and # reset the _RC_CACHE so that any cached resource classes # are flushed. - rp_obj._TRAITS_SYNCED = False - rp_obj._RC_CACHE = None + self._reset_db_flags() self.output_stream_fixture.cleanUp() self.standard_logging_fixture.cleanUp() if self.conf: self.conf.reset() + @staticmethod + def _reset_db_flags(): + rp_obj._TRAITS_SYNCED = False + rp_obj._RC_CACHE = None + class AllocationFixture(APIFixture): """An APIFixture that has some pre-made Allocations."""