Skip to content

Commit 673103f

Browse files
SeanMooneygibizer
authored andcommitted
fix qemu-img version dependent tests
while backporting Ia34203f246f0bc574e11476287dfb33fda7954fe We observed that several of the tests showed distro specific behavior depending on if qemu was installed in the test env, what version is installed and how it was compiled This change ensures that if qemu is present that it supprot the required formats otherwise it skips the test. Change-Id: I131996cdd7aaf1f52d4caac33b153753ff6db869 (cherry picked from commit cc2514d) (cherry picked from commit ae10fde) (cherry picked from commit bb2645e)
1 parent 65f0789 commit 673103f

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

nova/tests/unit/image/test_format_inspector.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,18 +111,22 @@ def _create_img(
111111
if fmt == 'iso':
112112
return self._create_iso(size, subformat)
113113

114-
# these tests depend on qemu-img
115-
# being installed and in the path,
116-
# if it is not installed, skip
117-
try:
118-
subprocess.check_output('qemu-img --version', shell=True)
119-
except Exception:
120-
self.skipTest('qemu-img not installed')
121-
122114
if fmt == 'vhd':
123115
# QEMU calls the vhd format vpc
124116
fmt = 'vpc'
125117

118+
# these tests depend on qemu-img being installed and in the path,
119+
# if it is not installed, skip. we also need to ensure that the
120+
# format is supported by qemu-img, this can vary depending on the
121+
# distribution so we need to check if the format is supported via
122+
# the help output.
123+
try:
124+
subprocess.check_output(
125+
'qemu-img --help | grep %s' % fmt, shell=True)
126+
except Exception:
127+
self.skipTest(
128+
'qemu-img not installed or does not support %s format' % fmt)
129+
126130
if options is None:
127131
options = {}
128132
opt = ''

0 commit comments

Comments
 (0)