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
This commit is contained in:
parent
73ac2bfa4b
commit
0010e98bbd
31
nova/test.py
31
nova/test.py
@ -209,6 +209,10 @@ class TestCase(testtools.TestCase):
|
|||||||
USES_DB_SELF = False
|
USES_DB_SELF = False
|
||||||
REQUIRES_LOCKING = 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
|
TIMEOUT_SCALING_FACTOR = 1
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
@ -324,9 +328,6 @@ class TestCase(testtools.TestCase):
|
|||||||
cells-aware code can find those two databases.
|
cells-aware code can find those two databases.
|
||||||
"""
|
"""
|
||||||
celldbs = nova_fixtures.CellDatabases()
|
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()
|
ctxt = context.get_context()
|
||||||
fake_transport = 'fake://nowhere/'
|
fake_transport = 'fake://nowhere/'
|
||||||
@ -338,16 +339,24 @@ class TestCase(testtools.TestCase):
|
|||||||
transport_url=fake_transport,
|
transport_url=fake_transport,
|
||||||
database_connection=objects.CellMapping.CELL0_UUID)
|
database_connection=objects.CellMapping.CELL0_UUID)
|
||||||
c0.create()
|
c0.create()
|
||||||
|
self.cell_mappings[c0.name] = c0
|
||||||
|
celldbs.add_cell_database(objects.CellMapping.CELL0_UUID)
|
||||||
|
|
||||||
c1 = objects.CellMapping(
|
for x in range(self.NUMBER_OF_CELLS):
|
||||||
context=ctxt,
|
name = 'cell%i' % (x + 1)
|
||||||
uuid=uuids.cell1,
|
uuid = getattr(uuids, name)
|
||||||
name=CELL1_NAME,
|
cell = objects.CellMapping(
|
||||||
transport_url=fake_transport,
|
context=ctxt,
|
||||||
database_connection=uuids.cell1)
|
uuid=uuid,
|
||||||
c1.create()
|
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):
|
def _restore_obj_registry(self):
|
||||||
objects_base.NovaObjectRegistry._registry._obj_classes = \
|
objects_base.NovaObjectRegistry._registry._obj_classes = \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user