import python-blivet-3.4.0-7.el9

This commit is contained in:
CentOS Sources 2021-12-07 13:22:33 -05:00 committed by Stepan Oksanichenko
commit 7ea334f263
13 changed files with 4901 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
SOURCES/blivet-3.4.0-tests.tar.gz
SOURCES/blivet-3.4.0.tar.gz

2
.python-blivet.metadata Normal file
View File

@ -0,0 +1,2 @@
d0a86df7bbaeda7be9990b7f7b15ec36b325ec7a SOURCES/blivet-3.4.0-tests.tar.gz
aafc429e224dfd204cb1c284bb70de52920f7b20 SOURCES/blivet-3.4.0.tar.gz

View File

@ -0,0 +1,35 @@
From 2f90040ff66eacc9715e370cd49ffb72d8d1f36f Mon Sep 17 00:00:00 2001
From: Vojtech Trefny <vtrefny@redhat.com>
Date: Wed, 11 Jul 2018 15:36:24 +0200
Subject: [PATCH] Force command line based libblockdev LVM plugin
---
blivet/__init__.py | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/blivet/__init__.py b/blivet/__init__.py
index c5a75bb..cb75917 100644
--- a/blivet/__init__.py
+++ b/blivet/__init__.py
@@ -63,11 +63,16 @@ gi.require_version("BlockDev", "2.0")
from gi.repository import GLib
from gi.repository import BlockDev as blockdev
if arch.is_s390():
- _REQUESTED_PLUGIN_NAMES = set(("lvm", "btrfs", "swap", "crypto", "loop", "mdraid", "mpath", "dm", "s390", "nvdimm"))
+ _REQUESTED_PLUGIN_NAMES = set(("btrfs", "swap", "crypto", "loop", "mdraid", "mpath", "dm", "s390", "nvdimm"))
else:
- _REQUESTED_PLUGIN_NAMES = set(("lvm", "btrfs", "swap", "crypto", "loop", "mdraid", "mpath", "dm", "nvdimm"))
+ _REQUESTED_PLUGIN_NAMES = set(("btrfs", "swap", "crypto", "loop", "mdraid", "mpath", "dm", "nvdimm"))
_requested_plugins = blockdev.plugin_specs_from_names(_REQUESTED_PLUGIN_NAMES)
+# XXX force non-dbus LVM plugin
+lvm_plugin = blockdev.PluginSpec()
+lvm_plugin.name = blockdev.Plugin.LVM
+lvm_plugin.so_name = "libbd_lvm.so.2"
+_requested_plugins.append(lvm_plugin)
try:
# do not check for dependencies during libblockdev initializtion, do runtime
# checks instead
--
1.8.3.1

View File

@ -0,0 +1,28 @@
From 6bf3378d3d2a1b6a4338df0c4dd36a783a641633 Mon Sep 17 00:00:00 2001
From: Vojtech Trefny <vtrefny@redhat.com>
Date: Mon, 16 Jul 2018 14:26:11 +0200
Subject: [PATCH] Remove btrfs from requested libblockdev plugins
---
blivet/__init__.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/blivet/__init__.py b/blivet/__init__.py
index cb75917..09f8b1c 100644
--- a/blivet/__init__.py
+++ b/blivet/__init__.py
@@ -63,9 +63,9 @@ gi.require_version("BlockDev", "2.0")
from gi.repository import GLib
from gi.repository import BlockDev as blockdev
if arch.is_s390():
- _REQUESTED_PLUGIN_NAMES = set(("btrfs", "swap", "crypto", "loop", "mdraid", "mpath", "dm", "s390", "nvdimm"))
+ _REQUESTED_PLUGIN_NAMES = set(("swap", "crypto", "loop", "mdraid", "mpath", "dm", "s390", "nvdimm"))
else:
- _REQUESTED_PLUGIN_NAMES = set(("btrfs", "swap", "crypto", "loop", "mdraid", "mpath", "dm", "nvdimm"))
+ _REQUESTED_PLUGIN_NAMES = set(("swap", "crypto", "loop", "mdraid", "mpath", "dm", "nvdimm"))
_requested_plugins = blockdev.plugin_specs_from_names(_REQUESTED_PLUGIN_NAMES)
# XXX force non-dbus LVM plugin
--
1.8.3.1

View File

