Skip to content

Commit

Permalink
Test macvtap port with resource request
Browse files Browse the repository at this point in the history
This patch adds a functional test to see that ports with vnic_type
macvtap and with bandwidth resource request are supported.

Change-Id: I3297adbbf36e537a548b5b46f7f4e27eb103f0f8
blueprint: bandwidth-resource-provider
  • Loading branch information
Balazs Gibizer committed May 1, 2019
1 parent 5efce38 commit 095d3f9
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 1 deletion.
23 changes: 23 additions & 0 deletions nova/tests/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -1360,6 +1360,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",
Expand Down
48 changes: 47 additions & 1 deletion nova/tests/functional/test_servers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6064,6 +6064,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'
Expand Down Expand Up @@ -6111,6 +6112,8 @@ def setUp(self):
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(
Expand Down Expand Up @@ -6230,7 +6233,8 @@ def _create_sriov_networking_rp_tree(self, compute_rp_uuid):
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)
Expand Down Expand Up @@ -6765,6 +6769,48 @@ def test_one_sriov_port_no_vf_and_bandwidth_available_on_the_same_pf(self):
'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):
Expand Down

0 comments on commit 095d3f9

Please sign in to comment.