Browse Source

tests: Move libvirt-specific fixtures

These were left to last since there's a bit of cleanup necessary to move
everything across.

Change-Id: I921c812ac03f7d32eec31200772020c17f292851
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
changes/69/790969/3
Stephen Finucane 8 months ago
parent
commit
33be6d4b56
  1. 2
      nova/tests/fixtures/__init__.py
  2. 37
      nova/tests/fixtures/imagebackend.py
  3. 6
      nova/tests/fixtures/libvirt.py
  4. 0
      nova/tests/fixtures/libvirt_data.py
  5. 7
      nova/tests/functional/libvirt/base.py
  6. 4
      nova/tests/functional/libvirt/integrated_helpers.py
  7. 4
      nova/tests/functional/libvirt/test_evacuate.py
  8. 4
      nova/tests/functional/libvirt/test_numa_live_migration.py
  9. 2
      nova/tests/functional/libvirt/test_numa_servers.py
  10. 4
      nova/tests/functional/libvirt/test_pci_sriov_servers.py
  11. 2
      nova/tests/functional/libvirt/test_report_cpu_traits.py
  12. 2
      nova/tests/functional/libvirt/test_reshape.py
  13. 2
      nova/tests/functional/libvirt/test_vgpu.py
  14. 6
      nova/tests/functional/libvirt/test_vpmem.py
  15. 5
      nova/tests/functional/notification_sample_tests/test_libvirt.py
  16. 4
      nova/tests/functional/regressions/test_bug_1595962.py
  17. 4
      nova/tests/functional/regressions/test_bug_1888395.py
  18. 2
      nova/tests/functional/regressions/test_bug_1899649.py
  19. 2
      nova/tests/functional/regressions/test_bug_1928063.py
  20. 2
      nova/tests/unit/fixtures/test_libvirt.py
  21. 2
      nova/tests/unit/virt/libvirt/test_config.py
  22. 2
      nova/tests/unit/virt/libvirt/test_designer.py
  23. 61
      nova/tests/unit/virt/libvirt/test_driver.py
  24. 9
      nova/tests/unit/virt/libvirt/test_guest.py
  25. 11
      nova/tests/unit/virt/libvirt/test_host.py
  26. 5
      nova/tests/unit/virt/libvirt/test_migration.py
  27. 11
      nova/tests/unit/virt/libvirt/test_utils.py
  28. 5
      nova/tests/unit/virt/libvirt/test_vif.py
  29. 6
      nova/tests/unit/virt/libvirt/volume/test_volume.py
  30. 11
      nova/tests/unit/virt/test_virt_drivers.py

2
nova/tests/fixtures/__init__.py

@ -17,6 +17,8 @@ from .cinder import CinderFixture # noqa: F401
from .conf import ConfFixture # noqa: F401, F403
from .cyborg import CyborgFixture # noqa: F401
from .glance import GlanceFixture # noqa: F401
from .imagebackend import ImageBackendFixture # noqa: F401
from .libvirt import LibvirtFixture # noqa: F401
from .neutron import NeutronFixture # noqa: F401
from .nova import * # noqa: F401, F403
from .policy import OverridePolicyFixture # noqa: F401

37
nova/tests/unit/virt/libvirt/fake_imagebackend.py → nova/tests/fixtures/imagebackend.py

@ -27,17 +27,17 @@ from nova.virt.libvirt import utils as libvirt_utils
class ImageBackendFixture(fixtures.Fixture):
def __init__(self, got_files=None, imported_files=None, exists=None):
"""This fixture mocks imagebackend.Backend.backend, which is the
only entry point to libvirt.imagebackend from libvirt.driver.
:param got_files: A list of {'filename': path, 'size': size} for every
file which was created.
file which was created.
:param imported_files: A list of (local_filename, remote_filename) for
every invocation of import_file().
every invocation of import_file().
:param exists: An optional lambda which takes the disk name as an
argument, and returns True if the disk exists,
False otherwise.
argument, and returns True if the disk exists, False otherwise.
"""
self.got_files = got_files
self.imported_files = imported_files
@ -49,27 +49,27 @@ class ImageBackendFixture(fixtures.Fixture):
self._exists = exists
def setUp(self):
super(ImageBackendFixture, self).setUp()
super().setUp()
# Mock template functions passed to cache
self.mock_fetch_image = mock.create_autospec(libvirt_utils.fetch_image)
self.useFixture(fixtures.MonkeyPatch(
'nova.virt.libvirt.utils.fetch_image', self.mock_fetch_image))
self.mock_fetch_raw_image = \
mock.create_autospec(libvirt_utils.fetch_raw_image)
self.mock_fetch_raw_image = mock.create_autospec(
libvirt_utils.fetch_raw_image)
self.useFixture(fixtures.MonkeyPatch(
'nova.virt.libvirt.utils.fetch_raw_image',
self.mock_fetch_raw_image))
self.mock_create_ephemeral = \
mock.create_autospec(driver.LibvirtDriver._create_ephemeral)
self.mock_create_ephemeral = mock.create_autospec(
driver.LibvirtDriver._create_ephemeral)
self.useFixture(fixtures.MonkeyPatch(
'nova.virt.libvirt.driver.LibvirtDriver._create_ephemeral',
self.mock_create_ephemeral))
self.mock_create_swap = \
mock.create_autospec(driver.LibvirtDriver._create_swap)
self.mock_create_swap = mock.create_autospec(
driver.LibvirtDriver._create_swap)
self.useFixture(fixtures.MonkeyPatch(
'nova.virt.libvirt.driver.LibvirtDriver._create_swap',
self.mock_create_swap))
@ -84,10 +84,11 @@ class ImageBackendFixture(fixtures.Fixture):
"""disks, filtered to contain only disks which were actually created
by calling a relevant method.
"""
# A disk was created iff either cache() or import_file() was called.
return {name: disk for name, disk in self.disks.items()
if any([disk.cache.called, disk.import_file.called])}
return {
name: disk for name, disk in self.disks.items()
if any([disk.cache.called, disk.import_file.called])
}
def _mock_disk(self):
# This is the generator passed to the disks defaultdict. It returns
@ -119,8 +120,8 @@ class ImageBackendFixture(fixtures.Fixture):
disk.libvirt_info.side_effect = functools.partial(
self._fake_libvirt_info, disk)
disk.direct_snapshot.side_effect = (
NotImplementedError('direct_snapshot() is not implemented'))
disk.direct_snapshot.side_effect = NotImplementedError(
'direct_snapshot() is not implemented')
return disk
@ -196,8 +197,8 @@ class ImageBackendFixture(fixtures.Fixture):
return False
setattr(image_init, 'is_shared_block_storage', is_shared_block_storage)
setattr(image_init, 'is_file_in_instance_path',
is_file_in_instance_path)
setattr(
image_init, 'is_file_in_instance_path', is_file_in_instance_path)
return image_init

