Test alloc candidates with same RC in cn & shared

This change set adds a couple of failing test cases that demonstrate
holes in the design of GET /allocation_candidates when inventory from
the same resource class is present on both the compute node (the "main"
resource provider) and a shared resource provider.

The example being used is where the compute node has some local disk,
and is also associated with a shared storage pool.  Both the compute
node RP and the shared storage RP will provide inventory of DISK_GB.

Test case test_common_rc demonstrates bug #1724613: when I ask for
DISK_GB in this setup, the shared storage pool is ignored.  I expect to
get two candidates back: one with the storage from the compute node; the
other with the storage from the shared storage pool.  But I actually
only get the former candidate back.

Test case test_common_rc_traits_split shows bug #1724633: that placement
can't tell which traits are supposed to apply to which resources.  In
the above scenario, if the local storage is SSD and the shared storage
is RAID, and I ask for SSD + RAID, I "expect" to get back no hits.  But
I would in fact get back a candidate with the storage from the shared
storage pool, because the cumulative set of traits would satisfy my
requested SSD + RAID.

Note that the two tests are functionally identical (traits are ignored
entirely) until https://review.openstack.org/#/c/479766/ lands.  At that
point, depending on how we decide to implement the code that would deal
with this scenario, the test may fail *differently* until bug #1724613
is fixed.

Related-Bug: #1724613
Related-Bug: #1724633

Change-Id: I42edf102379cf329aa2252ab779a9f945f5fc155
This commit is contained in:
Eric Fried 2017-11-07 09:30:21 -06:00
parent 01bee2e32c
commit d4398f715f
1 changed files with 77 additions and 0 deletions

View File

@ -454,3 +454,80 @@ class AllocationCandidatesTestCase(test.NoDBTestCase):
('cn3', fields.ResourceClass.DISK_GB, 1500)],
]
self._validate_allocation_requests(expected, alloc_cands)
def test_common_rc(self):
"""Candidates when cn and shared have inventory in the same class."""
cn = self._create_provider('cn', uuids.agg1)
_add_inventory(cn, fields.ResourceClass.VCPU, 24)
_add_inventory(cn, fields.ResourceClass.MEMORY_MB, 2048)
_add_inventory(cn, fields.ResourceClass.DISK_GB, 1600)
ss = self._create_provider('ss', uuids.agg1)
_set_traits(ss, "MISC_SHARES_VIA_AGGREGATE")
_add_inventory(ss, fields.ResourceClass.DISK_GB, 1600)
alloc_cands = self._get_allocation_candidates()
# One allocation_request should have cn + ss; the other should have
# just the cn.
expected = [
[('cn', fields.ResourceClass.VCPU, 1),
('cn', fields.ResourceClass.MEMORY_MB, 64),
('cn', fields.ResourceClass.DISK_GB, 1500)],
# TODO(efried): Due to bug #1724613, the cn + ss candidate is not
# returned. Uncomment this when the bug is fixed.
# [('cn', fields.ResourceClass.VCPU, 1),
# ('cn', fields.ResourceClass.MEMORY_MB, 64),
# ('ss', fields.ResourceClass.DISK_GB, 1500)],
]
self._validate_allocation_requests(expected, alloc_cands)
def test_common_rc_traits_split(self):
"""Validate filters when traits are split across cn and shared RPs."""
# NOTE(efried): This test case only applies to the scenario where we're
# requesting resources via the RequestGroup where
# use_same_provider=False
cn = self._create_provider('cn', uuids.agg1)
_add_inventory(cn, fields.ResourceClass.VCPU, 24)
_add_inventory(cn, fields.ResourceClass.MEMORY_MB, 2048)
_add_inventory(cn, fields.ResourceClass.DISK_GB, 1600)
# The compute node's disk is SSD
_set_traits(cn, 'HW_CPU_X86_SSE', 'STORAGE_DISK_SSD')
ss = self._create_provider('ss', uuids.agg1)
_add_inventory(ss, fields.ResourceClass.DISK_GB, 1600)
# The shared storage's disk is RAID
_set_traits(ss, 'MISC_SHARES_VIA_AGGREGATE', 'CUSTOM_RAID')
alloc_cands = rp_obj.AllocationCandidates.get_by_filters(
self.ctx, filters={
'resources': self.requested_resources,
'traits': ['HW_CPU_X86_SSE', 'STORAGE_DISK_SSD', 'CUSTOM_RAID']
}
)
# TODO(efried): Okay, bear with me here:
# TODO(efried): Bug #1724633: we'd *like* to get no candidates, because
# there's no single DISK_GB resource with both STORAGE_DISK_SSD and
# CUSTOM_RAID traits. So this is the ideal expected value:
# expected = []
# TODO(efried): But under the design as currently conceived, we would
# get the cn + ss candidate, because that combination satisfies both
# traits:
# expected = [
# [('cn', fields.ResourceClass.VCPU, 1),
# ('cn', fields.ResourceClass.MEMORY_MB, 64),
# ('ss', fields.ResourceClass.DISK_GB, 1500)],
# ]
# TODO(efried): However, until https://review.openstack.org/#/c/479766/
# lands, the traits are ignored, so this behaves just like
# test_common_rc above, which is subject to bug #1724613:
expected = [
[('cn', fields.ResourceClass.VCPU, 1),
('cn', fields.ResourceClass.MEMORY_MB, 64),
('cn', fields.ResourceClass.DISK_GB, 1500)],
]
self._validate_allocation_requests(expected, alloc_cands)