Increase max_unit in placement test fixture

In the AllocationFixture setup, to avoid the limitation of the
max_unit that is set to the inventory, we were using a bit hacky
way creating multiple allocation objects that have the same resource
class, the same consumer, and the same resource provider.

Since this is not how it works in real cases, and this prevents us
from refactoring, this patch fixes it.

Change-Id: I8ba378ff5eeaf6c9cca11c5874708a17d4640097
This commit is contained in:
Tetsuro Nakamura 2018-08-02 14:00:45 +09:00
parent d4dbb42593
commit e4923abaeb
2 changed files with 9 additions and 19 deletions

View File

@ -159,22 +159,17 @@ class AllocationFixture(APIFixture):
inventory = rp_obj.Inventory(
self.context, resource_provider=rp,
resource_class='DISK_GB', total=2048,
step_size=10, min_unit=10, max_unit=600)
step_size=10, min_unit=10, max_unit=1000)
inventory.obj_set_defaults()
rp.add_inventory(inventory)
alloc1 = rp_obj.Allocation(
alloc = rp_obj.Allocation(
self.context, resource_provider=rp,
resource_class='DISK_GB',
consumer=consumer,
used=500)
alloc2 = rp_obj.Allocation(
self.context, resource_provider=rp,
resource_class='DISK_GB',
consumer=consumer,
used=500)
used=1000)
alloc_list = rp_obj.AllocationList(
self.context,
objects=[alloc1, alloc2]
objects=[alloc]
)
alloc_list.replace_all()
@ -190,22 +185,17 @@ class AllocationFixture(APIFixture):
inventory = rp_obj.Inventory(
self.context, resource_provider=rp,
resource_class='VCPU', total=10,
max_unit=4)
max_unit=10)
inventory.obj_set_defaults()
rp.add_inventory(inventory)
alloc1 = rp_obj.Allocation(
alloc = rp_obj.Allocation(
self.context, resource_provider=rp,
resource_class='VCPU',
consumer=consumer,
used=2)
alloc2 = rp_obj.Allocation(
self.context, resource_provider=rp,
resource_class='VCPU',
consumer=consumer,
used=4)
used=6)
alloc_list = rp_obj.AllocationList(
self.context,
objects=[alloc1, alloc2])
objects=[alloc])
alloc_list.replace_all()
# Create a consumer object for a different user

View File

@ -117,7 +117,7 @@ tests:
$.resource_providers.`len`: 0
- name: list resource providers providing resources (no match - more than max_unit)
GET: /resource_providers?resources=DISK_GB:610
GET: /resource_providers?resources=DISK_GB:1010
response_json_paths:
$.resource_providers.`len`: 0