[placement] Fix bad management of _TRAITS_SYNCED flag
Placement functional tests could, depending on run order, be unable to synchronise the os-traits because a previous test or this test has failed to reset the _TRAITS_SYNCED flag. This change fixes it so the tests will always reset the flag at both setUp and tearDown. In the process a nearby misleading comment which says a database is not being used is corrected. Change-Id: I595be7bca2c1bde86651b126ce501286b301d272 Closes-Bug: #1759863
This commit is contained in:
parent
00b19c73cf
commit
bdf06d18aa
|
@ -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,
|
||||
|
|
|
@ -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."""
|
||||
|
|
Loading…
Reference in New Issue