Allow setting up multiple cells in the base TestCase

This lays the groundwork for other tests to get multiple
cells setup in the base TestCase by overriding a variable.

Change-Id: Ic27369dd3711e5b6bf11c98f742b5dc20a3a2799
Related-Bug: #1715493
(cherry picked from commit 53c2a979e2)
This commit is contained in:
Matt Riedemann 2017-09-06 21:22:53 -04:00
parent e06912594f
commit 9a791df1ec
1 changed files with 20 additions and 11 deletions

View File

@ -208,6 +208,10 @@ class TestCase(testtools.TestCase):
USES_DB_SELF = False
REQUIRES_LOCKING = False
# The number of non-cell0 cells to create. This is only used in the
# base class when USES_DB is True.
NUMBER_OF_CELLS = 1
TIMEOUT_SCALING_FACTOR = 1
def setUp(self):
@ -320,9 +324,6 @@ class TestCase(testtools.TestCase):
cells-aware code can find those two databases.
"""
celldbs = nova_fixtures.CellDatabases()
celldbs.add_cell_database(objects.CellMapping.CELL0_UUID)
celldbs.add_cell_database(uuids.cell1, default=True)
self.useFixture(celldbs)
ctxt = context.get_context()
fake_transport = 'fake://nowhere/'
@ -334,16 +335,24 @@ class TestCase(testtools.TestCase):
transport_url=fake_transport,
database_connection=objects.CellMapping.CELL0_UUID)
c0.create()
self.cell_mappings[c0.name] = c0
celldbs.add_cell_database(objects.CellMapping.CELL0_UUID)
c1 = objects.CellMapping(
context=ctxt,
uuid=uuids.cell1,
name=CELL1_NAME,
transport_url=fake_transport,
database_connection=uuids.cell1)
c1.create()
for x in range(self.NUMBER_OF_CELLS):
name = 'cell%i' % (x + 1)
uuid = getattr(uuids, name)
cell = objects.CellMapping(
context=ctxt,
uuid=uuid,
name=name,
transport_url=fake_transport,
database_connection=uuid)
cell.create()
self.cell_mappings[name] = cell
# cell1 is the default cell
celldbs.add_cell_database(uuid, default=(x == 0))
self.cell_mappings = {cm.name: cm for cm in (c0, c1)}
self.useFixture(celldbs)
def _restore_obj_registry(self):
objects_base.NovaObjectRegistry._registry._obj_classes = \