Merge "Do not set allocation.id in AllocationList.create_all()" into stable/pike
This commit is contained in:
commit
3e80588f5a
|
@ -1850,8 +1850,7 @@ class AllocationList(base.ObjectListBase, base.NovaObject):
|
||||||
resource_class_id=rc_id,
|
resource_class_id=rc_id,
|
||||||
consumer_id=alloc.consumer_id,
|
consumer_id=alloc.consumer_id,
|
||||||
used=alloc.used)
|
used=alloc.used)
|
||||||
result = conn.execute(ins_stmt)
|
conn.execute(ins_stmt)
|
||||||
alloc.id = result.lastrowid
|
|
||||||
|
|
||||||
# Generation checking happens here. If the inventory for
|
# Generation checking happens here. If the inventory for
|
||||||
# this resource provider changed out from under us,
|
# this resource provider changed out from under us,
|
||||||
|
|
|
@ -841,7 +841,6 @@ class TestAllocation(ResourceProviderBaseCase):
|
||||||
disk_allocation.used)
|
disk_allocation.used)
|
||||||
self.assertEqual(DISK_ALLOCATION['consumer_id'],
|
self.assertEqual(DISK_ALLOCATION['consumer_id'],
|
||||||
disk_allocation.consumer_id)
|
disk_allocation.consumer_id)
|
||||||
self.assertIsInstance(disk_allocation.id, int)
|
|
||||||
|
|
||||||
allocations = objects.AllocationList.get_all_by_resource_provider_uuid(
|
allocations = objects.AllocationList.get_all_by_resource_provider_uuid(
|
||||||
self.ctx, resource_provider.uuid)
|
self.ctx, resource_provider.uuid)
|
||||||
|
@ -997,12 +996,13 @@ class TestAllocation(ResourceProviderBaseCase):
|
||||||
allocations = objects.AllocationList.get_all_by_resource_provider_uuid(
|
allocations = objects.AllocationList.get_all_by_resource_provider_uuid(
|
||||||
self.ctx, rp.uuid)
|
self.ctx, rp.uuid)
|
||||||
self.assertEqual(1, len(allocations))
|
self.assertEqual(1, len(allocations))
|
||||||
objects.Allocation._destroy(self.ctx, allocation.id)
|
allocation_id = allocations[0].id
|
||||||
|
objects.Allocation._destroy(self.ctx, allocation_id)
|
||||||
allocations = objects.AllocationList.get_all_by_resource_provider_uuid(
|
allocations = objects.AllocationList.get_all_by_resource_provider_uuid(
|
||||||
self.ctx, rp.uuid)
|
self.ctx, rp.uuid)
|
||||||
self.assertEqual(0, len(allocations))
|
self.assertEqual(0, len(allocations))
|
||||||
self.assertRaises(exception.NotFound, objects.Allocation._destroy,
|
self.assertRaises(exception.NotFound, objects.Allocation._destroy,
|
||||||
self.ctx, allocation.id)
|
self.ctx, allocation_id)
|
||||||
|
|
||||||
def test_get_allocations_from_db(self):
|
def test_get_allocations_from_db(self):
|
||||||
rp, allocation = self._make_allocation()
|
rp, allocation = self._make_allocation()
|
||||||
|
|
|
@ -513,9 +513,13 @@ class TestAllocation(test_objects._LocalTest):
|
||||||
consumer_id=uuids.fake_instance,
|
consumer_id=uuids.fake_instance,
|
||||||
used=8)
|
used=8)
|
||||||
alloc_list = objects.AllocationList(self.context, objects=[obj])
|
alloc_list = objects.AllocationList(self.context, objects=[obj])
|
||||||
self.assertNotIn("id", obj)
|
|
||||||
alloc_list.create_all()
|
alloc_list.create_all()
|
||||||
self.assertIn("id", obj)
|
|
||||||
|
rp_al = resource_provider.AllocationList
|
||||||
|
saved_allocations = rp_al.get_all_by_resource_provider_uuid(
|
||||||
|
self.context, rp.uuid)
|
||||||
|
self.assertEqual(1, len(saved_allocations))
|
||||||
|
self.assertEqual(obj.used, saved_allocations[0].used)
|
||||||
|
|
||||||
def test_create_with_id_fails(self):
|
def test_create_with_id_fails(self):
|
||||||
rp = objects.ResourceProvider(context=self.context,
|
rp = objects.ResourceProvider(context=self.context,
|
||||||
|
|
Loading…
Reference in New Issue