From d5b9b0052a25a7a448df0b2523b48e9f2ff279e0 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 5 Aug 2019 15:39:41 +0100 Subject: [PATCH] Fix libvirt driver tests to use LibvirtConfigCapsGuest instances test_driver.LibvirtConnTestCase.test_cpu_info() and test_driver.LibvirtConnTestCase.test_get_instance_capabilities() were incorrectly adding LibvirtConfigGuest fixture objects to the guests attribute of LibvirtConfigCaps, rather than LibvirtConfigCapsGuest objects which is what the parse_dom() method of LibvirtConfigCaps does. LibvirtConfigCaps is intended to capture all useful information returned by libvirt's getCapabilities API call, and LibvirtConfigCapsGuest is intended to capture a small subset of that. In contrast, LibvirtConfigGuest is intended for holding the entire configuration of a libvirt guest domain. So fix this to instead add LibvirtConfigCapsGuest fixtures. Note that despite this bug, the tests previously passed through duck-typing because LibvirtConfigCaps does not define __slots__ or any other mechanism for limiting how attributes can be set on instances. This is required by another commit in the SEV series in the near future which will alter the fields within LibvirtConfigCapsGuest. blueprint: amd-sev-libvirt-support Change-Id: Ic4cbbaf81938fc88980e44c4a17fe388f9c2b92b --- nova/tests/unit/virt/libvirt/test_driver.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/nova/tests/unit/virt/libvirt/test_driver.py b/nova/tests/unit/virt/libvirt/test_driver.py index 52839c8791..55eedbb83d 100644 --- a/nova/tests/unit/virt/libvirt/test_driver.py +++ b/nova/tests/unit/virt/libvirt/test_driver.py @@ -15346,13 +15346,13 @@ class LibvirtConnTestCase(test.NoDBTestCase, caps.host = vconfig.LibvirtConfigCapsHost() caps.host.cpu = cpu - guest = vconfig.LibvirtConfigGuest() + guest = vconfig.LibvirtConfigCapsGuest() guest.ostype = fields.VMMode.HVM guest.arch = fields.Architecture.X86_64 guest.domtype = ["kvm"] caps.guests.append(guest) - guest = vconfig.LibvirtConfigGuest() + guest = vconfig.LibvirtConfigCapsGuest() guest.ostype = fields.VMMode.HVM guest.arch = fields.Architecture.I686 guest.domtype = ["kvm"] @@ -16380,13 +16380,13 @@ class LibvirtConnTestCase(test.NoDBTestCase, def get_host_capabilities_stub(self): caps = vconfig.LibvirtConfigCaps() - guest = vconfig.LibvirtConfigGuest() + guest = vconfig.LibvirtConfigCapsGuest() guest.ostype = 'hvm' guest.arch = fields.Architecture.X86_64 guest.domtype = ['kvm', 'qemu'] caps.guests.append(guest) - guest = vconfig.LibvirtConfigGuest() + guest = vconfig.LibvirtConfigCapsGuest() guest.ostype = 'hvm' guest.arch = fields.Architecture.I686 guest.domtype = ['kvm'] @@ -16394,7 +16394,7 @@ class LibvirtConnTestCase(test.NoDBTestCase, # Include one that is not known to nova to make sure it # does not trip us up. - guest = vconfig.LibvirtConfigGuest() + guest = vconfig.LibvirtConfigCapsGuest() guest.ostype = 'hvm' guest.arch = 'itanic' guest.domtype = ['kvm']