Restore provisioning of DBs in legacy test base

Apparentely I0163e637ffef6d45d2573ebe29b5438911d01fce breaks Nova
tests, as we no longer provision a new DB in DatabaseResource by
default. While the recommended way is to use the new fixtures, we
should make sure the original behavior is preserved for the legacy
test cases.

Change-Id: I3e238b6a97769cf0a352f11e718d5d73eebcfa8a
This commit is contained in:
Roman Podoliaka
2016-11-14 13:28:57 +02:00
parent 4ecb9bd19c
commit dd80045893
2 changed files with 18 additions and 1 deletions

View File

@@ -126,7 +126,8 @@ class DbTestCase(test_base.BaseTestCase):
if driver not in self._database_resources:
try:
self._database_resources[driver] = \
provision.DatabaseResource(driver)
provision.DatabaseResource(driver,
provision_new_database=True)
except exception.BackendNotAvailable as bne:
self._database_resources[driver] = None
self._db_not_available[driver] = str(bne)

View File

@@ -196,3 +196,19 @@ class EnginefacadeIntegrationTest(oslo_test_base.BaseTestCase):
fixture.cleanUp()
fixture._clear_cleanups() # so the real cleanUp works
self.assertFalse(normal_mgr._factory._started)
class LegacyBaseClassTest(oslo_test_base.BaseTestCase):
def test_new_db_is_provisioned_by_default(self):
classes = [
legacy_test_base.MySQLOpportunisticTestCase,
legacy_test_base.PostgreSQLOpportunisticTestCase
]
for base_cls in classes:
class SomeTest(base_cls):
def runTest(self):
pass
st = SomeTest()
db_resource = dict(st.resources)['db']
self.assertTrue(db_resource.provision_new_database)