Skip snapshot test when missing qemu-img

Since the commit the remove AMI snapshot format special casing
has merged, we're now running the libvirt snapshot tests as expected.
However, for those tests qemu-img binary needs to be installed.
Because these tests have been silently and incorrectly skipped for so long,
they didn't receive the same maintenance as other tests as the failures went unnoticed.

Change-Id: Ia90eedbe35f4ab2b200bdc90e0e35e5a86cc2110
Closes-bug: #2075178
Signed-off-by: Julien Le Jeune <julien.le-jeune@ovhcloud.com>
(cherry picked from commit 0809f75d79)
This commit is contained in:
Julien Le Jeune 2024-07-30 15:45:48 +02:00
parent 0e6cda2851
commit cd4e58173a
No known key found for this signature in database
GPG Key ID: EB59AD4164D3F024

View File

@ -21,6 +21,7 @@ import fixtures
import netaddr
import os_resource_classes as orc
import os_vif
from oslo_concurrency import processutils
from oslo_log import log as logging
from oslo_serialization import jsonutils
from oslo_utils import importutils
@ -239,8 +240,16 @@ class _VirtDriverTestCase(_FakeDriverBackendTestCase):
def test_snapshot_running(self):
img_ref = self.image_service.create(self.ctxt, {'name': 'snap-1'})
instance_ref, network_info = self._get_running_instance()
# this test depends on qemu-img
# being installed and in the path,
# if it is not installed, skip
try:
self.connection.snapshot(self.ctxt, instance_ref, img_ref['id'],
lambda *args, **kwargs: None)
except processutils.ProcessExecutionError as e:
if 'qemu-img' in e.stderr and 'No such file' in e.stderr:
self.skipTest("qemu-img not installed")
raise e
@catch_notimplementederror
def test_reboot(self):