Skip to content

Commit 1852019

Browse files
committed
Reproducer for bug 1951656
Due to a new mdev naming, we can't parse it. Change-Id: I0f785178b132dfef668829558dea9f7e674abadb Related-Bug: #1951656
1 parent 2eb358c commit 1852019

File tree

1 file changed

+83
-0
lines changed

1 file changed

+83
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
#
2+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
3+
# not use this file except in compliance with the License. You may obtain
4+
# a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
10+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
11+
# License for the specific language governing permissions and limitations
12+
# under the License.
13+
14+
from oslo_utils import uuidutils
15+
16+
17+
from nova.tests.fixtures import libvirt as fakelibvirt
18+
from nova.tests.functional.libvirt import test_vgpu
19+
from nova.virt.libvirt import utils as libvirt_utils
20+
21+
22+
class VGPUTestsLibvirt7_7(test_vgpu.VGPUTestBase):
23+
24+
def _create_mdev(self, physical_device, mdev_type, uuid=None):
25+
# We need to fake the newly created sysfs object by adding a new
26+
# FakeMdevDevice in the existing persisted Connection object so
27+
# when asking to get the existing mdevs, we would see it.
28+
if not uuid:
29+
uuid = uuidutils.generate_uuid()
30+
mdev_name = libvirt_utils.mdev_uuid2name(uuid)
31+
libvirt_parent = self.pci2libvirt_address(physical_device)
32+
33+
# Libvirt 7.7 now creates mdevs with a parent_addr suffix.
34+
new_mdev_name = '_'.join([mdev_name, libvirt_parent])
35+
36+
# Here, we get the right compute thanks by the self.current_host that
37+
# was modified just before
38+
connection = self.computes[
39+
self._current_host].driver._host.get_connection()
40+
connection.mdev_info.devices.update(
41+
{mdev_name: fakelibvirt.FakeMdevDevice(dev_name=new_mdev_name,
42+
type_id=mdev_type,
43+
parent=libvirt_parent)})
44+
return uuid
45+
46+
def setUp(self):
47+
super(VGPUTestsLibvirt7_7, self).setUp()
48+
extra_spec = {"resources:VGPU": "1"}
49+
self.flavor = self._create_flavor(extra_spec=extra_spec)
50+
51+
# Start compute1 supporting only nvidia-11
52+
self.flags(
53+
enabled_mdev_types=fakelibvirt.NVIDIA_11_VGPU_TYPE,
54+
group='devices')
55+
56+
self.compute1 = self.start_compute_with_vgpu('host1')
57+
58+
def test_create_servers_with_vgpu(self):
59+
60+
# Create a single instance against a specific compute node.
61+
self._create_server(
62+
image_uuid='155d900f-4e14-4e4c-a73d-069cbf4541e6',
63+
flavor_id=self.flavor, host=self.compute1.host,
64+
networks='auto', expected_state='ACTIVE')
65+
66+
# TODO(sbauza): Modify this once bug #1851656 is fixed.
67+
# mdev_name2uuid() raises a badly formed hexadecimal UUID string error
68+
self.assertRaises(ValueError,
69+
self.assert_mdev_usage,
70+
self.compute1, expected_amount=1)
71+
72+
# Now, the problem is that we can't create new instances with VGPUs
73+
# from this host.
74+
server = self._create_server(
75+
image_uuid='155d900f-4e14-4e4c-a73d-069cbf4541e6',
76+
flavor_id=self.flavor, host=self.compute1.host,
77+
networks='auto', expected_state='ERROR')
78+
# The error is due to a bad mdev name parsing
79+
self.assertIn('fault', server)
80+
# since we only have one host, we have a RescheduledException as this
81+
# service was creating an exception and we can't use another one.
82+
self.assertIn('Exceeded maximum number of retries',
83+
server['fault']['message'])

0 commit comments

Comments
 (0)