Merge "Refactor bandwidth related functional tests"
This commit is contained in:
commit
4a8ef26a92
@ -5384,6 +5384,13 @@ class PortResourceRequestBasedSchedulingTestBase(
|
||||
macvtap = self.neutron.port_macvtap_with_resource_request
|
||||
self.neutron._ports[macvtap['id']] = copy.deepcopy(macvtap)
|
||||
|
||||
def assertComputeAllocationMatchesFlavor(
|
||||
self, allocations, compute_rp_uuid, flavor):
|
||||
compute_allocations = allocations[compute_rp_uuid]['resources']
|
||||
self.assertEqual(
|
||||
self._resources_from_flavor(flavor),
|
||||
compute_allocations)
|
||||
|
||||
def _create_server(self, flavor, networks):
|
||||
server_req = self._build_minimal_create_server_request(
|
||||
self.api, 'bandwidth-aware-server',
|
||||
@ -5804,12 +5811,11 @@ class PortResourceRequestBasedSchedulingTest(
|
||||
# compute rp and one set for the networking resources on the ovs bridge
|
||||
# rp due to the qos_port resource request
|
||||
self.assertEqual(2, len(allocations))
|
||||
compute_allocations = allocations[self.compute1_rp_uuid]['resources']
|
||||
|
||||
self.assertComputeAllocationMatchesFlavor(
|
||||
allocations, self.compute1_rp_uuid, self.flavor)
|
||||
network_allocations = allocations[
|
||||
self.ovs_bridge_rp_per_host[self.compute1_rp_uuid]]['resources']
|
||||
|
||||
self.assertEqual(self._resources_from_flavor(self.flavor),
|
||||
compute_allocations)
|
||||
self.assertPortMatchesAllocation(qos_port, network_allocations)
|
||||
|
||||
# We expect that only the RP uuid of the networking RP having the port
|
||||
@ -5851,15 +5857,13 @@ class PortResourceRequestBasedSchedulingTest(
|
||||
# compute rp and one set for the networking resources on the ovs bridge
|
||||
# rp and on the sriov PF rp.
|
||||
self.assertEqual(3, len(allocations))
|
||||
compute_allocations = allocations[self.compute1_rp_uuid]['resources']
|
||||
|
||||
self.assertComputeAllocationMatchesFlavor(
|
||||
allocations, self.compute1_rp_uuid, self.flavor_with_group_policy)
|
||||
|
||||
ovs_allocations = allocations[
|
||||
self.ovs_bridge_rp_per_host[self.compute1_rp_uuid]]['resources']
|
||||
sriov_allocations = allocations[self.sriov_pf2_rp_uuid]['resources']
|
||||
|
||||
self.assertEqual(
|
||||
self._resources_from_flavor(self.flavor_with_group_policy),
|
||||
compute_allocations)
|
||||
|
||||
self.assertPortMatchesAllocation(ovs_port, ovs_allocations)
|
||||
self.assertPortMatchesAllocation(sriov_port, sriov_allocations)
|
||||
|
||||
@ -5888,12 +5892,12 @@ class PortResourceRequestBasedSchedulingTest(
|
||||
# compute rp and one set for the networking resources on the ovs bridge
|
||||
# rp due to the port resource request
|
||||
self.assertEqual(2, len(allocations))
|
||||
compute_allocations = allocations[self.compute1_rp_uuid]['resources']
|
||||
|
||||
self.assertComputeAllocationMatchesFlavor(
|
||||
allocations, self.compute1_rp_uuid, self.flavor)
|
||||
|
||||
network_allocations = allocations[
|
||||
self.ovs_bridge_rp_per_host[self.compute1_rp_uuid]]['resources']
|
||||
|
||||
self.assertEqual(self._resources_from_flavor(self.flavor),
|
||||
compute_allocations)
|
||||
self.assertPortMatchesAllocation(port, network_allocations)
|
||||
|
||||
# We expect that only the RP uuid of the networking RP having the port
|
||||
@ -5918,9 +5922,9 @@ class PortResourceRequestBasedSchedulingTest(
|
||||
|
||||
# We expect that the port related resource allocations are removed
|
||||
self.assertEqual(1, len(allocations))
|
||||
compute_allocations = allocations[self.compute1_rp_uuid]['resources']
|
||||
self.assertEqual(self._resources_from_flavor(self.flavor),
|
||||
compute_allocations)
|
||||
|
||||
self.assertComputeAllocationMatchesFlavor(
|
||||
allocations, self.compute1_rp_uuid, self.flavor)
|
||||
|
||||
# We expect that the allocation is removed from the port too
|
||||
binding_profile = updated_port['binding:profile']
|
||||
@ -6051,10 +6055,9 @@ class PortResourceRequestBasedSchedulingTest(
|
||||
# compute rp and one set for the networking resources on the sriov PF2
|
||||
# rp.
|
||||
self.assertEqual(2, len(allocations))
|
||||
compute_allocations = allocations[self.compute1_rp_uuid]['resources']
|
||||
self.assertEqual(
|
||||
self._resources_from_flavor(self.flavor_with_group_policy),
|
||||
compute_allocations)
|
||||
|
||||
self.assertComputeAllocationMatchesFlavor(
|
||||
allocations, self.compute1_rp_uuid, self.flavor_with_group_policy)
|
||||
|
||||
sriov_allocations = allocations[self.sriov_pf2_rp_uuid]['resources']
|
||||
self.assertPortMatchesAllocation(
|
||||
@ -6073,11 +6076,15 @@ class PortResourceRequestBasedSchedulingTest(
|
||||
# We expect that the selected PCI device matches with the RP from
|
||||
# where the bandwidth is allocated from. The bandwidth is allocated
|
||||
# from 0000:02:00 (PF2) so the PCI device should be a VF of that PF
|
||||
self.assertEqual('0000:02:00.1', sriov_with_req_binding['pci_slot'])
|
||||
self.assertEqual(
|
||||
fake.FakeDriverWithPciResources.PCI_ADDR_PF2_VF1,
|
||||
sriov_with_req_binding['pci_slot'])
|
||||
# But also the port that has no resource request still gets a pci slot
|
||||
# allocated. The 0000:02:00 has no more VF available but 0000:03:00 has
|
||||
# one VF available and that PF is also on physnet2
|
||||
self.assertEqual('0000:03:00.1', sriov_binding['pci_slot'])
|
||||
self.assertEqual(
|
||||
fake.FakeDriverWithPciResources.PCI_ADDR_PF3_VF1,
|
||||
sriov_binding['pci_slot'])
|
||||
|
||||
def test_one_sriov_port_no_vf_and_bandwidth_available_on_the_same_pf(self):
|
||||
"""Verify that if there is no PF that both provides bandwidth and VFs
|
||||
@ -6095,7 +6102,9 @@ class PortResourceRequestBasedSchedulingTest(
|
||||
sriov_binding = sriov_port['binding:profile']
|
||||
|
||||
# We expect that this consume the last available VF from the PF2
|
||||
self.assertEqual('0000:02:00.1', sriov_binding['pci_slot'])
|
||||
self.assertEqual(
|
||||
fake.FakeDriverWithPciResources.PCI_ADDR_PF2_VF1,
|
||||
sriov_binding['pci_slot'])
|
||||
|
||||
# Now boot a second server with a port that has resource request
|
||||
# At this point PF2 has available bandwidth but no available VF
|
||||
@ -6141,10 +6150,8 @@ class PortResourceRequestBasedSchedulingTest(
|
||||
# rp.
|
||||
self.assertEqual(2, len(allocations))
|
||||
|
||||
compute_allocations = allocations[self.compute1_rp_uuid]['resources']
|
||||
self.assertEqual(
|
||||
self._resources_from_flavor(self.flavor),
|
||||
compute_allocations)
|
||||
self.assertComputeAllocationMatchesFlavor(
|
||||
allocations, self.compute1_rp_uuid, self.flavor)
|
||||
|
||||
sriov_allocations = allocations[self.sriov_pf2_rp_uuid]['resources']
|
||||
self.assertPortMatchesAllocation(
|
||||
@ -6160,7 +6167,9 @@ class PortResourceRequestBasedSchedulingTest(
|
||||
# We expect that the selected PCI device matches with the RP from
|
||||
# where the bandwidth is allocated from. The bandwidth is allocated
|
||||
# from 0000:02:00 (PF2) so the PCI device should be a VF of that PF
|
||||
self.assertEqual('0000:02:00.1', port_binding['pci_slot'])
|
||||
self.assertEqual(
|
||||
fake.FakeDriverWithPciResources.PCI_ADDR_PF2_VF1,
|
||||
port_binding['pci_slot'])
|
||||
|
||||
|
||||
class PortResourceRequestReSchedulingTest(
|
||||
@ -6207,12 +6216,12 @@ class PortResourceRequestReSchedulingTest(
|
||||
# compute rp and one set for the networking resources on the ovs bridge
|
||||
# rp
|
||||
self.assertEqual(2, len(allocations))
|
||||
compute_allocations = allocations[dest_compute_rp_uuid]['resources']
|
||||
|
||||
self.assertComputeAllocationMatchesFlavor(
|
||||
allocations, dest_compute_rp_uuid, self.flavor)
|
||||
|
||||
network_allocations = allocations[
|
||||
self.ovs_bridge_rp_per_host[dest_compute_rp_uuid]]['resources']
|
||||
|
||||
self.assertEqual(self._resources_from_flavor(self.flavor),
|
||||
compute_allocations)
|
||||
self.assertPortMatchesAllocation(port, network_allocations)
|
||||
|
||||
# assert that the allocations against the host where the spawn
|
||||
|
@ -839,6 +839,13 @@ class FakeLiveMigrateDriverWithNestedCustomResources(
|
||||
|
||||
class FakeDriverWithPciResources(SmallFakeDriver):
|
||||
|
||||
PCI_ADDR_PF1 = '0000:01:00.0'
|
||||
PCI_ADDR_PF1_VF1 = '0000:01:00.1'
|
||||
PCI_ADDR_PF2 = '0000:02:00.0'
|
||||
PCI_ADDR_PF2_VF1 = '0000:02:00.1'
|
||||
PCI_ADDR_PF3 = '0000:03:00.0'
|
||||
PCI_ADDR_PF3_VF1 = '0000:03:00.1'
|
||||
|
||||
# NOTE(gibi): Always use this fixture along with the
|
||||
# FakeDriverWithPciResources to make the necessary configuration for the
|
||||
# driver.
|
||||
@ -898,17 +905,17 @@ class FakeDriverWithPciResources(SmallFakeDriver):
|
||||
def get_available_resource(self, nodename):
|
||||
host_status = super(
|
||||
FakeDriverWithPciResources, self).get_available_resource(nodename)
|
||||
# 01:00 - PF - ens1
|
||||
# 01:00.0 - PF - ens1
|
||||
# |---- 01:00.1 - VF
|
||||
#
|
||||
# 02:00 - PF - ens2
|
||||
# 02:00.0 - PF - ens2
|
||||
# |---- 02:00.1 - VF
|
||||
#
|
||||
# 03:00 - PF - ens3
|
||||
# 03:00.0 - PF - ens3
|
||||
# |---- 03:00.1 - VF
|
||||
host_status['pci_passthrough_devices'] = jsonutils.dumps([
|
||||
{
|
||||
'address': '0000:01:00.0',
|
||||
'address': self.PCI_ADDR_PF1,
|
||||
'product_id': 'fake-product_id',
|
||||
'vendor_id': 'fake-vendor_id',
|
||||
'status': 'available',
|
||||
@ -918,18 +925,18 @@ class FakeDriverWithPciResources(SmallFakeDriver):
|
||||
'label': 'fake-label',
|
||||
},
|
||||
{
|
||||
'address': '0000:01:00.1',
|
||||
'address': self.PCI_ADDR_PF1_VF1,
|
||||
'product_id': 'fake-product_id',
|
||||
'vendor_id': 'fake-vendor_id',
|
||||
'status': 'available',
|
||||
'dev_type': 'type-VF',
|
||||
'parent_addr': '0000:01:00',
|
||||
'parent_addr': self.PCI_ADDR_PF1,
|
||||
'numa_node': 0,
|
||||
'label': 'fake-label',
|
||||
"parent_ifname": "ens1",
|
||||
},
|
||||
{
|
||||
'address': '0000:02:00.0',
|
||||
'address': self.PCI_ADDR_PF2,
|
||||
'product_id': 'fake-product_id',
|
||||
'vendor_id': 'fake-vendor_id',
|
||||
'status': 'available',
|
||||
@ -939,18 +946,18 @@ class FakeDriverWithPciResources(SmallFakeDriver):
|
||||
'label': 'fake-label',
|
||||
},
|
||||
{
|
||||
'address': '0000:02:00.1',
|
||||
'address': self.PCI_ADDR_PF2_VF1,
|
||||
'product_id': 'fake-product_id',
|
||||
'vendor_id': 'fake-vendor_id',
|
||||
'status': 'available',
|
||||
'dev_type': 'type-VF',
|
||||
'parent_addr': '0000:02:00',
|
||||
'parent_addr': self.PCI_ADDR_PF2,
|
||||
'numa_node': 0,
|
||||
'label': 'fake-label',
|
||||
"parent_ifname": "ens2",
|
||||
},
|
||||
{
|
||||
'address': '0000:03:00.0',
|
||||
'address': self.PCI_ADDR_PF3,
|
||||
'product_id': 'fake-product_id',
|
||||
'vendor_id': 'fake-vendor_id',
|
||||
'status': 'available',
|
||||
@ -960,12 +967,12 @@ class FakeDriverWithPciResources(SmallFakeDriver):
|
||||
'label': 'fake-label',
|
||||
},
|
||||
{
|
||||
'address': '0000:03:00.1',
|
||||
'address': self.PCI_ADDR_PF3_VF1,
|
||||
'product_id': 'fake-product_id',
|
||||
'vendor_id': 'fake-vendor_id',
|
||||
'status': 'available',
|
||||
'dev_type': 'type-VF',
|
||||
'parent_addr': '0000:03:00',
|
||||
'parent_addr': self.PCI_ADDR_PF3,
|
||||
'numa_node': 0,
|
||||
'label': 'fake-label',
|
||||
"parent_ifname": "ens3",
|
||||
|
Loading…
x
Reference in New Issue
Block a user