nova/nova/tests/functional/libvirt
Matthew Booth 32be7a4a02 libvirt: Improve mocking of imagebackend disks
We had grown several similar methods of mocking the imagebackend
module. This patch creates a fixture which covers all existing uses.

As well covering existing uses, it also exposes a new test interface,
the disks dict, which makes it easy for tests to assert calls to
imagebackend for specific disks. This has already uncovered several
bugs in both code and tests which were previously untested.

The ability to assert calls at the imagebackend interface is also
critical to the effort to refactor the internal interfaces of
libvirt.driver. By mocking at the imagebackend interface we can assert
that we continue to manipulate disks as before as we change those
interfaces. For example, it is an explicit goal that change Ie5d47f55
makes almost no test changes, despite making significant code changes
in libvirt.driver.

We can revisit this decision incrementally after establishing new
interfaces, which should also allow us to reduce test duplication. For
example, change Ic7b3058f starts to remove individual tests for image
fetching fallback because these now have a common implementation with
their own tests.

We make some associated fixes in tests:

test_spawn_without_image_meta:
    Change If03b166d accidentally introduced a duplicated test. We
    remove it

test_spawn_with_config_drive:
    This was rewritten in change I931421ea. However, the written test
    neither created nor tested for a config disk. We move it to be
    with the other spawn tests and rewrite it again.

test_spawn_with_pci_devices:
    This test was touching the DB by accessing drvr._conn. We
    additionally mock this to fix the DB access.

Change-Id: Iea6541de4b52a9bcad13795fb48b7dd83d57afdd
2016-08-16 16:24:47 +01:00
..
__init__.py tests: introduce a NUMAServersTest class 2015-04-16 11:43:53 -04:00
test_numa_servers.py libvirt: Improve mocking of imagebackend disks 2016-08-16 16:24:47 +01:00
test_rt_servers.py libvirt: Improve mocking of imagebackend disks 2016-08-16 16:24:47 +01:00