From 095d3f91d1a7adb103b194c7bbaba9d3b8639db0 Mon Sep 17 00:00:00 2001 From: Balazs Gibizer Date: Wed, 6 Mar 2019 11:31:53 +0100 Subject: [PATCH] Test macvtap port with resource request 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 --- nova/tests/fixtures.py | 23 +++++++++++++ nova/tests/functional/test_servers.py | 48 ++++++++++++++++++++++++++- 2 files changed, 70 insertions(+), 1 deletion(-) diff --git a/nova/tests/fixtures.py b/nova/tests/fixtures.py index 0919e5b72d..debc010ace 100644 --- a/nova/tests/fixtures.py +++ b/nova/tests/fixtures.py @@ -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", diff --git a/nova/tests/functional/test_servers.py b/nova/tests/functional/test_servers.py index 13123bc4fb..25f6e62d35 100644 --- a/nova/tests/functional/test_servers.py +++ b/nova/tests/functional/test_servers.py @@ -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' @@ -6111,6 +6112,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( @@ -6230,7 +6233,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) @@ -6765,6 +6769,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):