from .marks import requires_loopback_sector_size BEFORE = b"a" * 10 AFTER = b"b" * 10 @requires_root @pytest.mark.parametrize("sector_size", [ None, pytest.param(sc.BLOCK_SIZE_512, marks=requires_loopback_sector_size), pytest.param( sc.BLOCK_SIZE_4K, marks=[ requires_loopback_sector_size, pytest.mark.xfail( testing.on_ovirt_ci(), reason="fails randomly to create loop device with 4k sector " "size, only in ovirt CI - needs investigation", strict=False), ]), ]) def test_with_device(tmpdir, sector_size): filename = str(tmpdir.join("file")) prepare_backing_file(filename) with loopback.Device(filename, sector_size=sector_size) as device: assert device.is_attached() check_device(device) block_size, _ = multipath.getDeviceBlockSizes(device.path) expected = sector_size if sector_size else sc.BLOCK_SIZE_512 assert block_size == expected assert not device.is_attached()
requires_root = pytest.mark.skipif(os.geteuid() != 0, reason="requires root") requires_unprivileged_user = pytest.mark.skipif( os.geteuid() == 0, reason="This test can not run as root") requires_sanlock = pytest.mark.skipif(isinstance(sanlock, compat.MissingModule), reason="sanlock is not available") requires_selinux = pytest.mark.skipif(not selinux.is_selinux_enabled(), reason="Selinux is not enabled") xfail_python3 = pytest.mark.xfail(six.PY3, reason="needs porting to python 3") xfail_python37 = pytest.mark.xfail(sys.version_info[:2] == (3, 7), reason="needs porting to python 3.7") broken_on_ci = pytest.mark.skipif(on_ovirt_ci() or on_travis_ci(), reason="fails on CI") @cache.memoized def has_loopback_sector_size(): out = commands.run(["losetup", "-h"]) return "--sector-size <num>" in out.decode() requires_loopback_sector_size = pytest.mark.skipif( not has_loopback_sector_size(), reason="lossetup --sector-size option not available")
from .marks import requires_loopback_sector_size BEFORE = b"a" * 10 AFTER = b"b" * 10 @requires_root @pytest.mark.parametrize("sector_size", [ None, pytest.param(sc.BLOCK_SIZE_512, marks=requires_loopback_sector_size), pytest.param( sc.BLOCK_SIZE_4K, marks=[ requires_loopback_sector_size, pytest.mark.xfail( testing.on_ovirt_ci() and testing.on_fedora("29"), reason="fails randomly to create loop device with 4k sector " "size, only in ovirt CI - needs investigation") ]), ]) def test_with_device(tmpdir, sector_size): filename = str(tmpdir.join("file")) prepare_backing_file(filename) with loopback.Device(filename, sector_size=sector_size) as device: assert device.is_attached() check_device(device) block_size, _ = multipath.getDeviceBlockSizes(device.path) expected = sector_size if sector_size else sc.BLOCK_SIZE_512 assert block_size == expected assert not device.is_attached() check_backing_file(filename)
xfail_python3 = pytest.mark.xfail( six.PY3, reason="needs porting to python 3") xfail_python37 = pytest.mark.xfail( sys.version_info[:2] == (3, 7), reason="needs porting to python 3.7") # Note: This cannot be strict since in oVirt CI we run with older qemu-img # version that does not reproduce this issue. xfail_requires_target_is_zero = pytest.mark.xfail( not qemuimg.target_is_zero_supported(), reason="requires qemu-img convert --target-is-zero introdued in 5.1.0", strict=False) broken_on_ci = pytest.mark.skipif( on_ovirt_ci() or on_travis_ci(), reason="fails on CI") @cache.memoized def has_loopback_sector_size(): out = commands.run(["losetup", "-h"]) return "--sector-size <num>" in out.decode() requires_loopback_sector_size = pytest.mark.skipif( not has_loopback_sector_size(), reason="lossetup --sector-size option not available") requires_bitmaps_support = pytest.mark.skipif( not qemuimg.bitmaps_supported(),
from .marks import requires_loopback_sector_size BEFORE = b"a" * 10 AFTER = b"b" * 10 @requires_root @pytest.mark.parametrize("sector_size", [ None, pytest.param(sc.BLOCK_SIZE_512, marks=requires_loopback_sector_size), pytest.param( sc.BLOCK_SIZE_4K, marks=[ requires_loopback_sector_size, pytest.mark.xfail( testing.on_ovirt_ci() or testing.on_travis_ci(), reason="fails randomly to create loop device with 4k sector " "size, only in CI - needs investigation", strict=False), ]), ]) def test_with_device(tmpdir, sector_size): filename = str(tmpdir.join("file")) prepare_backing_file(filename) with loopback.Device(filename, sector_size=sector_size) as device: assert device.is_attached() check_device(device) block_size, _ = multipath.getDeviceBlockSizes(device.path) expected = sector_size if sector_size else sc.BLOCK_SIZE_512 assert block_size == expected assert not device.is_attached()
from .marks import requires_loopback_sector_size BEFORE = b"a" * 10 AFTER = b"b" * 10 @requires_root @pytest.mark.parametrize("sector_size", [ None, pytest.param(sc.BLOCK_SIZE_512, marks=requires_loopback_sector_size), pytest.param( sc.BLOCK_SIZE_4K, marks=[ requires_loopback_sector_size, pytest.mark.xfail( testing.on_ovirt_ci() and testing.on_fedora(), reason="fails randomly to create loop device with 4k sector " "size, only in ovirt CI - needs investigation", strict=False), ]), ]) def test_with_device(tmpdir, sector_size): filename = str(tmpdir.join("file")) prepare_backing_file(filename) with loopback.Device(filename, sector_size=sector_size) as device: assert device.is_attached() check_device(device) block_size, _ = multipath.getDeviceBlockSizes(device.path) expected = sector_size if sector_size else sc.BLOCK_SIZE_512 assert block_size == expected assert not device.is_attached()