6
nova/tests/unit/virt/libvirt/fakelibvirt.py → nova/tests/fixtures/libvirt.py

@ -28,7 +28,7 @@ from oslo_utils import versionutils
from nova import conf
from nova.objects import fields as obj_fields
from nova.tests.unit.virt.libvirt import fake_libvirt_data
from nova.tests.fixtures import libvirt_data as fake_libvirt_data
from nova.virt.libvirt import config as vconfig
from nova.virt.libvirt import driver as libvirt_driver
@ -2118,14 +2118,14 @@ class FakeHandler(object):
_EventAddHandleFunc = FakeHandler
class FakeLibvirtFixture(fixtures.Fixture):
class LibvirtFixture(fixtures.Fixture):
"""Performs global setup/stubbing for all libvirt tests.
"""
def __init__(self, stub_os_vif=True):
self.stub_os_vif = stub_os_vif
def setUp(self):
super(FakeLibvirtFixture, self).setUp()
super().setUp()
# Some modules load the libvirt library in a strange way
for module in ('driver', 'host', 'guest', 'migration'):

0
nova/tests/unit/virt/libvirt/fake_libvirt_data.py → nova/tests/fixtures/libvirt_data.py

7
nova/tests/functional/libvirt/base.py

@ -21,9 +21,8 @@ import mock
from nova import conf
from nova.tests import fixtures as nova_fixtures
from nova.tests.fixtures import libvirt as fakelibvirt
from nova.tests.functional import integrated_helpers
from nova.tests.unit.virt.libvirt import fake_imagebackend
from nova.tests.unit.virt.libvirt import fakelibvirt
CONF = conf.CONF
@ -42,8 +41,8 @@ class ServersTestBase(integrated_helpers._IntegratedTestBase):
super(ServersTestBase, self).setUp()
self.useFixture(fake_imagebackend.ImageBackendFixture())
self.useFixture(fakelibvirt.FakeLibvirtFixture())
self.useFixture(nova_fixtures.ImageBackendFixture())
self.useFixture(nova_fixtures.LibvirtFixture())
self.useFixture(fixtures.MockPatch(
'nova.virt.libvirt.LibvirtDriver._create_image',

4
nova/tests/functional/libvirt/integrated_helpers.py

@ -13,8 +13,8 @@
import fixtures
from nova import conf
from nova.tests import fixtures as nova_fixtures
from nova.tests.functional import integrated_helpers
from nova.tests.unit.virt.libvirt import fakelibvirt
CONF = conf.CONF
@ -31,7 +31,7 @@ class LibvirtProviderUsageBaseTestCase(
def setUp(self):
super(LibvirtProviderUsageBaseTestCase, self).setUp()
self.useFixture(fakelibvirt.FakeLibvirtFixture(stub_os_vif=False))
self.useFixture(nova_fixtures.LibvirtFixture(stub_os_vif=False))
if self.STUB_INIT_HOST:
self.useFixture(
fixtures.MockPatch(

4
nova/tests/functional/libvirt/test_evacuate.py

@ -27,11 +27,11 @@ from nova import exception
from nova import objects
from nova import test
from nova.tests import fixtures as nova_fixtures
from nova.tests.fixtures import libvirt as fakelibvirt
from nova.tests.functional import fixtures as func_fixtures
from nova.tests.functional import integrated_helpers
from nova.tests.unit import fake_network
from nova.tests.unit import fake_notifier
from nova.tests.unit.virt.libvirt import fakelibvirt
from nova.virt.libvirt import config as libvirt_config
CONF = conf.CONF
@ -434,7 +434,7 @@ class _LibvirtEvacuateTest(integrated_helpers.InstanceHelperMixin):
fake_notifier.stub_notifier(self)
self.addCleanup(fake_notifier.reset)
self.useFixture(fakelibvirt.FakeLibvirtFixture())
self.useFixture(nova_fixtures.LibvirtFixture())
# Fake out all the details of volume connection
self.useFixture(fixtures.MockPatch(

4
nova/tests/functional/libvirt/test_numa_live_migration.py

@ -23,10 +23,10 @@ from nova.compute import resource_tracker as rt
from nova import context
from nova import objects
from nova import test
from nova.tests.fixtures import libvirt as fakelibvirt
from nova.tests.functional import integrated_helpers
from nova.tests.functional.libvirt import base
from nova.tests.unit.virt.libvirt import fake_os_brick_connector
from nova.tests.unit.virt.libvirt import fakelibvirt
CONF = cfg.CONF
@ -109,7 +109,7 @@ class NUMALiveMigrationPositiveBase(NUMALiveMigrationBase):
def setUp(self):
super(NUMALiveMigrationPositiveBase, self).setUp()
self.useFixture(fixtures.MonkeyPatch(
'nova.tests.unit.virt.libvirt.fakelibvirt.Domain.migrateToURI3',
'nova.tests.fixtures.libvirt.Domain.migrateToURI3',
self._migrate_stub))
self.migrate_stub_ran = False

2
nova/tests/functional/libvirt/test_numa_servers.py

@ -24,10 +24,10 @@ from nova.conf import neutron as neutron_conf
from nova import context as nova_context
from nova import objects
from nova.tests import fixtures as nova_fixtures
from nova.tests.fixtures import libvirt as fakelibvirt
from nova.tests.functional.api import client
from nova.tests.functional.libvirt import base
from nova.tests.unit import fake_notifier
from nova.tests.unit.virt.libvirt import fakelibvirt
CONF = cfg.CONF
LOG = logging.getLogger(__name__)

4
nova/tests/functional/libvirt/test_pci_sriov_servers.py

@ -32,11 +32,11 @@ from nova.network import constants
from nova import objects
from nova.objects import fields
from nova.tests import fixtures as nova_fixtures
from nova.tests.fixtures import libvirt as fakelibvirt
from nova.tests.functional.api import client
from nova.tests.functional.libvirt import base
from nova.tests.unit import fake_notifier
from nova.tests.unit.virt.libvirt import fake_os_brick_connector
from nova.tests.unit.virt.libvirt import fakelibvirt
CONF = cfg.CONF
LOG = logging.getLogger(__name__)
@ -126,7 +126,7 @@ class SRIOVServersTest(_PCIServersTestBase):
'nova.virt.libvirt.driver.connector',
fake_os_brick_connector))
self.useFixture(fixtures.MonkeyPatch(
'nova.tests.unit.virt.libvirt.fakelibvirt.Domain.migrateToURI3',
'nova.tests.fixtures.libvirt.Domain.migrateToURI3',
self._migrate_stub))
def _migrate_stub(self, domain, destination, params, flags):

2
nova/tests/functional/libvirt/test_report_cpu_traits.py

@ -21,8 +21,8 @@ import os_traits as ost
from nova import conf
from nova.db import constants as db_const
from nova import test
from nova.tests.fixtures import libvirt as fakelibvirt
from nova.tests.functional.libvirt import integrated_helpers
from nova.tests.unit.virt.libvirt import fakelibvirt
from nova.virt.libvirt.host import SEV_KERNEL_PARAM_FILE
CONF = conf.CONF

2
nova/tests/functional/libvirt/test_reshape.py

@ -19,8 +19,8 @@ from oslo_log import log as logging
from nova import context
from nova import objects
from nova.tests.fixtures import libvirt as fakelibvirt
from nova.tests.functional.libvirt import base
from nova.tests.unit.virt.libvirt import fakelibvirt
from nova.virt.libvirt import utils

2
nova/tests/functional/libvirt/test_vgpu.py

@ -24,8 +24,8 @@ from nova.compute import instance_actions
import nova.conf
from nova import context
from nova import objects
from nova.tests.fixtures import libvirt as fakelibvirt
from nova.tests.functional.libvirt import base
from nova.tests.unit.virt.libvirt import fakelibvirt
from nova.virt.libvirt import driver as libvirt_driver
from nova.virt.libvirt import utils as libvirt_utils

6
nova/tests/functional/libvirt/test_vpmem.py

@ -17,9 +17,9 @@ from oslo_config import cfg
from oslo_log import log as logging
from nova import objects
from nova.tests import fixtures as nova_fixtures
from nova.tests.fixtures import libvirt as fakelibvirt
from nova.tests.functional.libvirt import integrated_helpers
from nova.tests.unit.virt.libvirt import fake_imagebackend
from nova.tests.unit.virt.libvirt import fakelibvirt
CONF = cfg.CONF
@ -74,7 +74,7 @@ class VPMEMTestBase(integrated_helpers.LibvirtProviderUsageBaseTestCase):
self.useFixture(fixtures.MockPatch(
'nova.privsep.libvirt.get_pmem_namespaces',
return_value=self.fake_pmem_namespaces))
self.useFixture(fake_imagebackend.ImageBackendFixture())
self.useFixture(nova_fixtures.ImageBackendFixture())
self.useFixture(fixtures.MockPatch(
'nova.virt.libvirt.LibvirtDriver._get_local_gb_info',
return_value={'total': 128,

5
nova/tests/functional/notification_sample_tests/test_libvirt.py

@ -17,10 +17,11 @@ import mock
import nova.conf
from nova import exception
from nova.tests import fixtures as nova_fixtures
from nova.tests.fixtures import libvirt as fakelibvirt
from nova.tests.functional.notification_sample_tests \
import notification_sample_base
from nova.tests.unit import fake_notifier
from nova.tests.unit.virt.libvirt import fakelibvirt
from nova.virt.libvirt import host
@ -32,7 +33,7 @@ class TestLibvirtErrorNotificationSample(
def setUp(self):
self.flags(compute_driver='libvirt.LibvirtDriver')
self.useFixture(fakelibvirt.FakeLibvirtFixture())
self.useFixture(nova_fixtures.LibvirtFixture())
self.useFixture(fixtures.MockPatchObject(host.Host, 'initialize'))
super(TestLibvirtErrorNotificationSample, self).setUp()

4
nova/tests/functional/regressions/test_bug_1595962.py

@ -20,8 +20,8 @@ import mock
from nova import test
from nova.tests import fixtures as nova_fixtures
from nova.tests.fixtures import libvirt as fakelibvirt
from nova.tests.functional import fixtures as func_fixtures
from nova.tests.unit.virt.libvirt import fakelibvirt
from nova.virt.libvirt import guest as libvirt_guest
@ -46,7 +46,7 @@ class TestSerialConsoleLiveMigrate(test.TestCase):
self.useFixture(fixtures.MonkeyPatch(
'nova.virt.libvirt.guest.libvirt',
fakelibvirt))
self.useFixture(fakelibvirt.FakeLibvirtFixture())
self.useFixture(nova_fixtures.LibvirtFixture())
self.admin_api = api_fixture.admin_api
self.api = api_fixture.api

4
nova/tests/functional/regressions/test_bug_1888395.py

@ -18,9 +18,9 @@ from urllib import parse as urlparse
from nova import context
from nova.network import constants as neutron_constants
from nova.network import neutron
from nova.tests.fixtures import libvirt as fakelibvirt
from nova.tests.functional.libvirt import base as libvirt_base
from nova.tests.unit.virt.libvirt import fake_os_brick_connector
from nova.tests.unit.virt.libvirt import fakelibvirt
class TestLiveMigrationWithoutMultiplePortBindings(
@ -73,7 +73,7 @@ class TestLiveMigrationWithoutMultiplePortBindings(
self.ctxt = context.get_admin_context()
# TODO(sean-k-mooney): remove this when it is part of ServersTestBase
self.useFixture(fixtures.MonkeyPatch(
'nova.tests.unit.virt.libvirt.fakelibvirt.Domain.migrateToURI3',
'nova.tests.fixtures.libvirt.Domain.migrateToURI3',
self._migrate_stub))
def _migrate_stub(self, domain, destination, params, flags):

2
nova/tests/functional/regressions/test_bug_1899649.py

@ -13,8 +13,8 @@
# under the License.
from nova.tests import fixtures as nova_fixtures
from nova.tests.fixtures import libvirt as fakelibvirt
from nova.tests.functional.libvirt import base
from nova.tests.unit.virt.libvirt import fakelibvirt
class TestVolAttachmentsAfterFailureToScheduleOrBuild(base.ServersTestBase):

2
nova/tests/functional/regressions/test_bug_1928063.py

@ -16,9 +16,9 @@ import mock
from oslo_utils.fixture import uuidsentinel as uuids
from nova import test
from nova.tests.fixtures import libvirt as fakelibvirt
from nova.tests.functional.api import client
from nova.tests.functional.libvirt import base
from nova.tests.unit.virt.libvirt import fakelibvirt
from nova.virt.libvirt.host import SEV_KERNEL_PARAM_FILE

2
nova/tests/unit/virt/libvirt/test_fakelibvirt.py → nova/tests/unit/fixtures/test_libvirt.py

@ -18,7 +18,7 @@ from oslo_utils import uuidutils
from nova.objects import fields as obj_fields
from nova import test
import nova.tests.unit.virt.libvirt.fakelibvirt as libvirt
from nova.tests.fixtures import libvirt
from nova.virt.libvirt import config as vconfig

2
nova/tests/unit/virt/libvirt/test_config.py

@ -18,7 +18,7 @@ from oslo_utils import units
from nova.objects import fields as obj_fields
from nova import test
from nova.tests.unit.virt.libvirt import fake_libvirt_data
from nova.tests.fixtures import libvirt_data as fake_libvirt_data
from nova.virt import hardware
from nova.virt.libvirt import config

2
nova/tests/unit/virt/libvirt/test_designer.py

@ -16,8 +16,8 @@ import mock
from nova.pci import utils as pci_utils
from nova import test
from nova.tests.fixtures import libvirt_data as fake_libvirt_data
from nova.tests.unit import matchers
from nova.tests.unit.virt.libvirt import fake_libvirt_data
from nova.virt.libvirt import config
from nova.virt.libvirt import designer

61
nova/tests/unit/virt/libvirt/test_driver.py

@ -83,6 +83,8 @@ import nova.privsep.libvirt
from nova.storage import rbd_utils
from nova import test
from nova.tests import fixtures as nova_fixtures
from nova.tests.fixtures import libvirt as fakelibvirt
from nova.tests.fixtures import libvirt_data as fake_libvirt_data
from nova.tests.unit import fake_block_device
from nova.tests.unit import fake_diagnostics
from nova.tests.unit import fake_flavor
@ -94,9 +96,6 @@ from nova.tests.unit.objects import test_diagnostics
from nova.tests.unit.objects import test_pci_device
from nova.tests.unit.objects import test_vcpu_model
from nova.tests.unit import utils as test_utils
from nova.tests.unit.virt.libvirt import fake_imagebackend
from nova.tests.unit.virt.libvirt import fake_libvirt_data
from nova.tests.unit.virt.libvirt import fakelibvirt
from nova import utils
from nova import version
from nova.virt import block_device as driver_block_device
@ -743,7 +742,7 @@ class LibvirtConnTestCase(test.NoDBTestCase,
'resolve_driver_format',
imagebackend.Image._get_driver_format)
self.useFixture(fakelibvirt.FakeLibvirtFixture())
self.useFixture(nova_fixtures.LibvirtFixture())
# ensure tests perform the same on all host architectures; this is
# already done by the fakelibvirt fixture but we want to change the
@ -13491,7 +13490,7 @@ class LibvirtConnTestCase(test.NoDBTestCase,
def test_create_images_and_backing_disk_info_none(self):
instance = objects.Instance(**self.test_instance)
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
fake_backend = self.useFixture(fake_imagebackend.ImageBackendFixture())
fake_backend = self.useFixture(nova_fixtures.ImageBackendFixture())
drvr._create_images_and_backing(self.context, instance,
"/fake/instance/dir", None)
@ -14440,7 +14439,7 @@ class LibvirtConnTestCase(test.NoDBTestCase,
instance.config_drive = ''
image_meta = objects.ImageMeta.from_dict(self.test_image_meta)
self.useFixture(fake_imagebackend.ImageBackendFixture())
self.useFixture(nova_fixtures.ImageBackendFixture())
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
with test.nested(
@ -14556,7 +14555,7 @@ class LibvirtConnTestCase(test.NoDBTestCase,
post_xml_callback()
fake_backend = self.useFixture(
fake_imagebackend.ImageBackendFixture(exists=lambda _: False))
nova_fixtures.ImageBackendFixture(exists=lambda _: False))
mock_get_info.return_value = instance_info
mock_create_guest_with_network.side_effect = \
@ -14576,7 +14575,7 @@ class LibvirtConnTestCase(test.NoDBTestCase,
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
image_meta = objects.ImageMeta.from_dict(self.test_image_meta)
fake_backend = self.useFixture(fake_imagebackend.ImageBackendFixture())
fake_backend = self.useFixture(nova_fixtures.ImageBackendFixture())
self.stub_out('nova.virt.libvirt.driver.LibvirtDriver._get_guest_xml',
lambda *a, **kw: None)
@ -14604,7 +14603,7 @@ class LibvirtConnTestCase(test.NoDBTestCase,
instance.root_device_name = '/dev/vda'
instance.uuid = uuids.instance_uuid
backend = self.useFixture(fake_imagebackend.ImageBackendFixture())
backend = self.useFixture(nova_fixtures.ImageBackendFixture())
with test.nested(
mock.patch.object(drvr, '_get_guest_xml'),
@ -14781,7 +14780,7 @@ class LibvirtConnTestCase(test.NoDBTestCase,
image_meta = objects.ImageMeta.from_dict(self.test_image_meta)
self.useFixture(fake_imagebackend.ImageBackendFixture())
self.useFixture(nova_fixtures.ImageBackendFixture())
with mock.patch.object(drvr, '_get_connection',
return_value=mock_connection):
@ -14803,7 +14802,7 @@ class LibvirtConnTestCase(test.NoDBTestCase,
instance.
"""
self.flags(swtpm_enabled=True, group='libvirt')
self.useFixture(fake_imagebackend.ImageBackendFixture())
self.useFixture(nova_fixtures.ImageBackendFixture())
mock_get_info.return_value = hardware.InstanceInfo(
state=power_state.RUNNING)
@ -14848,7 +14847,7 @@ class LibvirtConnTestCase(test.NoDBTestCase,
image_meta)
self.useFixture(
fake_imagebackend.ImageBackendFixture(got_files=gotFiles))
nova_fixtures.ImageBackendFixture(got_files=gotFiles))
drvr._create_image(self.context, instance, disk_info['mapping'])
drvr._get_guest_xml(self.context, instance, None,
@ -14906,7 +14905,7 @@ class LibvirtConnTestCase(test.NoDBTestCase,
driver = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
fake_backend = self.useFixture(
fake_imagebackend.ImageBackendFixture(got_files=gotFiles))
nova_fixtures.ImageBackendFixture(got_files=gotFiles))
with test.nested(
mock.patch.object(driver, '_get_guest_xml'),
@ -14960,7 +14959,7 @@ class LibvirtConnTestCase(test.NoDBTestCase,
instance.config_drive = 'True'
backend = self.useFixture(
fake_imagebackend.ImageBackendFixture(exists=lambda path: False))
nova_fixtures.ImageBackendFixture(exists=lambda path: False))
mock_build_device_metadata.return_value = None
injection_info = get_injection_info(
@ -15013,7 +15012,7 @@ class LibvirtConnTestCase(test.NoDBTestCase,
instance, image_meta,
block_device_info=bdi)
backend = self.useFixture(fake_imagebackend.ImageBackendFixture())
backend = self.useFixture(nova_fixtures.ImageBackendFixture())
drvr._create_image(self.context, instance, disk_info['mapping'],
block_device_info=bdi, **create_image_kwargs)
@ -15094,7 +15093,7 @@ class LibvirtConnTestCase(test.NoDBTestCase,
instance, image_meta,
block_device_info=bdi)
mock_get_ext.return_value = mock.sentinel.file_ext
backend = self.useFixture(fake_imagebackend.ImageBackendFixture())
backend = self.useFixture(nova_fixtures.ImageBackendFixture())
drvr._create_image(self.context, instance, disk_info['mapping'],
block_device_info=bdi)
@ -15119,7 +15118,7 @@ class LibvirtConnTestCase(test.NoDBTestCase,
instance,
image_meta)
fake_backend = self.useFixture(fake_imagebackend.ImageBackendFixture())
fake_backend = self.useFixture(nova_fixtures.ImageBackendFixture())
drvr._create_image(self.context, instance, disk_info['mapping'])
@ -15968,7 +15967,7 @@ class LibvirtConnTestCase(test.NoDBTestCase,
mock_get_disk_info.return_value = \
fake_disk_info_byname(instance).values()
backend = self.useFixture(fake_imagebackend.ImageBackendFixture())
backend = self.useFixture(nova_fixtures.ImageBackendFixture())
accel_info = [{'k1': 'v1', 'k2': 'v2'}]
with mock.patch('os.path.exists', return_value=True):
@ -16560,7 +16559,7 @@ class LibvirtConnTestCase(test.NoDBTestCase,
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
self.stub_out('nova.virt.libvirt.host.Host._get_domain',
lambda self, instance: mock_virdomain)
self.stub_out('nova.tests.unit.virt.libvirt.fakelibvirt.libvirtError.'
self.stub_out('nova.tests.fixtures.libvirt.libvirtError.'
'get_error_code',
lambda self: fakelibvirt.VIR_ERR_OPERATION_TIMEOUT)
instance = objects.Instance(**self.test_instance)
@ -20299,7 +20298,7 @@ class HostStateTestCase(test.NoDBTestCase):
def setUp(self):
super(HostStateTestCase, self).setUp()
self.useFixture(fakelibvirt.FakeLibvirtFixture())
self.useFixture(nova_fixtures.LibvirtFixture())
@mock.patch.object(fakelibvirt, "openAuth")
def test_update_status(self, mock_open):
@ -20344,7 +20343,7 @@ class TestUpdateProviderTree(test.NoDBTestCase):
def setUp(self):
super(TestUpdateProviderTree, self).setUp()
self.useFixture(fakelibvirt.FakeLibvirtFixture())
self.useFixture(nova_fixtures.LibvirtFixture())
self.driver = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
# create compute node resource provider
self.cn_rp = dict(
@ -21114,7 +21113,7 @@ class LibvirtDriverTestCase(test.NoDBTestCase, TraitsComparisonMixin):
super(LibvirtDriverTestCase, self).setUp()
self.flags(sysinfo_serial="none", group="libvirt")
self.flags(instances_path=self.useFixture(fixtures.TempDir()).path)
self.useFixture(fakelibvirt.FakeLibvirtFixture())
self.useFixture(nova_fixtures.LibvirtFixture())
os_vif.initialize()
self.drvr = libvirt_driver.LibvirtDriver(
@ -21719,7 +21718,7 @@ class LibvirtDriverTestCase(test.NoDBTestCase, TraitsComparisonMixin):
disk_info = list(fake_disk_info_byname(instance, type='raw').values())
disk_info_text = jsonutils.dumps(disk_info)
backend = self.useFixture(fake_imagebackend.ImageBackendFixture())
backend = self.useFixture(nova_fixtures.ImageBackendFixture())
mock_create_guest_with_network.return_value = \
libvirt_guest.Guest('fake_dom')
@ -23910,7 +23909,7 @@ class LibvirtDriverTestCase(test.NoDBTestCase, TraitsComparisonMixin):
mock_get_mdev.return_value = {uuids.mdev1: uuids.inst1}
backend = self.useFixture(
fake_imagebackend.ImageBackendFixture(exists=exists))
nova_fixtures.ImageBackendFixture(exists=exists))
if not image_meta_dict:
image_meta_dict = {'id': uuids.image_id, 'name': 'fake'}
@ -26208,7 +26207,7 @@ class LibvirtVolumeUsageTestCase(test.NoDBTestCase):
def setUp(self):
super(LibvirtVolumeUsageTestCase, self).setUp()
self.useFixture(fakelibvirt.FakeLibvirtFixture())
self.useFixture(nova_fixtures.LibvirtFixture())
self.drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
self.c = context.get_admin_context()
@ -26259,7 +26258,7 @@ class LibvirtNonblockingTestCase(test.NoDBTestCase):
def setUp(self):
super(LibvirtNonblockingTestCase, self).setUp()
self.useFixture(fakelibvirt.FakeLibvirtFixture())
self.useFixture(nova_fixtures.LibvirtFixture())
self.flags(connection_uri="test:///default",
group='libvirt')
@ -26309,7 +26308,7 @@ class LibvirtVolumeSnapshotTestCase(test.NoDBTestCase):
def setUp(self):
super(LibvirtVolumeSnapshotTestCase, self).setUp()
self.useFixture(fakelibvirt.FakeLibvirtFixture())
self.useFixture(nova_fixtures.LibvirtFixture())
self.drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
self.c = context.get_admin_context()
@ -27216,7 +27215,7 @@ class _BaseSnapshotTests(test.NoDBTestCase):
self.flags(snapshots_directory='./', group='libvirt')
self.context = context.get_admin_context()
self.useFixture(fakelibvirt.FakeLibvirtFixture())
self.useFixture(nova_fixtures.LibvirtFixture())
self.image_service = self.useFixture(nova_fixtures.GlanceFixture(self))
@ -27629,7 +27628,7 @@ class TestLibvirtSEV(test.NoDBTestCase):
def setUp(self):
super(TestLibvirtSEV, self).setUp()
self.useFixture(fakelibvirt.FakeLibvirtFixture())
self.useFixture(nova_fixtures.LibvirtFixture())
self.driver = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
@ -27683,7 +27682,7 @@ class LibvirtPMEMNamespaceTests(test.NoDBTestCase):
def setUp(self):
super(LibvirtPMEMNamespaceTests, self).setUp()
self.useFixture(fakelibvirt.FakeLibvirtFixture())
self.useFixture(nova_fixtures.LibvirtFixture())
self.context = context.get_admin_context()
self.vpmem_0 = objects.LibvirtVPMEMDevice(
label='4GB',
@ -27926,7 +27925,7 @@ class LibvirtPMEMNamespaceTests(test.NoDBTestCase):
class LibvirtDeviceRemoveEventTestCase(test.NoDBTestCase):
def setUp(self):
super().setUp()
self.useFixture(fakelibvirt.FakeLibvirtFixture())
self.useFixture(nova_fixtures.LibvirtFixture())
@mock.patch.object(libvirt_driver.LOG, 'warning')
@mock.patch('nova.virt.driver.ComputeDriver.emit_event')

9
nova/tests/unit/virt/libvirt/test_guest.py

@ -20,7 +20,8 @@ from oslo_utils import encodeutils
from nova import context
from nova import test
from nova.tests.unit.virt.libvirt import fakelibvirt
from nova.tests import fixtures as nova_fixtures
from nova.tests.fixtures import libvirt as fakelibvirt
from nova.virt.libvirt import config as vconfig
from nova.virt.libvirt import guest as libvirt_guest
from nova.virt.libvirt import host
@ -31,7 +32,7 @@ class GuestTestCase(test.NoDBTestCase):
def setUp(self):
super(GuestTestCase, self).setUp()
self.useFixture(fakelibvirt.FakeLibvirtFixture())
self.useFixture(nova_fixtures.LibvirtFixture())
self.host = host.Host("qemu:///system")
self.context = context.get_admin_context()
@ -701,7 +702,7 @@ class GuestBlockTestCase(test.NoDBTestCase):
def setUp(self):
super(GuestBlockTestCase, self).setUp()
self.useFixture(fakelibvirt.FakeLibvirtFixture())
self.useFixture(nova_fixtures.LibvirtFixture())
self.host = host.Host("qemu:///system")
self.context = context.get_admin_context()
@ -851,7 +852,7 @@ class JobInfoTestCase(test.NoDBTestCase):
def setUp(self):
super(JobInfoTestCase, self).setUp()
self.useFixture(fakelibvirt.FakeLibvirtFixture())
self.useFixture(nova_fixtures.LibvirtFixture())
self.conn = fakelibvirt.openAuth("qemu:///system",
[[], lambda: True])

11
nova/tests/unit/virt/libvirt/test_host.py

@ -31,8 +31,9 @@ from nova import objects
from nova.objects import fields as obj_fields
from nova.pci import utils as pci_utils
from nova import test
from nova.tests.unit.virt.libvirt import fake_libvirt_data
from nova.tests.unit.virt.libvirt import fakelibvirt
from nova.tests import fixtures as nova_fixtures
from nova.tests.fixtures import libvirt as fakelibvirt
from nova.tests.fixtures import libvirt_data as fake_libvirt_data
from nova.virt import event
from nova.virt.libvirt import config as vconfig
from nova.virt.libvirt import event as libvirtevent
@ -67,7 +68,7 @@ class HostTestCase(test.NoDBTestCase):
def setUp(self):
super(HostTestCase, self).setUp()
self.useFixture(fakelibvirt.FakeLibvirtFixture())
self.useFixture(nova_fixtures.LibvirtFixture())
self.host = host.Host("qemu:///system")
@mock.patch("nova.virt.libvirt.host.Host._init_events")
@ -1809,7 +1810,7 @@ class TestLibvirtSEV(test.NoDBTestCase):
def setUp(self):
super(TestLibvirtSEV, self).setUp()
self.useFixture(fakelibvirt.FakeLibvirtFixture())
self.useFixture(nova_fixtures.LibvirtFixture())
self.host = host.Host("qemu:///system")
@ -1876,7 +1877,7 @@ class LibvirtTpoolProxyTestCase(test.NoDBTestCase):
def setUp(self):
super(LibvirtTpoolProxyTestCase, self).setUp()
self.useFixture(fakelibvirt.FakeLibvirtFixture())
self.useFixture(nova_fixtures.LibvirtFixture())
self.host = host.Host("qemu:///system")
def _stub_xml(uuid):

5
nova/tests/unit/virt/libvirt/test_migration.py

@ -26,7 +26,8 @@ from nova import exception
from nova.network import model as network_model
from nova import objects
from nova import test
from nova.tests.unit.virt.libvirt import fakelibvirt
from nova.tests import fixtures as nova_fixtures
from nova.tests.fixtures import libvirt as fakelibvirt
from nova.virt.libvirt import config as vconfig
from nova.virt.libvirt import guest as libvirt_guest
from nova.virt.libvirt import host
@ -926,7 +927,7 @@ class MigrationMonitorTestCase(test.NoDBTestCase):
def setUp(self):
super(MigrationMonitorTestCase, self).setUp()
self.useFixture(fakelibvirt.FakeLibvirtFixture())
self.useFixture(nova_fixtures.LibvirtFixture())
flavor = objects.Flavor(memory_mb=2048,
swap=0,

11
nova/tests/unit/virt/libvirt/test_utils.py

@ -36,7 +36,6 @@ import nova.privsep.qemu
from nova import test
from nova.tests import fixtures as nova_fixtures
from nova.tests.unit import fake_instance
from nova.tests.unit.virt.libvirt import fakelibvirt
from nova.virt import images
from nova.virt.libvirt import guest as libvirt_guest
from nova.virt.libvirt import utils as libvirt_utils
@ -492,7 +491,7 @@ sunrpc /var/lib/nfs/rpc_pipefs rpc_pipefs rw,relatime 0 0
self.assertFalse(libvirt_utils.is_mounted(mount_path, source))
def test_find_disk_file_device(self):
self.useFixture(fakelibvirt.FakeLibvirtFixture())
self.useFixture(nova_fixtures.LibvirtFixture())
xml = """
<domain type='kvm'>
<os>
@ -514,7 +513,7 @@ sunrpc /var/lib/nfs/rpc_pipefs rpc_pipefs rw,relatime 0 0
self.assertEqual('qcow2', format)
def test_find_disk_block_device(self):
self.useFixture(fakelibvirt.FakeLibvirtFixture())
self.useFixture(nova_fixtures.LibvirtFixture())
xml = """
<domain type='kvm'>
<os>
@ -536,7 +535,7 @@ sunrpc /var/lib/nfs/rpc_pipefs rpc_pipefs rw,relatime 0 0
self.assertEqual('raw', format)
def test_find_disk_rbd(self):
self.useFixture(fakelibvirt.FakeLibvirtFixture())
self.useFixture(nova_fixtures.LibvirtFixture())
xml = """
<domain type='kvm'>
<os>
@ -560,7 +559,7 @@ sunrpc /var/lib/nfs/rpc_pipefs rpc_pipefs rw,relatime 0 0
self.assertEqual('raw', format)
def test_find_disk_lxc(self):
self.useFixture(fakelibvirt.FakeLibvirtFixture())
self.useFixture(nova_fixtures.LibvirtFixture())
xml = """
<domain type='lxc'>
<os>
@ -581,7 +580,7 @@ sunrpc /var/lib/nfs/rpc_pipefs rpc_pipefs rw,relatime 0 0
self.assertIsNone(format)
def test_find_disk_parallels(self):
self.useFixture(fakelibvirt.FakeLibvirtFixture())
self.useFixture(nova_fixtures.LibvirtFixture())
xml = """
<domain type='parallels'>
<os>

5
nova/tests/unit/virt/libvirt/test_vif.py

@ -28,8 +28,9 @@ from nova.network import model as network_model
from nova import objects
from nova.pci import utils as pci_utils
from nova import test
from nova.tests import fixtures as nova_fixtures
from nova.tests.fixtures import libvirt as fakelibvirt
from nova.tests.unit.virt import fakelibosinfo
from nova.tests.unit.virt.libvirt import fakelibvirt
from nova.virt.libvirt import config as vconfig
from nova.virt.libvirt import vif
@ -500,7 +501,7 @@ class LibvirtVifTestCase(test.NoDBTestCase):
def setUp(self):
super(LibvirtVifTestCase, self).setUp()
self.useFixture(fakelibvirt.FakeLibvirtFixture(stub_os_vif=False))
self.useFixture(nova_fixtures.LibvirtFixture(stub_os_vif=False))
# os_vif.initialize is typically done in nova-compute startup
os_vif.initialize()

6
nova/tests/unit/virt/libvirt/volume/test_volume.py

@ -19,7 +19,7 @@ from oslo_utils.fixture import uuidsentinel as uuids
from nova import exception
from nova import test
from nova.tests.unit.virt.libvirt import fakelibvirt
from nova.tests import fixtures as nova_fixtures
from nova.virt import fake
from nova.virt.libvirt import driver
from nova.virt.libvirt import host
@ -56,7 +56,7 @@ class LibvirtBaseVolumeDriverSubclassSignatureTestCase(
def _get_base_class(self):
# We do this because it has the side-effect of loading all the
# volume drivers
self.useFixture(fakelibvirt.FakeLibvirtFixture())
self.useFixture(nova_fixtures.LibvirtFixture())
driver.LibvirtDriver(fake.FakeVirtAPI(), False)
return volume.LibvirtBaseVolumeDriver
@ -68,7 +68,7 @@ class LibvirtVolumeBaseTestCase(test.NoDBTestCase):
def setUp(self):
super(LibvirtVolumeBaseTestCase, self).setUp()
self.useFixture(fakelibvirt.FakeLibvirtFixture())
self.useFixture(nova_fixtures.LibvirtFixture())
self.fake_host = host.Host("qemu:///system")

11
nova/tests/unit/virt/test_virt_drivers.py

@ -34,9 +34,9 @@ from nova import exception
from nova import objects
from nova import test
from nova.tests import fixtures as nova_fixtures
from nova.tests.fixtures import libvirt as fakelibvirt
from nova.tests.unit import fake_block_device
from nova.tests.unit import utils as test_utils
from nova.tests.unit.virt.libvirt import fakelibvirt
from nova.virt import block_device as driver_block_device
from nova.virt import event as virtevent
from nova.virt import fake
@ -82,13 +82,10 @@ class _FakeDriverBackendTestCase(object):
else:
self.saved_libvirt = None
from nova.tests.unit.virt.libvirt import fake_imagebackend
from nova.tests.unit.virt.libvirt import fakelibvirt
from nova.tests.unit.virt.libvirt import fake_os_brick_connector
self.useFixture(fake_imagebackend.ImageBackendFixture())
self.useFixture(fakelibvirt.FakeLibvirtFixture())
self.useFixture(nova_fixtures.ImageBackendFixture())
self.useFixture(nova_fixtures.LibvirtFixture())
self.useFixture(fixtures.MonkeyPatch(
'nova.virt.libvirt.driver.connector',
@ -570,7 +567,7 @@ class _VirtDriverTestCase(_FakeDriverBackendTestCase):
self.assertIsInstance(mks_console, ctype.ConsoleMKS)
@mock.patch(
'nova.tests.unit.virt.libvirt.fakelibvirt.Domain.jobStats',
'nova.tests.fixtures.libvirt.Domain.jobStats',
new=mock.Mock(return_value={
'type': fakelibvirt.VIR_DOMAIN_JOB_COMPLETED}))
def test_live_migration(self):

Loading…
Cancel
Save