Fix migration list + MigrationList operation
Fixes up the get_migrations cells method and corresponding tests. The tests were not in line with reality since the MigrationList object was introduced. This patch removes the [] + MigrationList operation that was occurring since the operation is poorly defined and only works by accident. Future objects work may break this so it should be removed now. Change-Id: I5dabd8c745cc287322a1ef0f0dd2d4733484188d
This commit is contained in:
parent
15e536518a
commit
00e46a313c
@ -452,8 +452,10 @@ class CellsManager(manager.Manager):
|
|||||||
False, filters)
|
False, filters)
|
||||||
migrations = []
|
migrations = []
|
||||||
for response in responses:
|
for response in responses:
|
||||||
migrations += response.value_or_raise()
|
# response.value_or_raise returns MigrationList objects.
|
||||||
return migrations
|
# MigrationList.objects returns the list of Migration objects.
|
||||||
|
migrations.extend(response.value_or_raise().objects)
|
||||||
|
return objects.MigrationList(objects=migrations)
|
||||||
|
|
||||||
def instance_update_from_api(self, ctxt, instance, expected_vm_state,
|
def instance_update_from_api(self, ctxt, instance, expected_vm_state,
|
||||||
expected_task_state, admin_state_reset):
|
expected_task_state, admin_state_reset):
|
||||||
|
@ -652,8 +652,10 @@ class CellsManagerClassTestCase(test.NoDBTestCase):
|
|||||||
|
|
||||||
def test_get_migrations(self):
|
def test_get_migrations(self):
|
||||||
filters = {'status': 'confirmed'}
|
filters = {'status': 'confirmed'}
|
||||||
cell1_migrations = [{'id': 123}]
|
cell1_migrations = objects.MigrationList(
|
||||||
cell2_migrations = [{'id': 456}]
|
objects=[objects.Migration(id=123)])
|
||||||
|
cell2_migrations = objects.MigrationList(
|
||||||
|
objects=[objects.Migration(id=456)])
|
||||||
fake_responses = [self._get_fake_response(cell1_migrations),
|
fake_responses = [self._get_fake_response(cell1_migrations),
|
||||||
self._get_fake_response(cell2_migrations)]
|
self._get_fake_response(cell2_migrations)]
|
||||||
self.mox.StubOutWithMock(self.msg_runner,
|
self.mox.StubOutWithMock(self.msg_runner,
|
||||||
@ -664,12 +666,13 @@ class CellsManagerClassTestCase(test.NoDBTestCase):
|
|||||||
|
|
||||||
response = self.cells_manager.get_migrations(self.ctxt, filters)
|
response = self.cells_manager.get_migrations(self.ctxt, filters)
|
||||||
|
|
||||||
self.assertEqual([cell1_migrations[0], cell2_migrations[0]], response)
|
self.assertEqual(cell1_migrations.objects + cell2_migrations.objects,
|
||||||
|
response.objects)
|
||||||
|
|
||||||
def test_get_migrations_for_a_given_cell(self):
|
def test_get_migrations_for_a_given_cell(self):
|
||||||
filters = {'status': 'confirmed', 'cell_name': 'ChildCell1'}
|
filters = {'status': 'confirmed', 'cell_name': 'ChildCell1'}
|
||||||
target_cell = '%s%s%s' % (CONF.cells.name, '!', filters['cell_name'])
|
target_cell = '%s%s%s' % (CONF.cells.name, '!', filters['cell_name'])
|
||||||
migrations = [{'id': 123}]
|
migrations = objects.MigrationList(objects=[objects.Migration(id=123)])
|
||||||
fake_responses = [self._get_fake_response(migrations)]
|
fake_responses = [self._get_fake_response(migrations)]
|
||||||
self.mox.StubOutWithMock(self.msg_runner,
|
self.mox.StubOutWithMock(self.msg_runner,
|
||||||
'get_migrations')
|
'get_migrations')
|
||||||
@ -678,7 +681,7 @@ class CellsManagerClassTestCase(test.NoDBTestCase):
|
|||||||
self.mox.ReplayAll()
|
self.mox.ReplayAll()
|
||||||
|
|
||||||
response = self.cells_manager.get_migrations(self.ctxt, filters)
|
response = self.cells_manager.get_migrations(self.ctxt, filters)
|
||||||
self.assertEqual(migrations, response)
|
self.assertEqual(migrations.objects, response.objects)
|
||||||
|
|
||||||
def test_instance_update_from_api(self):
|
def test_instance_update_from_api(self):
|
||||||
self.mox.StubOutWithMock(self.msg_runner,
|
self.mox.StubOutWithMock(self.msg_runner,
|
||||||
|
Loading…
Reference in New Issue
Block a user