Merge "Test macvtap port with resource request"

This commit is contained in:
Zuul 2019-05-16 23:08:13 +00:00 committed by Gerrit Code Review
commit 5dc5be53e6
2 changed files with 70 additions and 1 deletions

View File

@ -1358,6 +1358,29 @@ class NeutronFixture(fixtures.Fixture):
'binding:vnic_type': 'direct',
}
port_macvtap_with_resource_request = {
'id': 'cbb9707f-3559-4675-a973-4ea89c747f02',
'network_id': network_2['id'],
'admin_state_up': True,
'status': 'ACTIVE',
'mac_address': '52:54:00:1e:59:c6',
# Do neutron really adds fixed_ips to an direct vnic_type port?
'fixed_ips': [
{
'ip_address': '192.168.13.4',
'subnet_id': subnet_2['id']
}
],
'tenant_id': tenant_id,
'resource_request': {
"resources": {
orc.NET_BW_IGR_KILOBIT_PER_SEC: 10000,
orc.NET_BW_EGR_KILOBIT_PER_SEC: 10000},
"required": ["CUSTOM_PHYSNET2", "CUSTOM_VNIC_TYPE_MACVTAP"]
},
'binding:vnic_type': 'macvtap',
}
nw_info = [{
"profile": {},
"ovs_interfaceid": "b71f1699-42be-4515-930a-f3ef01f94aa7",

View File

@ -6148,6 +6148,7 @@ class PortResourceRequestBasedSchedulingTestBase(
CUSTOM_VNIC_TYPE_NORMAL = 'CUSTOM_VNIC_TYPE_NORMAL'
CUSTOM_VNIC_TYPE_DIRECT = 'CUSTOM_VNIC_TYPE_DIRECT'
CUSTOM_VNIC_TYPE_MACVTAP = 'CUSTOM_VNIC_TYPE_MACVTAP'
CUSTOM_PHYSNET1 = 'CUSTOM_PHYSNET1'
CUSTOM_PHYSNET2 = 'CUSTOM_PHYSNET2'
CUSTOM_PHYSNET3 = 'CUSTOM_PHYSNET3'
@ -6195,6 +6196,8 @@ class PortResourceRequestBasedSchedulingTestBase(
self.neutron.network_2['id']] = self.neutron.network_2
self.neutron._subnets[
self.neutron.subnet_2['id']] = self.neutron.subnet_2
macvtap = self.neutron.port_macvtap_with_resource_request
self.neutron._ports[macvtap['id']] = copy.deepcopy(macvtap)
def _create_server(self, flavor, networks):
server_req = self._build_minimal_create_server_request(
@ -6314,7 +6317,8 @@ class PortResourceRequestBasedSchedulingTestBase(
orc.NET_BW_IGR_KILOBIT_PER_SEC: {"total": 100000},
orc.NET_BW_EGR_KILOBIT_PER_SEC: {"total": 100000},
}
traits = [self.CUSTOM_VNIC_TYPE_DIRECT, self.CUSTOM_PHYSNET2]
traits = [self.CUSTOM_VNIC_TYPE_DIRECT, self.CUSTOM_VNIC_TYPE_MACVTAP,
self.CUSTOM_PHYSNET2]
self._create_pf_device_rp(
self.sriov_pf2_rp_uuid, sriov_agent_rp_uuid, inventories, traits,
device_rp_name="%s:NIC Switch agent:ens2" % compute_name)
@ -6931,6 +6935,48 @@ class PortResourceRequestBasedSchedulingTest(
'available for retrying build failures for instance',
server['fault']['message'])
def test_sriov_macvtap_port_with_resource_request(self):
"""Verify that vnic type macvtap is also supported"""
port = self.neutron.port_macvtap_with_resource_request
server = self._create_server(
flavor=self.flavor,
networks=[{'port': port['id']}])
server = self._wait_for_state_change(self.admin_api, server, 'ACTIVE')
port = self.neutron.show_port(port['id'])['port']
allocations = self.placement_api.get(
'/allocations/%s' % server['id']).body['allocations']
# We expect one set of allocations for the compute resources on the
# 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),
compute_allocations)
sriov_allocations = allocations[self.sriov_pf2_rp_uuid]['resources']
self.assertPortMatchesAllocation(
port, sriov_allocations)
# We expect that only the RP uuid of the networking RP having the port
# allocation is sent in the port binding for the port having resource
# request
port_binding = port['binding:profile']
self.assertEqual(
self.sriov_pf2_rp_uuid, port_binding['allocation'])
# 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'])
class PortResourceRequestReSchedulingTest(
PortResourceRequestBasedSchedulingTestBase):