Skip to content

Commit c8cef08

Browse files
test: Ensure pytest-timeout is available and skip qemu_nb_test on centos
- Skip test_block_device on CentOS due to non patched qemu-img active there. - Ensure pytest-timeout is available during bench to avoid possible dependency errors. Signed-off-by: Jasper Berton <jasper.berton@team.blue>
1 parent 07268c4 commit c8cef08

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed

ovirt_imageio/_internal/qemu_img.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import json
55
import logging
66
import subprocess
7+
import re
78

89
log = logging.getLogger("qemu_img")
910

test/qemu_nbd_test.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,10 @@ def test_block_signals(tmpdir):
482482
assert s.wait(0.2) is not None
483483

484484

485+
@pytest.mark.skipif(
486+
testutil.is_centos_9_or_10,
487+
reason="Non patched qemu-img in CentOS, which causes test failure",
488+
)
485489
@pytest.mark.parametrize("fmt", ["raw", "qcow2"])
486490
def test_block_device(tmpdir, user_block, fmt):
487491
qemu_img.create(user_block.path, fmt, size=1024**3)

test/testutil.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# SPDX-License-Identifier: GPL-2.0-or-later
33

44
import json
5+
import os
56
import logging
67
import socket
78
import subprocess
@@ -68,3 +69,13 @@ def ipv6_enabled():
6869
out = subprocess.check_output(["ip", "-6", "-j", "addr"])
6970
addresses = json.loads(out)
7071
return len(addresses) > 0
72+
73+
def is_centos_9_or_10():
74+
try:
75+
with open("/etc/os-release") as f:
76+
content = f.read()
77+
return ("ID=\"centos\"" in content or "ID=centos" in content) and \
78+
("VERSION_ID=\"9\"" in content or "VERSION_ID=\"10\"" in content or \
79+
"VERSION_ID=9" in content or "VERSION_ID=10" in content)
80+
except:
81+
return False

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ deps =
1919
test,bench: pytest
2020
test,bench: userstorage>=0.5.3
2121
test,bench: setuptools>=68.2.2
22+
test,bench: pytest-timeout
2223
test: pytest-cov
23-
test: pytest-timeout
2424
commands_pre =
2525
# Since Python 3.12, setuptools is not installed by default.
2626
pip install setuptools>=68.2.2

0 commit comments

Comments
 (0)