Browse Source

Add tests for alloc_cands with member_of

This patch add a functional test which describes a bug that when
the `member_of` parameter is present, only non-sharing providers
in the specified aggregates are picked, but the non-sharing
provider brings sharing providers from out of the specified
aggregates.

Change-Id: Ie098bb6fa21b3656a8ea840f4e6d9407311bddcd
Related-Bug: #1763907
Blueprint: alloc-candidates-member-of
changes/99/561399/6
Tetsuro Nakamura 3 years ago
parent
commit
d31e54b35f
  1. 235
      nova/tests/functional/api/openstack/placement/db/test_allocation_candidates.py

235
nova/tests/functional/api/openstack/placement/db/test_allocation_candidates.py

@ -1561,6 +1561,241 @@ class AllocationCandidatesTestCase(tb.PlacementDbBaseTestCase):
}
self._validate_provider_summary_resources(expected, alloc_cands)
def test_sharing_providers_member_of(self):
# Covering the following setup:
#
# CN1 (VCPU) CN2 (VCPU)
# / agg1 \ agg2 / agg2 \ agg3
# SS1 (DISK_GB) SS2 (DISK_GB) SS3 (DISK_GB)
cn1 = self._create_provider('cn1', uuids.agg1, uuids.agg2)
tb.add_inventory(cn1, fields.ResourceClass.VCPU, 24)
cn2 = self._create_provider('cn2', uuids.agg2, uuids.agg3)
tb.add_inventory(cn2, fields.ResourceClass.VCPU, 24)
# ss1 is connected to cn1
ss1 = self._create_provider('ss1', uuids.agg1)
tb.set_traits(ss1, "MISC_SHARES_VIA_AGGREGATE")
tb.add_inventory(ss1, fields.ResourceClass.DISK_GB, 1600)
# ss2 is connected to both cn1 and cn2
ss2 = self._create_provider('ss2', uuids.agg2)
tb.set_traits(ss2, "MISC_SHARES_VIA_AGGREGATE")
tb.add_inventory(ss2, fields.ResourceClass.DISK_GB, 1600)
# ss3 is connected to cn2
ss3 = self._create_provider('ss3', uuids.agg3)
tb.set_traits(ss3, "MISC_SHARES_VIA_AGGREGATE")
tb.add_inventory(ss3, fields.ResourceClass.DISK_GB, 1600)
# Let's get allocation candidates from agg1
alloc_cands = self._get_allocation_candidates(
{'': placement_lib.RequestGroup(
use_same_provider=False,
resources={
'VCPU': 2,
'DISK_GB': 1500,
},
member_of=[[uuids.agg1]]
)}
)
# Bug#1763907: We should get providers only in agg1, but the actual
# is that we get all the resource providers shared by rps in agg1.
# expected = [
# [('cn1', fields.ResourceClass.VCPU, 2),
# ('ss1', fields.ResourceClass.DISK_GB, 1500)],
# ]
expected = [
[('cn1', fields.ResourceClass.VCPU, 2),
('ss1', fields.ResourceClass.DISK_GB, 1500)],
[('cn1', fields.ResourceClass.VCPU, 2),
('ss2', fields.ResourceClass.DISK_GB, 1500)],
]
self._validate_allocation_requests(expected, alloc_cands)
# expected = {
# 'cn1': set([
# (fields.ResourceClass.VCPU, 24, 0),
# ]),
# 'ss1': set([
# (fields.ResourceClass.DISK_GB, 1600, 0),
# ]),
# }
expected = {
'cn1': set([
(fields.ResourceClass.VCPU, 24, 0),
]),
'ss1': set([
(fields.ResourceClass.DISK_GB, 1600, 0),
]),
'ss2': set([
(fields.ResourceClass.DISK_GB, 1600, 0),
]),
}
self._validate_provider_summary_resources(expected, alloc_cands)
# Let's get allocation candidates from agg2
alloc_cands = self._get_allocation_candidates(
{'': placement_lib.RequestGroup(
use_same_provider=False,
resources={
'VCPU': 2,
'DISK_GB': 1500,
},
member_of=[[uuids.agg2]]
)}
)
# expected = [
# [('cn1', fields.ResourceClass.VCPU, 2),
# ('ss2', fields.ResourceClass.DISK_GB, 1500)],
# [('cn2', fields.ResourceClass.VCPU, 2),
# ('ss2', fields.ResourceClass.DISK_GB, 1500)],
# ]
expected = [
[('cn1', fields.ResourceClass.VCPU, 2),
('ss1', fields.ResourceClass.DISK_GB, 1500)],
[('cn1', fields.ResourceClass.VCPU, 2),
('ss2', fields.ResourceClass.DISK_GB, 1500)],
[('cn2', fields.ResourceClass.VCPU, 2),
('ss2', fields.ResourceClass.DISK_GB, 1500)],
[('cn2', fields.ResourceClass.VCPU, 2),
('ss3', fields.ResourceClass.DISK_GB, 1500)],
]
self._validate_allocation_requests(expected, alloc_cands)
# expected = {
# 'cn1': set([
# (fields.ResourceClass.VCPU, 24, 0),
# ]),
# 'cn2': set([
# (fields.ResourceClass.VCPU, 24, 0),
# ]),
# 'ss2': set([
# (fields.ResourceClass.DISK_GB, 1600, 0),
# ]),
# }
expected = {
'cn1': set([
(fields.ResourceClass.VCPU, 24, 0),
]),
'cn2': set([
(fields.ResourceClass.VCPU, 24, 0),
]),
'ss1': set([
(fields.ResourceClass.DISK_GB, 1600, 0),
]),
'ss2': set([
(fields.ResourceClass.DISK_GB, 1600, 0),
]),
'ss3': set([
(fields.ResourceClass.DISK_GB, 1600, 0),
]),
}
self._validate_provider_summary_resources(expected, alloc_cands)
# Let's move to validate multiple member_of scenario
# The request from agg1 *AND* agg2 would provide no candidate
alloc_cands = self._get_allocation_candidates(
{'': placement_lib.RequestGroup(
use_same_provider=False,
resources={
'VCPU': 2,
'DISK_GB': 1500,
},
member_of=[[uuids.agg1], [uuids.agg2]]
)}
)
# expected = []
expected = [
[('cn1', fields.ResourceClass.VCPU, 2),
('ss1', fields.ResourceClass.DISK_GB, 1500)],
[('cn1', fields.ResourceClass.VCPU, 2),
('ss2', fields.ResourceClass.DISK_GB, 1500)],
]
self._validate_allocation_requests(expected, alloc_cands)
# expected = {}
expected = {
'cn1': set([
(fields.ResourceClass.VCPU, 24, 0),
]),
'ss1': set([
(fields.ResourceClass.DISK_GB, 1600, 0),
]),
'ss2': set([
(fields.ResourceClass.DISK_GB, 1600, 0),
]),
}
self._validate_provider_summary_resources(expected, alloc_cands)
# The request from agg1 *OR* agg2 would provide three candidates
alloc_cands = self._get_allocation_candidates(
{'': placement_lib.RequestGroup(
use_same_provider=False,
resources={
'VCPU': 2,
'DISK_GB': 1500,
},
member_of=[[uuids.agg1, uuids.agg2]]
)}
)
# expected = [
# [('cn1', fields.ResourceClass.VCPU, 2),
# ('ss1', fields.ResourceClass.DISK_GB, 1500)],
# [('cn1', fields.ResourceClass.VCPU, 2),
# ('ss2', fields.ResourceClass.DISK_GB, 1500)],
# [('cn2', fields.ResourceClass.VCPU, 2),
# ('ss2', fields.ResourceClass.DISK_GB, 1500)],
# ]
expected = [
[('cn1', fields.ResourceClass.VCPU, 2),
('ss1', fields.ResourceClass.DISK_GB, 1500)],
[('cn1', fields.ResourceClass.VCPU, 2),
('ss2', fields.ResourceClass.DISK_GB, 1500)],
[('cn2', fields.ResourceClass.VCPU, 2),
('ss2', fields.ResourceClass.DISK_GB, 1500)],
[('cn2', fields.ResourceClass.VCPU, 2),
('ss3', fields.ResourceClass.DISK_GB, 1500)],
]
self._validate_allocation_requests(expected, alloc_cands)
# expected = {
# 'cn1': set([
# (fields.ResourceClass.VCPU, 24, 0),
# ]),
# 'cn2': set([
# (fields.ResourceClass.VCPU, 24, 0),
# ]),
# 'ss1': set([
# (fields.ResourceClass.DISK_GB, 1600, 0),
# ]),
# 'ss2': set([
# (fields.ResourceClass.DISK_GB, 1600, 0),
# ]),
# }
expected = {
'cn1': set([
(fields.ResourceClass.VCPU, 24, 0),
]),
'cn2': set([
(fields.ResourceClass.VCPU, 24, 0),
]),
'ss1': set([
(fields.ResourceClass.DISK_GB, 1600, 0),
]),
'ss2': set([
(fields.ResourceClass.DISK_GB, 1600, 0),
]),
'ss3': set([
(fields.ResourceClass.DISK_GB, 1600, 0),
]),
}
self._validate_provider_summary_resources(expected, alloc_cands)
def test_simple_tree_of_providers(self):
"""Tests that we properly winnow allocation requests when including
traits in the request group and that the traits appear in the provider

Loading…
Cancel
Save