@ -0,0 +1,330 @@
From 3a42d9e2afdf04dbbfd2c507f5b2392193fda25b Mon Sep 17 00:00:00 2001
From: Vojtech Trefny <vtrefny@redhat.com>
Date: Wed, 26 May 2021 12:15:54 +0200
Subject: [PATCH] Revert "More consistent lvm errors (API break)"
This reverts commit 49ec071c6d0673224a0774d613904387c52c7381.
---
blivet/devices/lvm.py | 72 +++++++++++++++++-----------------
tests/devices_test/lvm_test.py | 14 +++----
2 files changed, 43 insertions(+), 43 deletions(-)
diff --git a/blivet/devices/lvm.py b/blivet/devices/lvm.py
index a55515fc..6d23bfba 100644
--- a/blivet/devices/lvm.py
+++ b/blivet/devices/lvm.py
@@ -307,7 +307,7 @@ class LVMVolumeGroupDevice(ContainerDevice):
def _add_log_vol(self, lv):
""" Add an LV to this VG. """
if lv in self._lvs:
- raise errors.DeviceError("lv is already part of this vg")
+ raise ValueError("lv is already part of this vg")
# verify we have the space, then add it
# do not verify for growing vg (because of ks)
@@ -340,7 +340,7 @@ class LVMVolumeGroupDevice(ContainerDevice):
def _remove_log_vol(self, lv):
""" Remove an LV from this VG. """
if lv not in self.lvs:
- raise errors.DeviceError("specified lv is not part of this vg")
+ raise ValueError("specified lv is not part of this vg")
self._lvs.remove(lv)
@@ -415,7 +415,7 @@ class LVMVolumeGroupDevice(ContainerDevice):
@thpool_reserve.setter
def thpool_reserve(self, value):
if value is not None and not isinstance(value, ThPoolReserveSpec):
- raise AttributeError("Invalid thpool_reserve given, must be of type ThPoolReserveSpec")
+ raise ValueError("Invalid thpool_reserve given, must be of type ThPoolReserveSpec")
self._thpool_reserve = value
@property
@@ -646,14 +646,14 @@ class LVMLogicalVolumeBase(DMDevice, RaidDevice):
if seg_type not in [None, "linear", "thin", "thin-pool", "cache", "vdo-pool", "vdo"] + lvm.raid_seg_types:
raise ValueError("Invalid or unsupported segment type: %s" % seg_type)
if seg_type and seg_type in lvm.raid_seg_types and not pvs:
- raise errors.DeviceError("List of PVs has to be given for every non-linear LV")
+ raise ValueError("List of PVs has to be given for every non-linear LV")
elif (not seg_type or seg_type == "linear") and pvs:
if not all(isinstance(pv, LVPVSpec) for pv in pvs):
- raise errors.DeviceError("Invalid specification of PVs for a linear LV: either no or complete "
- "specification (with all space split into PVs has to be given")
+ raise ValueError("Invalid specification of PVs for a linear LV: either no or complete "
+ "specification (with all space split into PVs has to be given")
elif sum(spec.size for spec in pvs) != size:
- raise errors.DeviceError("Invalid specification of PVs for a linear LV: the sum of space "
- "assigned to PVs is not equal to the size of the LV")
+ raise ValueError("Invalid specification of PVs for a linear LV: the sum of space "
+ "assigned to PVs is not equal to the size of the LV")
# When this device's format is set in the superclass constructor it will
# try to access self.snapshots.
@@ -702,13 +702,13 @@ class LVMLogicalVolumeBase(DMDevice, RaidDevice):
self._from_lvs = from_lvs
if self._from_lvs:
if exists:
- raise errors.DeviceError("Only new LVs can be created from other LVs")
+ raise ValueError("Only new LVs can be created from other LVs")
if size or maxsize or percent:
- raise errors.DeviceError("Cannot specify size for a converted LV")
+ raise ValueError("Cannot specify size for a converted LV")
if fmt:
- raise errors.DeviceError("Cannot specify format for a converted LV")
+ raise ValueError("Cannot specify format for a converted LV")
if any(lv.vg != self.vg for lv in self._from_lvs):
- raise errors.DeviceError("Conversion of LVs only possible inside a VG")
+ raise ValueError("Conversion of LVs only possible inside a VG")
self._cache = None
if cache_request and not self.exists:
@@ -723,13 +723,13 @@ class LVMLogicalVolumeBase(DMDevice, RaidDevice):
elif isinstance(pv_spec, StorageDevice):
self._pv_specs.append(LVPVSpec(pv_spec, Size(0)))
else:
- raise AttributeError("Invalid PV spec '%s' for the '%s' LV" % (pv_spec, self.name))
+ raise ValueError("Invalid PV spec '%s' for the '%s' LV" % (pv_spec, self.name))
# Make sure any destination PVs are actually PVs in this VG
if not set(spec.pv for spec in self._pv_specs).issubset(set(self.vg.parents)):
missing = [r.name for r in
set(spec.pv for spec in self._pv_specs).difference(set(self.vg.parents))]
msg = "invalid destination PV(s) %s for LV %s" % (missing, self.name)
- raise errors.DeviceError(msg)
+ raise ValueError(msg)
if self._pv_specs:
self._assign_pv_space()
@@ -1072,7 +1072,7 @@ class LVMLogicalVolumeBase(DMDevice, RaidDevice):
else:
msg = "the specified internal LV '%s' doesn't belong to this LV ('%s')" % (int_lv.lv_name,
self.name)
- raise errors.DeviceError(msg)
+ raise ValueError(msg)
def populate_ksdata(self, data):
super(LVMLogicalVolumeBase, self).populate_ksdata(data)
@@ -1171,7 +1171,7 @@ class LVMInternalLogicalVolumeMixin(object):
def _init_check(self):
# an internal LV should have no parents
if self._parent_lv and self._parents:
- raise errors.DeviceError("an internal LV should have no parents")
+ raise ValueError("an internal LV should have no parents")
@property
def is_internal_lv(self):
@@ -1231,7 +1231,7 @@ class LVMInternalLogicalVolumeMixin(object):
@readonly.setter
def readonly(self, value): # pylint: disable=unused-argument
- raise errors.DeviceError("Cannot make an internal LV read-write")
+ raise ValueError("Cannot make an internal LV read-write")
@property
def type(self):
@@ -1267,7 +1267,7 @@ class LVMInternalLogicalVolumeMixin(object):
def _check_parents(self):
# an internal LV should have no parents
if self._parents:
- raise errors.DeviceError("an internal LV should have no parents")
+ raise ValueError("an internal LV should have no parents")
def _add_to_parents(self):
# nothing to do here, an internal LV has no parents (in the DeviceTree's
@@ -1277,13 +1277,13 @@ class LVMInternalLogicalVolumeMixin(object):
# internal LVs follow different rules limitting size
def _set_size(self, newsize):
if not isinstance(newsize, Size):
- raise AttributeError("new size must of type Size")
+ raise ValueError("new size must of type Size")
if not self.takes_extra_space:
if newsize <= self.parent_lv.size: # pylint: disable=no-member
self._size = newsize # pylint: disable=attribute-defined-outside-init
else:
- raise errors.DeviceError("Internal LV cannot be bigger than its parent LV")
+ raise ValueError("Internal LV cannot be bigger than its parent LV")
else:
# same rules apply as for any other LV
raise NotTypeSpecific()
@@ -1361,18 +1361,18 @@ class LVMSnapshotMixin(object):
return
if self.origin and not isinstance(self.origin, LVMLogicalVolumeDevice):
- raise errors.DeviceError("lvm snapshot origin must be a logical volume")
+ raise ValueError("lvm snapshot origin must be a logical volume")
if self.vorigin and not self.exists:
- raise errors.DeviceError("only existing vorigin snapshots are supported")
+ raise ValueError("only existing vorigin snapshots are supported")
if isinstance(self.origin, LVMLogicalVolumeDevice) and \
isinstance(self.parents[0], LVMVolumeGroupDevice) and \
self.origin.vg != self.parents[0]:
- raise errors.DeviceError("lvm snapshot and origin must be in the same vg")
+ raise ValueError("lvm snapshot and origin must be in the same vg")
if self.is_thin_lv:
if self.origin and self.size and not self.exists:
- raise errors.DeviceError("thin snapshot size is determined automatically")
+ raise ValueError("thin snapshot size is determined automatically")
@property
def is_snapshot_lv(self):
@@ -1544,7 +1544,7 @@ class LVMThinPoolMixin(object):
def _check_from_lvs(self):
if self._from_lvs:
if len(self._from_lvs) != 2:
- raise errors.DeviceError("two LVs required to create a thin pool")
+ raise ValueError("two LVs required to create a thin pool")
def _convert_from_lvs(self):
data_lv, metadata_lv = self._from_lvs
@@ -1590,7 +1590,7 @@ class LVMThinPoolMixin(object):
def _add_log_vol(self, lv):
""" Add an LV to this pool. """
if lv in self._lvs:
- raise errors.DeviceError("lv is already part of this vg")
+ raise ValueError("lv is already part of this vg")
# TODO: add some checking to prevent overcommit for preexisting
self.vg._add_log_vol(lv)
@@ -1601,7 +1601,7 @@ class LVMThinPoolMixin(object):
def _remove_log_vol(self, lv):
""" Remove an LV from this pool. """
if lv not in self._lvs:
- raise errors.DeviceError("specified lv is not part of this vg")
+ raise ValueError("specified lv is not part of this vg")
self._lvs.remove(lv)
self.vg._remove_log_vol(lv)
@@ -1711,14 +1711,14 @@ class LVMThinLogicalVolumeMixin(object):
"""Check that this device has parents as expected"""
if isinstance(self.parents, (list, ParentList)):
if len(self.parents) != 1:
- raise errors.DeviceError("constructor requires a single thin-pool LV")
+ raise ValueError("constructor requires a single thin-pool LV")
container = self.parents[0]
else:
container = self.parents
if not container or not isinstance(container, LVMLogicalVolumeDevice) or not container.is_thin_pool:
- raise errors.DeviceError("constructor requires a thin-pool LV")
+ raise ValueError("constructor requires a thin-pool LV")
@property
def is_thin_lv(self):
@@ -1755,7 +1755,7 @@ class LVMThinLogicalVolumeMixin(object):
def _set_size(self, newsize):
if not isinstance(newsize, Size):
- raise AttributeError("new size must of type Size")
+ raise ValueError("new size must of type Size")
newsize = self.vg.align(newsize)
newsize = self.vg.align(util.numeric_type(newsize))
@@ -2229,7 +2229,7 @@ class LVMLogicalVolumeDevice(LVMLogicalVolumeBase, LVMInternalLogicalVolumeMixin
container = self.parents
if not isinstance(container, LVMVolumeGroupDevice):
- raise AttributeError("constructor requires a LVMVolumeGroupDevice")
+ raise ValueError("constructor requires a LVMVolumeGroupDevice")
@type_specific
def _add_to_parents(self):
@@ -2240,12 +2240,12 @@ class LVMLogicalVolumeDevice(LVMLogicalVolumeBase, LVMInternalLogicalVolumeMixin
@type_specific
def _check_from_lvs(self):
"""Check the LVs to create this LV from"""
- raise errors.DeviceError("Cannot create a new LV of type '%s' from other LVs" % self.seg_type)
+ raise ValueError("Cannot create a new LV of type '%s' from other LVs" % self.seg_type)
@type_specific
def _convert_from_lvs(self):
"""Convert the LVs to create this LV from into its internal LVs"""
- raise errors.DeviceError("Cannot create a new LV of type '%s' from other LVs" % self.seg_type)
+ raise ValueError("Cannot create a new LV of type '%s' from other LVs" % self.seg_type)
@property
def external_dependencies(self):
@@ -2265,7 +2265,7 @@ class LVMLogicalVolumeDevice(LVMLogicalVolumeBase, LVMInternalLogicalVolumeMixin
@type_specific
def _set_size(self, newsize):
if not isinstance(newsize, Size):
- raise AttributeError("new size must be of type Size")
+ raise ValueError("new size must be of type Size")
newsize = self.vg.align(newsize)
log.debug("trying to set lv %s size to %s", self.name, newsize)
@@ -2274,7 +2274,7 @@ class LVMLogicalVolumeDevice(LVMLogicalVolumeBase, LVMInternalLogicalVolumeMixin
# space for it. A similar reasoning applies to shrinking the LV.
if not self.exists and newsize > self.size and newsize > self.vg.free_space + self.vg_space_used:
log.error("failed to set size: %s short", newsize - (self.vg.free_space + self.vg_space_used))
- raise errors.DeviceError("not enough free space in volume group")
+ raise ValueError("not enough free space in volume group")
LVMLogicalVolumeBase._set_size(self, newsize)
@@ -2622,7 +2622,7 @@ class LVMCache(Cache):
spec.size = spec.pv.format.free
space_to_assign -= spec.pv.format.free
if space_to_assign > 0:
- raise errors.DeviceError("Not enough free space in the PVs for this cache: %s short" % space_to_assign)
+ raise ValueError("Not enough free space in the PVs for this cache: %s short" % space_to_assign)
@property
def size(self):
diff --git a/tests/devices_test/lvm_test.py b/tests/devices_test/lvm_test.py
index 670c91c9..4156d0bf 100644
--- a/tests/devices_test/lvm_test.py
+++ b/tests/devices_test/lvm_test.py
@@ -36,10 +36,10 @@ class LVMDeviceTest(unittest.TestCase):
lv = LVMLogicalVolumeDevice("testlv", parents=[vg],
fmt=blivet.formats.get_format("xfs"))
- with six.assertRaisesRegex(self, errors.DeviceError, "lvm snapshot origin must be a logical volume"):
+ with six.assertRaisesRegex(self, ValueError, "lvm snapshot origin must be a logical volume"):
LVMLogicalVolumeDevice("snap1", parents=[vg], origin=pv)
- with six.assertRaisesRegex(self, errors.DeviceError, "only existing vorigin snapshots are supported"):
+ with six.assertRaisesRegex(self, ValueError, "only existing vorigin snapshots are supported"):
LVMLogicalVolumeDevice("snap1", parents=[vg], vorigin=True)
lv.exists = True
@@ -64,7 +64,7 @@ class LVMDeviceTest(unittest.TestCase):
pool = LVMLogicalVolumeDevice("pool1", parents=[vg], size=Size("500 MiB"), seg_type="thin-pool")
thinlv = LVMLogicalVolumeDevice("thinlv", parents=[pool], size=Size("200 MiB"), seg_type="thin")
- with six.assertRaisesRegex(self, errors.DeviceError, "lvm snapshot origin must be a logical volume"):
+ with six.assertRaisesRegex(self, ValueError, "lvm snapshot origin must be a logical volume"):
LVMLogicalVolumeDevice("snap1", parents=[pool], origin=pv, seg_type="thin")
# now make the constructor succeed so we can test some properties
@@ -258,21 +258,21 @@ class LVMDeviceTest(unittest.TestCase):
vg = LVMVolumeGroupDevice("testvg", parents=[pv, pv2])
# pvs have to be specified for non-linear LVs
- with self.assertRaises(errors.DeviceError):
+ with self.assertRaises(ValueError):
lv = LVMLogicalVolumeDevice("testlv", parents=[vg], size=Size("512 MiB"),
fmt=blivet.formats.get_format("xfs"),
exists=False, seg_type="raid1")
- with self.assertRaises(errors.DeviceError):
+ with self.assertRaises(ValueError):
lv = LVMLogicalVolumeDevice("testlv", parents=[vg], size=Size("512 MiB"),
fmt=blivet.formats.get_format("xfs"),
exists=False, seg_type="striped")
# no or complete specification has to be given for linear LVs
- with self.assertRaises(errors.DeviceError):
+ with self.assertRaises(ValueError):
lv = LVMLogicalVolumeDevice("testlv", parents=[vg], size=Size("512 MiB"),
fmt=blivet.formats.get_format("xfs"),
exists=False, pvs=[pv])
- with self.assertRaises(errors.DeviceError):
+ with self.assertRaises(ValueError):
pv_spec = LVPVSpec(pv, Size("256 MiB"))
pv_spec2 = LVPVSpec(pv2, Size("250 MiB"))
lv = LVMLogicalVolumeDevice("testlv", parents=[vg], size=Size("512 MiB"),
--
2.31.1

View File

@ -0,0 +1,538 @@
From ad34dfa2f983bb3159af8b5780193e0427b505e9 Mon Sep 17 00:00:00 2001
From: Vojtech Trefny <vtrefny@redhat.com>
Date: Thu, 10 Jun 2021 15:01:26 +0200
Subject: [PATCH] Fix/unify importing mock module in tests
mock is available in the unittest module since Python 3.3, we need
to use the old mock module not only with Python 2 but also with
the early versions of Python 3.
---
tests/action_test.py | 5 ++-
tests/dbus_test.py | 9 +++--
tests/devicefactory_test.py | 6 ++--
tests/devicelibs_test/disk_test.py | 6 ++--
tests/devicelibs_test/edd_test.py | 6 +++-
tests/devices_test/dependencies_test.py | 6 ++--
tests/devices_test/device_methods_test.py | 8 +++--
tests/devices_test/device_names_test.py | 6 ++--
tests/devices_test/device_properties_test.py | 8 ++---
tests/devices_test/disk_test.py | 7 ++--
tests/devices_test/lvm_test.py | 7 ++--
tests/devices_test/partition_test.py | 6 ++--
tests/devices_test/tags_test.py | 6 ++--
tests/devicetree_test.py | 6 ++--
tests/events_test.py | 6 ++--
tests/formats_test/disklabel_test.py | 6 ++--
tests/formats_test/luks_test.py | 6 ++--
tests/formats_test/lvmpv_test.py | 2 --
tests/formats_test/methods_test.py | 6 ++--
tests/formats_test/selinux_test.py | 6 ++--
tests/formats_test/swap_test.py | 2 --
tests/misc_test.py | 6 ++--
tests/partitioning_test.py | 6 ++--
tests/populator_test.py | 6 ++--
tests/storagetestcase.py | 5 ++-
tests/test_compat.py | 38 --------------------
tests/udev_test.py | 6 +++-
tests/unsupported_disklabel_test.py | 7 ++--
tests/util_test.py | 6 ++--
29 files changed, 104 insertions(+), 102 deletions(-)
delete mode 100644 tests/test_compat.py
diff --git a/tests/action_test.py b/tests/action_test.py
index 38a2e872..f60cf5d7 100644
--- a/tests/action_test.py
+++ b/tests/action_test.py
@@ -1,9 +1,8 @@
-from six import PY3
import unittest
-if PY3:
+try:
from unittest.mock import Mock
-else:
+except ImportError:
from mock import Mock
from tests.storagetestcase import StorageTestCase
diff --git a/tests/dbus_test.py b/tests/dbus_test.py
index 293ac073..9bb9102a 100644
--- a/tests/dbus_test.py
+++ b/tests/dbus_test.py
@@ -1,7 +1,10 @@
-import test_compat # pylint: disable=unused-import
-
import random
-from six.moves.mock import Mock, patch # pylint: disable=no-name-in-module,import-error
+
+try:
+ from unittest.mock import patch, Mock
+except ImportError:
+ from mock import patch, Mock
+
from unittest import TestCase
import dbus
diff --git a/tests/devicefactory_test.py b/tests/devicefactory_test.py
index dc0d6408..93c8bdb7 100644
--- a/tests/devicefactory_test.py
+++ b/tests/devicefactory_test.py
@@ -4,8 +4,10 @@ import unittest
from decimal import Decimal
import os
-import test_compat # pylint: disable=unused-import
-from six.moves.mock import patch # pylint: disable=no-name-in-module,import-error
+try:
+ from unittest.mock import patch
+except ImportError:
+ from mock import patch
import blivet
diff --git a/tests/devicelibs_test/disk_test.py b/tests/devicelibs_test/disk_test.py
index e67ef5b1..9cb39951 100644
--- a/tests/devicelibs_test/disk_test.py
+++ b/tests/devicelibs_test/disk_test.py
@@ -1,8 +1,10 @@
# pylint: skip-file
-import test_compat
+try:
+ from unittest.mock import Mock, patch, sentinel
+except ImportError:
+ from mock import Mock, patch, sentinel
import six
-from six.moves.mock import Mock, patch, sentinel
import unittest
from blivet.devicelibs import disk as disklib
diff --git a/tests/devicelibs_test/edd_test.py b/tests/devicelibs_test/edd_test.py
index 23d736f4..21bbcffc 100644
--- a/tests/devicelibs_test/edd_test.py
+++ b/tests/devicelibs_test/edd_test.py
@@ -1,5 +1,9 @@
+try:
+ from unittest import mock
+except ImportError:
+ import mock
+
import unittest
-import mock
import os
import inspect
import logging
diff --git a/tests/devices_test/dependencies_test.py b/tests/devices_test/dependencies_test.py
index c012751d..493d1c9f 100644
--- a/tests/devices_test/dependencies_test.py
+++ b/tests/devices_test/dependencies_test.py
@@ -1,8 +1,6 @@
-# vim:set fileencoding=utf-8
-from six import PY3
-if PY3:
+try:
from unittest.mock import patch, PropertyMock
-else:
+except ImportError:
from mock import patch, PropertyMock
import unittest
diff --git a/tests/devices_test/device_methods_test.py b/tests/devices_test/device_methods_test.py
index f00509be..8a70b5bb 100644
--- a/tests/devices_test/device_methods_test.py
+++ b/tests/devices_test/device_methods_test.py
@@ -1,9 +1,11 @@
-import test_compat # pylint: disable=unused-import
-
import six
-from six.moves.mock import patch, Mock, PropertyMock # pylint: disable=no-name-in-module,import-error
import unittest
+try:
+ from unittest.mock import patch, Mock, PropertyMock
+except ImportError:
+ from mock import patch, PropertyMock
+
from blivet.devices import StorageDevice
from blivet.devices import DiskDevice, PartitionDevice
from blivet.devices import LVMVolumeGroupDevice, LVMLogicalVolumeDevice
diff --git a/tests/devices_test/device_names_test.py b/tests/devices_test/device_names_test.py
index 2a66f983..ca44d38c 100644
--- a/tests/devices_test/device_names_test.py
+++ b/tests/devices_test/device_names_test.py
@@ -1,7 +1,9 @@
# vim:set fileencoding=utf-8
-import test_compat # pylint: disable=unused-import
+try:
+ from unittest.mock import patch
+except ImportError:
+ from mock import patch
-from six.moves.mock import patch # pylint: disable=no-name-in-module,import-error
import six
import unittest
diff --git a/tests/devices_test/device_properties_test.py b/tests/devices_test/device_properties_test.py
index 240ac088..8928707f 100644
--- a/tests/devices_test/device_properties_test.py
+++ b/tests/devices_test/device_properties_test.py
@@ -1,6 +1,3 @@
-# vim:set fileencoding=utf-8
-import test_compat # pylint: disable=unused-import
-
import six
import unittest
@@ -9,7 +6,10 @@ gi.require_version("BlockDev", "2.0")
from gi.repository import BlockDev as blockdev
-from six.moves.mock import Mock, patch # pylint: disable=no-name-in-module,import-error
+try:
+ from unittest.mock import patch, Mock
+except ImportError:
+ from mock import patch, Mock
import blivet
diff --git a/tests/devices_test/disk_test.py b/tests/devices_test/disk_test.py
index e9852303..cc8454e1 100644
--- a/tests/devices_test/disk_test.py
+++ b/tests/devices_test/disk_test.py
@@ -1,7 +1,8 @@
# pylint: skip-file
-import test_compat
-
-from six.moves.mock import patch
+try:
+ from unittest.mock import patch
+except ImportError:
+ from mock import patch
import unittest
from blivet.devices import DiskDevice
diff --git a/tests/devices_test/lvm_test.py b/tests/devices_test/lvm_test.py
index 670c91c9..f50933c4 100644
--- a/tests/devices_test/lvm_test.py
+++ b/tests/devices_test/lvm_test.py
@@ -1,8 +1,9 @@
-# vim:set fileencoding=utf-8
-import test_compat # pylint: disable=unused-import
+try:
+ from unittest.mock import patch, PropertyMock
+except ImportError:
+ from mock import patch, PropertyMock
import six
-from six.moves.mock import patch, PropertyMock # pylint: disable=no-name-in-module,import-error
import unittest
import blivet
diff --git a/tests/devices_test/partition_test.py b/tests/devices_test/partition_test.py
index 0abd88df..4748dafe 100644
--- a/tests/devices_test/partition_test.py
+++ b/tests/devices_test/partition_test.py
@@ -1,5 +1,4 @@
# vim:set fileencoding=utf-8
-import test_compat # pylint: disable=unused-import
from collections import namedtuple
import os
@@ -7,7 +6,10 @@ import six
import unittest
import parted
-from six.moves.mock import Mock, patch # pylint: disable=no-name-in-module,import-error
+try:
+ from unittest.mock import patch, Mock
+except ImportError:
+ from mock import patch, Mock
from blivet.devices import DiskFile
from blivet.devices import PartitionDevice
diff --git a/tests/devices_test/tags_test.py b/tests/devices_test/tags_test.py
index 1edc37f6..49a2d72e 100644
--- a/tests/devices_test/tags_test.py
+++ b/tests/devices_test/tags_test.py
@@ -1,6 +1,8 @@
-import test_compat # pylint: disable=unused-import
+try:
+ from unittest.mock import patch
+except ImportError:
+ from mock import patch
-from six.moves.mock import patch # pylint: disable=no-name-in-module,import-error
import unittest
from blivet.devices import DiskDevice, FcoeDiskDevice, iScsiDiskDevice, MultipathDevice, StorageDevice, ZFCPDiskDevice
diff --git a/tests/devicetree_test.py b/tests/devicetree_test.py
index 11f8469d..fbf31c77 100644
--- a/tests/devicetree_test.py
+++ b/tests/devicetree_test.py
@@ -1,6 +1,8 @@
-import test_compat # pylint: disable=unused-import
+try:
+ from unittest.mock import patch, Mock, PropertyMock, sentinel
+except ImportError:
+ from mock import patch, Mock, PropertyMock, sentinel
-from six.moves.mock import Mock, patch, PropertyMock, sentinel # pylint: disable=no-name-in-module,import-error
import os
import six
import unittest
diff --git a/tests/events_test.py b/tests/events_test.py
index 5906b4e2..22666f6d 100644
--- a/tests/events_test.py
+++ b/tests/events_test.py
@@ -1,6 +1,8 @@
-import test_compat # pylint: disable=unused-import
+try:
+ from unittest.mock import patch, Mock
+except ImportError:
+ from mock import patch, Mock
-from six.moves.mock import Mock, patch # pylint: disable=no-name-in-module,import-error
import time
from unittest import TestCase
diff --git a/tests/formats_test/disklabel_test.py b/tests/formats_test/disklabel_test.py
index 0cfa736d..f514a778 100644
--- a/tests/formats_test/disklabel_test.py
+++ b/tests/formats_test/disklabel_test.py
@@ -1,7 +1,9 @@
-import test_compat # pylint: disable=unused-import
+try:
+ from unittest import mock
+except ImportError:
+ import mock
import parted
-from six.moves import mock # pylint: disable=no-name-in-module,import-error
import unittest
import blivet
diff --git a/tests/formats_test/luks_test.py b/tests/formats_test/luks_test.py
index be0d50b0..1edbdcb2 100644
--- a/tests/formats_test/luks_test.py
+++ b/tests/formats_test/luks_test.py
@@ -1,6 +1,8 @@
-import test_compat # pylint: disable=unused-import
+try:
+ from unittest.mock import patch
+except ImportError:
+ from mock import patch
-from six.moves.mock import patch # pylint: disable=no-name-in-module,import-error
import unittest
from blivet.formats.luks import LUKS
diff --git a/tests/formats_test/lvmpv_test.py b/tests/formats_test/lvmpv_test.py
index 792a2f1d..cbd2c419 100644
--- a/tests/formats_test/lvmpv_test.py
+++ b/tests/formats_test/lvmpv_test.py
@@ -1,5 +1,3 @@
-import test_compat # pylint: disable=unused-import
-
from blivet.formats.lvmpv import LVMPhysicalVolume
from blivet.size import Size
diff --git a/tests/formats_test/methods_test.py b/tests/formats_test/methods_test.py
index b2674ea7..2743b7db 100644
--- a/tests/formats_test/methods_test.py
+++ b/tests/formats_test/methods_test.py
@@ -1,7 +1,9 @@
-import test_compat # pylint: disable=unused-import
+try:
+ from unittest.mock import patch, sentinel, PropertyMock
+except ImportError:
+ from mock import patch, sentinel, PropertyMock
import six
-from six.moves.mock import patch, sentinel, PropertyMock # pylint: disable=no-name-in-module,import-error
import unittest
from blivet.errors import DeviceFormatError
diff --git a/tests/formats_test/selinux_test.py b/tests/formats_test/selinux_test.py
index 02e39011..26df5fe9 100644
--- a/tests/formats_test/selinux_test.py
+++ b/tests/formats_test/selinux_test.py
@@ -1,9 +1,9 @@
# pylint: disable=unused-import
import os
-from six import PY3
-if PY3:
+
+try:
from unittest.mock import patch, ANY
-else:
+except ImportError:
from mock import patch, ANY
import unittest
diff --git a/tests/formats_test/swap_test.py b/tests/formats_test/swap_test.py
index 56356144..8968ca15 100644
--- a/tests/formats_test/swap_test.py
+++ b/tests/formats_test/swap_test.py
@@ -1,5 +1,3 @@
-import test_compat # pylint: disable=unused-import
-
import six
import unittest
diff --git a/tests/misc_test.py b/tests/misc_test.py
index 3c8cf344..10ea1320 100644
--- a/tests/misc_test.py
+++ b/tests/misc_test.py
@@ -1,7 +1,9 @@
import unittest
-import test_compat # pylint: disable=unused-import
-from six.moves.mock import patch # pylint: disable=no-name-in-module,import-error
+try:
+ from unittest.mock import patch
+except ImportError:
+ from mock import patch
import blivet
diff --git a/tests/partitioning_test.py b/tests/partitioning_test.py
index b7aa5045..9b27f0c0 100644
--- a/tests/partitioning_test.py
+++ b/tests/partitioning_test.py
@@ -1,6 +1,8 @@
-import test_compat # pylint: disable=unused-import
+try:
+ from unittest.mock import patch, Mock
+except ImportError:
+ from mock import patch, Mock
-from six.moves.mock import Mock, patch # pylint: disable=no-name-in-module,import-error
import six
import unittest
diff --git a/tests/populator_test.py b/tests/populator_test.py
index a7748a9d..2a8532f0 100644
--- a/tests/populator_test.py
+++ b/tests/populator_test.py
@@ -1,7 +1,9 @@
-import test_compat # pylint: disable=unused-import
+try:
+ from unittest.mock import call, patch, sentinel, Mock, PropertyMock
+except ImportError:
+ from mock import call, patch, sentinel, Mock, PropertyMock
import gi
-from six.moves.mock import call, patch, sentinel, Mock, PropertyMock # pylint: disable=no-name-in-module,import-error
import six
import unittest
diff --git a/tests/storagetestcase.py b/tests/storagetestcase.py
index 1844dec5..1b856914 100644
--- a/tests/storagetestcase.py
+++ b/tests/storagetestcase.py
@@ -1,6 +1,9 @@
import unittest
-from mock import Mock
+try:
+ from unittest.mock import Mock
+except ImportError:
+ from mock import Mock
import parted
diff --git a/tests/test_compat.py b/tests/test_compat.py
deleted file mode 100644
index d0859e24..00000000
--- a/tests/test_compat.py
+++ /dev/null
@@ -1,38 +0,0 @@
-# test_compat.py
-# Python (2 -v- 3) compatibility functions.
-#
-# Copyright (C) 2017 Red Hat, Inc.
-#
-# This copyrighted material is made available to anyone wishing to use,
-# modify, copy, or redistribute it subject to the terms and conditions of
-# the GNU Lesser General Public License v.2, or (at your option) any later
-# version. This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY expressed or implied, including the implied
-# warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
-# the GNU Lesser General Public License for more details. You should have
-# received a copy of the GNU Lesser General Public License along with this
-# program; if not, write to the Free Software Foundation, Inc., 51 Franklin
-# Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat trademarks
-# that are incorporated in the source code or documentation are not subject
-# to the GNU Lesser General Public License and may only be used or
-# replicated with the express permission of Red Hat, Inc.
-#
-# Red Hat Author(s): David Lehman <dlehman@redhat.com>
-#
-
-import six as _six
-
-mock_move = _six.MovedModule('mock', 'mock', 'unittest.mock')
-
-
-def add_move(mod):
- _six.add_move(mod)
- # https://bitbucket.org/gutworth/six/issues/116/enable-importing-from-within-custom
- _six._importer._add_module(mod, "moves." + mod.name)
-
-
-def setup():
- add_move(mock_move)
-
-
-setup()
diff --git a/tests/udev_test.py b/tests/udev_test.py
index f9b10620..569a144e 100644
--- a/tests/udev_test.py
+++ b/tests/udev_test.py
@@ -1,6 +1,10 @@
import unittest
-import mock
+
+try:
+ from unittest import mock
+except ImportError:
+ import mock
from udev_data import raid_data
diff --git a/tests/unsupported_disklabel_test.py b/tests/unsupported_disklabel_test.py
index f5b24779..38055333 100644
--- a/tests/unsupported_disklabel_test.py
+++ b/tests/unsupported_disklabel_test.py
@@ -1,7 +1,8 @@
-# vim:set fileencoding=utf-8
-import test_compat # pylint: disable=unused-import
+try:
+ from unittest.mock import patch, sentinel, DEFAULT
+except ImportError:
+ from mock import patch, sentinel, DEFAULT
-from six.moves.mock import patch, sentinel, DEFAULT # pylint: disable=no-name-in-module,import-error
import six
import unittest
diff --git a/tests/util_test.py b/tests/util_test.py
index 853b6166..b4f82c1b 100644
--- a/tests/util_test.py
+++ b/tests/util_test.py
@@ -1,7 +1,9 @@
# pylint: skip-file
-import test_compat
+try:
+ from unittest import mock
+except ImportError:
+ import mock
-from six.moves import mock
import os
import six
import tempfile
--
2.31.1

View File

@ -0,0 +1,23 @@
From d609cebba48744c97ac7e0461f8827ab63198026 Mon Sep 17 00:00:00 2001
From: Vojtech Trefny <vtrefny@redhat.com>
Date: Thu, 10 Jun 2021 16:58:42 +0200
Subject: [PATCH] Fix util.virt_detect on Xen
Xen is apparently still alive so we should return True for it too.
---
blivet/util.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/blivet/util.py b/blivet/util.py
index 3bebb003..af60210b 100644
--- a/blivet/util.py
+++ b/blivet/util.py
@@ -1130,4 +1130,4 @@ def detect_virt():
except (safe_dbus.DBusCallError, safe_dbus.DBusPropertyError):
return False
else:
- return vm[0] in ('qemu', 'kvm')
+ return vm[0] in ('qemu', 'kvm', 'xen')
--
2.31.1

View File

@ -0,0 +1,35 @@
From 8ece3da18b1abb89320d02f4475002e6a3ed7875 Mon Sep 17 00:00:00 2001
From: Vojtech Trefny <vtrefny@redhat.com>
Date: Thu, 20 May 2021 13:40:26 +0200
Subject: [PATCH] Fix activating old style LVM snapshots
The old style snapshots are activated together with the origin LV
so we need to make sure it is activated to be able to remove the
snapshot or its format.
Resolves: rhbz#1961739
---
blivet/devices/lvm.py | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/blivet/devices/lvm.py b/blivet/devices/lvm.py
index a55515fcb..fb57804d9 100644
--- a/blivet/devices/lvm.py
+++ b/blivet/devices/lvm.py
@@ -1461,9 +1461,13 @@ def _set_format(self, fmt): # pylint: disable=unused-argument
self._update_format_from_origin()
@old_snapshot_specific
- def setup(self, orig=False):
- # the old snapshot cannot be setup and torn down
- pass
+ def setup(self, orig=False): # pylint: disable=unused-argument
+ # the old snapshot is activated together with the origin
+ if self.origin and not self.origin.status:
+ try:
+ self.origin.setup()
+ except blockdev.LVMError as lvmerr:
+ log.error("failed to activate origin LV: %s", lvmerr)
@old_snapshot_specific
def teardown(self, recursive=False):

View File

@ -0,0 +1,75 @@
From 344e624f91010b6041c22ee8a24c9305b82af969 Mon Sep 17 00:00:00 2001
From: Vojtech Trefny <vtrefny@redhat.com>
Date: Tue, 18 May 2021 12:54:02 +0200
Subject: [PATCH] Fix resolving devices with names that look like BIOS drive
number
A RAID array named "10" will not be resolved because we try to
resolve it using EDD data and after this lookup fails, we don't
try the name.
Resolves: rhbz#1960798
---
blivet/devicetree.py | 18 +++++++++---------
tests/devicetree_test.py | 4 ++++
2 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/blivet/devicetree.py b/blivet/devicetree.py
index 88e9f0e5..f4ae1968 100644
--- a/blivet/devicetree.py
+++ b/blivet/devicetree.py
@@ -634,20 +634,20 @@ class DeviceTreeBase(object):
(label.startswith("'") and label.endswith("'"))):
label = label[1:-1]
device = self.labels.get(label)
- elif re.match(r'(0x)?[A-Fa-f0-9]{2}(p\d+)?$', devspec):
- # BIOS drive number
- (drive, _p, partnum) = devspec.partition("p")
- spec = int(drive, 16)
- for (edd_name, edd_number) in self.edd_dict.items():
- if edd_number == spec:
- device = self.get_device_by_name(edd_name + partnum)
- break
elif options and "nodev" in options.split(","):
device = self.get_device_by_name(devspec)
if not device:
device = self.get_device_by_path(devspec)
else:
- if not devspec.startswith("/dev/"):
+ if re.match(r'(0x)?[A-Fa-f0-9]{2}(p\d+)?$', devspec):
+ # BIOS drive number
+ (drive, _p, partnum) = devspec.partition("p")
+ spec = int(drive, 16)
+ for (edd_name, edd_number) in self.edd_dict.items():
+ if edd_number == spec:
+ device = self.get_device_by_name(edd_name + partnum)
+ break
+ if not device and not devspec.startswith("/dev/"):
device = self.get_device_by_name(devspec)
if not device:
devspec = "/dev/" + devspec
diff --git a/tests/devicetree_test.py b/tests/devicetree_test.py
index 11f8469d..b033343d 100644
--- a/tests/devicetree_test.py
+++ b/tests/devicetree_test.py
@@ -49,6 +49,9 @@ class DeviceTreeTestCase(unittest.TestCase):
dev3 = StorageDevice("sdp2", exists=True)
dt._add_device(dev3)
+ dev4 = StorageDevice("10", exists=True)
+ dt._add_device(dev4)
+
dt.edd_dict.update({"dev1": 0x81,
"dev2": 0x82})
@@ -62,6 +65,7 @@ class DeviceTreeTestCase(unittest.TestCase):
self.assertEqual(dt.resolve_device("0x82"), dev2)
self.assertEqual(dt.resolve_device(dev3.name), dev3)
+ self.assertEqual(dt.resolve_device(dev4.name), dev4)
def test_device_name(self):
# check that devicetree.names property contains all device's names
--
2.31.1

View File

@ -0,0 +1,151 @@
From dc1e2fe7783748528cac2f7aa516c89d1959b052 Mon Sep 17 00:00:00 2001
From: Vojtech Trefny <vtrefny@redhat.com>
Date: Thu, 29 Jul 2021 14:44:22 +0200
Subject: [PATCH] Do not set chunk size for RAID 1
Setting chunk size for RAID 1 doesn't make sense and latest
mdadm started returning error instead of ignoring the --chunk
option when creating an array.
Resolves: rhbz#1987170
---
blivet/devicelibs/raid.py | 12 ++++++++++
blivet/devices/md.py | 15 ++++++++++---
tests/devices_test/md_test.py | 41 +++++++++++++++++++++++++++++++++--
3 files changed, 63 insertions(+), 5 deletions(-)
diff --git a/blivet/devicelibs/raid.py b/blivet/devicelibs/raid.py
index 19c3fae98..a9e241c7a 100644
--- a/blivet/devicelibs/raid.py
+++ b/blivet/devicelibs/raid.py
@@ -462,6 +462,18 @@ def _pad(self, size, chunk_size):
def _get_recommended_stride(self, member_count):
return None
+ def get_size(self, member_sizes, num_members=None, chunk_size=None, superblock_size_func=None):
+ if not member_sizes:
+ return Size(0)
+
+ if num_members is None:
+ num_members = len(member_sizes)
+
+ min_size = min(member_sizes)
+ superblock_size = superblock_size_func(min_size)
+ min_data_size = self._trim(min_size - superblock_size, chunk_size)
+ return self.get_net_array_size(num_members, min_data_size)
+
RAID1 = RAID1()
ALL_LEVELS.add_raid_level(RAID1)
diff --git a/blivet/devices/md.py b/blivet/devices/md.py
index 69eee93a5..d1a2faf1f 100644
--- a/blivet/devices/md.py
+++ b/blivet/devices/md.py
@@ -138,7 +138,7 @@ def __init__(self, name, level=None, major=None, minor=None, size=None,
if self.exists:
self._chunk_size = self.read_chunk_size()
else:
- self._chunk_size = chunk_size or mdraid.MD_CHUNK_SIZE
+ self.chunk_size = chunk_size or Size(0)
if not self.exists and not isinstance(metadata_version, str):
self.metadata_version = "default"
@@ -208,8 +208,14 @@ def sector_size(self):
@property
def chunk_size(self):
- if self.exists and self._chunk_size == Size(0):
- self._chunk_size = self.read_chunk_size()
+ if self._chunk_size == Size(0):
+ if self.exists:
+ return self.read_chunk_size()
+ else:
+ if self.level == raid.RAID1:
+ return self._chunk_size
+ else:
+ return mdraid.MD_CHUNK_SIZE
return self._chunk_size
@chunk_size.setter
@@ -223,6 +229,9 @@ def chunk_size(self, newsize):
if self.exists:
raise ValueError("cannot set chunk size for an existing device")
+ if self.level == raid.RAID1 and newsize != Size(0):
+ raise ValueError("specifying chunk size is not allowed for raid1")
+
self._chunk_size = newsize
def read_chunk_size(self):
diff --git a/tests/devices_test/md_test.py b/tests/devices_test/md_test.py
index 46df76d3d..47a0fa0cc 100644
--- a/tests/devices_test/md_test.py
+++ b/tests/devices_test/md_test.py
@@ -1,6 +1,11 @@
import six
import unittest
+try:
+ from unittest.mock import patch
+except ImportError:
+ from mock import patch
+
import blivet
from blivet.devices import StorageDevice
@@ -27,9 +32,27 @@ def test_chunk_size1(self):
raid_array = MDRaidArrayDevice(name="raid", level="raid0", member_devices=2,
total_devices=2, parents=[member1, member2])
- # no chunk_size specified -- default value
+ # no chunk_size specified and RAID0 -- default value
self.assertEqual(raid_array.chunk_size, mdraid.MD_CHUNK_SIZE)
+ with patch("blivet.devices.md.blockdev.md.create") as md_create:
+ raid_array._create()
+ md_create.assert_called_with("/dev/md/raid", "raid0", ["/dev/member1", "/dev/member2"],
+ 0, version="default", bitmap=False,
+ chunk_size=mdraid.MD_CHUNK_SIZE)
+
+ raid_array = MDRaidArrayDevice(name="raid", level="raid1", member_devices=2,
+ total_devices=2, parents=[member1, member2])
+
+ # no chunk_size specified and RAID1 -- no chunk size set (0)
+ self.assertEqual(raid_array.chunk_size, Size(0))
+
+ with patch("blivet.devices.md.blockdev.md.create") as md_create:
+ raid_array._create()
+ md_create.assert_called_with("/dev/md/raid", "raid1", ["/dev/member1", "/dev/member2"],
+ 0, version="default", bitmap=True,
+ chunk_size=0)
+
def test_chunk_size2(self):
member1 = StorageDevice("member1", fmt=blivet.formats.get_format("mdmember"),
@@ -40,11 +63,25 @@ def test_chunk_size2(self):
raid_array = MDRaidArrayDevice(name="raid", level="raid0", member_devices=2,
total_devices=2, parents=[member1, member2],
chunk_size=Size("1024 KiB"))
-
self.assertEqual(raid_array.chunk_size, Size("1024 KiB"))
+ # for raid0 setting chunk_size = 0 means "default"
+ raid_array.chunk_size = Size(0)
+ self.assertEqual(raid_array.chunk_size, mdraid.MD_CHUNK_SIZE)
+
with six.assertRaisesRegex(self, ValueError, "new chunk size must be of type Size"):
raid_array.chunk_size = 1
with six.assertRaisesRegex(self, ValueError, "new chunk size must be multiple of 4 KiB"):
raid_array.chunk_size = Size("5 KiB")
+
+ with six.assertRaisesRegex(self, ValueError, "specifying chunk size is not allowed for raid1"):
+ MDRaidArrayDevice(name="raid", level="raid1", member_devices=2,
+ total_devices=2, parents=[member1, member2],
+ chunk_size=Size("1024 KiB"))
+
+ raid_array = MDRaidArrayDevice(name="raid", level="raid1", member_devices=2,
+ total_devices=2, parents=[member1, member2])
+
+ with six.assertRaisesRegex(self, ValueError, "specifying chunk size is not allowed for raid1"):
+ raid_array.chunk_size = Size("512 KiB")

View File

@ -0,0 +1,231 @@
From 8dbb92d692db9cbfbca0c82a1ed10a0492208534 Mon Sep 17 00:00:00 2001
From: Vojtech Trefny <vtrefny@redhat.com>
Date: Wed, 4 Aug 2021 13:00:53 +0200
Subject: [PATCH 1/3] edd_test: Locate the edd_data based on the test file
location
We can't use the blivet.edd module location when running tests
against installed version of blivet.
---
tests/devicelibs_test/edd_test.py | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/tests/devicelibs_test/edd_test.py b/tests/devicelibs_test/edd_test.py
index 21bbcffc4..0d0824e6b 100644
--- a/tests/devicelibs_test/edd_test.py
+++ b/tests/devicelibs_test/edd_test.py
@@ -5,7 +5,6 @@
import unittest
import os
-import inspect
import logging
import copy
@@ -114,9 +113,9 @@ def root(self, name):
name = name[:-1]
if name.startswith("/"):
name = name[1:]
- dirname = os.path.dirname(inspect.getfile(edd))
+ dirname = os.path.abspath(os.path.dirname(__file__))
return os.path.join(dirname,
- "../../tests/devicelibs_test/edd_data/",
+ "edd_data/",
name)
def edd_debug(self, *args):
From 924bc805f692b0f050a8a8b8187769f36aea059f Mon Sep 17 00:00:00 2001
From: Vojtech Trefny <vtrefny@redhat.com>
Date: Wed, 4 Aug 2021 13:02:08 +0200
Subject: [PATCH 2/3] tests: Allow running tests without the tests directory in
PYTHONPATH
When running the tests against installed version of blivet, the
"tests" directory is not in PYTHONPATH so we need to import all
helper modules using relative path.
---
tests/action_test.py | 2 +-
tests/devicelibs_test/edd_test.py | 2 +-
tests/{ => devicelibs_test}/lib.py | 0
tests/formats_test/fs_test.py | 2 +-
tests/formats_test/fslabeling.py | 2 +-
tests/formats_test/fstesting.py | 2 +-
tests/formats_test/fsuuid.py | 2 +-
tests/formats_test/labeling_test.py | 2 +-
tests/{ => formats_test}/loopbackedtestcase.py | 0
tests/formats_test/luks_test.py | 2 +-
tests/formats_test/lvmpv_test.py | 2 +-
tests/partitioning_test.py | 2 +-
12 files changed, 10 insertions(+), 10 deletions(-)
rename tests/{ => devicelibs_test}/lib.py (100%)
rename tests/{ => formats_test}/loopbackedtestcase.py (100%)
diff --git a/tests/action_test.py b/tests/action_test.py
index f60cf5d7e..8509ce35a 100644
--- a/tests/action_test.py
+++ b/tests/action_test.py
@@ -5,7 +5,7 @@
except ImportError:
from mock import Mock
-from tests.storagetestcase import StorageTestCase
+from storagetestcase import StorageTestCase
import blivet
from blivet.formats import get_format
from blivet.size import Size
diff --git a/tests/devicelibs_test/edd_test.py b/tests/devicelibs_test/edd_test.py
index 0d0824e6b..0db1fd16e 100644
--- a/tests/devicelibs_test/edd_test.py
+++ b/tests/devicelibs_test/edd_test.py
@@ -10,7 +10,7 @@
from blivet import arch
from blivet.devicelibs import edd
-from tests import lib
+from . import lib
class FakeDevice(object):
diff --git a/tests/lib.py b/tests/devicelibs_test/lib.py
similarity index 100%
rename from tests/lib.py
rename to tests/devicelibs_test/lib.py
diff --git a/tests/formats_test/fs_test.py b/tests/formats_test/fs_test.py
index ab3499a76..bd6433707 100644
--- a/tests/formats_test/fs_test.py
+++ b/tests/formats_test/fs_test.py
@@ -10,7 +10,7 @@
from blivet.formats import get_format
from blivet.devices import PartitionDevice, DiskDevice
-from tests import loopbackedtestcase
+from . import loopbackedtestcase
from . import fstesting
diff --git a/tests/formats_test/fslabeling.py b/tests/formats_test/fslabeling.py
index fbb28eee7..0e0dc2612 100644
--- a/tests/formats_test/fslabeling.py
+++ b/tests/formats_test/fslabeling.py
@@ -2,7 +2,7 @@
import abc
import six
-from tests import loopbackedtestcase
+from . import loopbackedtestcase
from blivet.errors import FSError, FSReadLabelError
from blivet.size import Size
diff --git a/tests/formats_test/fstesting.py b/tests/formats_test/fstesting.py
index 86b2a1168..e34584d88 100644
--- a/tests/formats_test/fstesting.py
+++ b/tests/formats_test/fstesting.py
@@ -5,7 +5,7 @@
import os
import tempfile
-from tests import loopbackedtestcase
+from . import loopbackedtestcase
from blivet.errors import FSError, FSResizeError, DeviceFormatError
from blivet.size import Size, ROUND_DOWN
from blivet.formats import fs
diff --git a/tests/formats_test/fsuuid.py b/tests/formats_test/fsuuid.py
index c80039457..16aa19a66 100644
--- a/tests/formats_test/fsuuid.py
+++ b/tests/formats_test/fsuuid.py
@@ -3,7 +3,7 @@
import six
from unittest import skipIf
-from tests import loopbackedtestcase
+from . import loopbackedtestcase
from blivet.errors import FSError, FSWriteUUIDError
from blivet.size import Size
from blivet.util import capture_output
diff --git a/tests/formats_test/labeling_test.py b/tests/formats_test/labeling_test.py
index e26cb7df1..d24e66191 100644
--- a/tests/formats_test/labeling_test.py
+++ b/tests/formats_test/labeling_test.py
@@ -1,10 +1,10 @@
import unittest
-from tests import loopbackedtestcase
from blivet.formats import device_formats
import blivet.formats.fs as fs
import blivet.formats.swap as swap
+from . import loopbackedtestcase
from . import fslabeling
diff --git a/tests/loopbackedtestcase.py b/tests/formats_test/loopbackedtestcase.py
similarity index 100%
rename from tests/loopbackedtestcase.py
rename to tests/formats_test/loopbackedtestcase.py
diff --git a/tests/formats_test/luks_test.py b/tests/formats_test/luks_test.py
index 1edbdcb28..5f25f0988 100644
--- a/tests/formats_test/luks_test.py
+++ b/tests/formats_test/luks_test.py
@@ -9,7 +9,7 @@
from blivet.size import Size
-from tests import loopbackedtestcase
+from . import loopbackedtestcase
class LUKSTestCase(loopbackedtestcase.LoopBackedTestCase):
diff --git a/tests/formats_test/lvmpv_test.py b/tests/formats_test/lvmpv_test.py
index cbd2c4195..cdc33ec4d 100644
--- a/tests/formats_test/lvmpv_test.py
+++ b/tests/formats_test/lvmpv_test.py
@@ -2,7 +2,7 @@
from blivet.size import Size
-from tests import loopbackedtestcase
+from . import loopbackedtestcase
class LVMPVTestCase(loopbackedtestcase.LoopBackedTestCase):
diff --git a/tests/partitioning_test.py b/tests/partitioning_test.py
index 9b27f0c0d..e7b7aa375 100644
--- a/tests/partitioning_test.py
+++ b/tests/partitioning_test.py
@@ -31,7 +31,7 @@
from blivet.errors import PartitioningError
-from tests.imagebackedtestcase import ImageBackedTestCase
+from imagebackedtestcase import ImageBackedTestCase
from blivet.blivet import Blivet
from blivet.util import sparsetmpfile
from blivet.formats import get_format
From 99385bd67ac944c43bc77f4b5465c672203e2679 Mon Sep 17 00:00:00 2001
From: Vojtech Trefny <vtrefny@redhat.com>
Date: Fri, 6 Aug 2021 14:51:01 +0200
Subject: [PATCH 3/3] tests: Print version and blivet location when running
tests
---
tests/run_tests.py | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/tests/run_tests.py b/tests/run_tests.py
index 32e3f2d3a..8ad8b61ad 100644
--- a/tests/run_tests.py
+++ b/tests/run_tests.py
@@ -32,6 +32,11 @@
testdir = os.path.abspath(os.path.dirname(__file__))
+ import blivet
+ print("Running tests with Blivet %s from %s" % (blivet.__version__,
+ os.path.abspath(os.path.dirname(blivet.__file__))),
+ file=sys.stderr)
+
if args.testname:
for n in args.testname:
suite.addTests(unittest.TestLoader().loadTestsFromName(n))

View File

@ -0,0 +1,68 @@
From a977e8389a09615615dc76dee8aaaea1cc0ac54b Mon Sep 17 00:00:00 2001
From: Vojtech Trefny <vtrefny@redhat.com>
Date: Thu, 22 Jul 2021 09:26:54 +0200
Subject: [PATCH 1/2] Tell LVM to ignore the new devices file for now
We currently don't support working with the devices file and it's
not possible to use lvm.conf filters together with the devices
file so we need to tell LVM to ignore it until we can support it.
---
blivet/devicelibs/lvm.py | 4 ++++
blivet/tasks/availability.py | 1 +
2 files changed, 5 insertions(+)
diff --git a/blivet/devicelibs/lvm.py b/blivet/devicelibs/lvm.py
index d56a76edc..989ecccaf 100644
--- a/blivet/devicelibs/lvm.py
+++ b/blivet/devicelibs/lvm.py
@@ -91,6 +91,10 @@ def _set_global_config():
if filter_string:
devices_string += " %s" % filter_string
+ # for now ignore the LVM devices file and rely on our filters
+ if availability.LVMDEVICES.available:
+ devices_string += " use_devicesfile=0"
+
# devices_string can have (inside the brackets) "dir", "scan",
# "preferred_names", "filter", "cache_dir", "write_cache_state",
# "types", "sysfs_scan", "md_component_detection". see man lvm.conf.
diff --git a/blivet/tasks/availability.py b/blivet/tasks/availability.py
index 1fd805901..5d3e295da 100644
--- a/blivet/tasks/availability.py
+++ b/blivet/tasks/availability.py
@@ -451,6 +451,7 @@ def available_resource(name):
HFORMAT_APP = application("hformat")
JFSTUNE_APP = application("jfs_tune")
KPARTX_APP = application("kpartx")
+LVMDEVICES = application("lvmdevices")
MKDOSFS_APP = application("mkdosfs")
MKDOSFS_NEW_APP = application_by_version("mkdosfs", DOSFSTOOLS_VERSION)
MKE2FS_APP = application_by_version("mke2fs", E2FSPROGS_VERSION)
From 08c137b5c98b24a9ba3df21f04cd20120c61198c Mon Sep 17 00:00:00 2001
From: Vojtech Trefny <vtrefny@redhat.com>
Date: Thu, 22 Jul 2021 11:33:46 +0200
Subject: [PATCH 2/2] Make sure LVM config is updated before running pvcreate
Our internal "global" LVM config is set during reset() but we have
test cases that run pvcreate without running reset() first so we
need to make sure to update the global config before running it
because the config string now also controls whether the new LVM
devices file will be used or not.
---
blivet/formats/lvmpv.py | 2 ++
1 file changed, 2 insertions(+)
diff --git a/blivet/formats/lvmpv.py b/blivet/formats/lvmpv.py
index e4182adb2..ea84e9e4b 100644
--- a/blivet/formats/lvmpv.py
+++ b/blivet/formats/lvmpv.py
@@ -125,6 +125,8 @@ def _create(self, **kwargs):
log_method_call(self, device=self.device,
type=self.type, status=self.status)
+ lvm._set_global_config()
+
ea_yes = blockdev.ExtraArg.new("-y", "")
blockdev.lvm.pvcreate(self.device, data_alignment=self.data_alignment, extra=[ea_yes])

3383
SPECS/python-blivet.spec Normal file

File diff suppressed because it is too large Load Diff