patches to support fancier kstest setups
by Chris Lumens
The following three patches to anaconda and three patches to lorax allow us to
set up tests that have much fancier disk setups. This can be as simple as
multiple disks, or as complicated as disks that are preinitialized with some
formatting.
This requires passing extra arguments to virt-install that LMC shouldn't
support. It already has enough arguments. Instead I have broken some code out
of LMC into extra pylorax modules and then made an LMC-like program so we still
get all the nice timeout and traceback detection. I don't think there's more
code that can be shared between LMC and my own program without making it all
more complicated than it needs to be.
This has the extra added bonus of meaning we can just do "autopart" in our
tests unless we want something else. I've gone ahead and made that change.
It also requires that you create the disks ahead of time. I've made that change
as well, and moved all the common code into its own file so everyone doesn't
have to remember it every time.
Support for fancy networking is not yet present, but should at least be possible
now. I simply don't yet know what will be required or how to do it.
- Chris
8 years, 11 months
[PATCH blivet/rhel7-branch] Introduce a new doReqPartition method that is similar to doAutoPartition.
by Chris Lumens
This method allows automatically creating just platform-specific partitions,
allowing kickstart files to do custom partitioning without having to introduce
lots of machine-specific details.
This also required splitting up platform.setDefaultPartitioning into two more
fined grained methods. I've left the older method around with its existing
behavior for anyone who may be using it. The split allows for users to be
even more picky in how much autostuff they want - just things like biosboot,
or also the /boot partition?
Related: rhbz#1164660
---
blivet/partitioning.py | 37 ++++++++++++++++++++++++++++++++-----
blivet/platform.py | 44 ++++++++++++++++++++++++++++++--------------
2 files changed, 62 insertions(+), 19 deletions(-)
diff --git a/blivet/partitioning.py b/blivet/partitioning.py
index c429514..eefd039 100644
--- a/blivet/partitioning.py
+++ b/blivet/partitioning.py
@@ -38,7 +38,7 @@ import logging
log = logging.getLogger("blivet")
def _getCandidateDisks(storage):
- """ Return a list of disks to be used for autopart.
+ """ Return a list of disks to be used for autopart/reqpart.
Disks must be partitioned and have a single free region large enough
for a default-sized (500MiB) partition. They must also be in
@@ -115,8 +115,8 @@ def _scheduleImplicitPartitions(storage, disks, min_luks_entropy=0):
return devs
-def _schedulePartitions(storage, disks, min_luks_entropy=0):
- """ Schedule creation of autopart partitions.
+def _schedulePartitions(storage, disks, min_luks_entropy=0, requests=None):
+ """ Schedule creation of autopart/reqpart partitions.
This only schedules the requests for actual partitions.
@@ -127,9 +127,15 @@ def _schedulePartitions(storage, disks, min_luks_entropy=0):
:param min_luks_entropy: minimum entropy in bits required for
luks format creation
:type min_luks_entropy: int
+ :param requests: list of partitioning requests to operate on,
+ or `~.storage.autoPartitionRequests` by default
+ :type requests: list of :class:`~.partspec.PartSpec` instances
:returns: None
:rtype: None
"""
+ if not requests:
+ requests = storage.autoPartitionRequests
+
# basis for requests with requiredSpace is the sum of the sizes of the
# two largest free regions
all_free = getFreeRegions(disks)
@@ -158,8 +164,8 @@ def _schedulePartitions(storage, disks, min_luks_entropy=0):
#
# First pass is for partitions only. We'll do LVs later.
#
- for request in storage.autoPartitionRequests:
- if ((request.lv and
+ for request in requests:
+ if ((request.lv and storage.doAutoPart and
storage.autoPartType in (AUTOPART_TYPE_LVM,
AUTOPART_TYPE_LVM_THINP)) or
(request.btr and storage.autoPartType == AUTOPART_TYPE_BTRFS)):
@@ -335,6 +341,27 @@ def _scheduleVolumes(storage, devs):
# schedule the device for creation
storage.createDevice(dev)
+def doReqPartition(storage, requests):
+ """Perform automatic partitioning of just required platform-specific
+ partitions. This is incompatible with doAutoPartition.
+
+ :param storage: a :class:`~.Blivet` instance
+ :type storage: :class:`~.Blivet`
+ :param requests: list of partitioning requests to operate on,
+ or `~.storage.autoPartitionRequests` by default
+ :type requests: list of :class:`~.partspec.PartSpec` instances
+ """
+ if not storage.partitioned:
+ raise NoDisksError(_("No usable disks selected"))
+
+ disks = _getCandidateDisks(storage)
+
+ if disks == []:
+ raise NotEnoughFreeSpaceError(_("Not enough free space on disks for "
+ "automatic partitioning"))
+
+ _schedulePartitions(storage, disks, [], requests=requests)
+
def doAutoPartition(storage, data, min_luks_entropy=0):
""" Perform automatic partitioning.
diff --git a/blivet/platform.py b/blivet/platform.py
index cd93f97..20b87bf 100644
--- a/blivet/platform.py
+++ b/blivet/platform.py
@@ -152,11 +152,22 @@ class Platform(object):
_packages.append('dracut-fips')
return _packages
- def setDefaultPartitioning(self):
- """Return the default platform-specific partitioning information."""
+ def setPlatformBootloaderReqs(self):
+ """Return the required platform-specific bootloader partition
+ information. These are typically partitions that do not get mounted,
+ like biosboot or prepboot, but may also include the /boot/efi
+ partition."""
+ return []
+
+ def setPlatformBootPartition(self):
+ """Return the default /boot partition for this platform."""
return [PartSpec(mountpoint="/boot", size=Size("500MiB"),
weight=self.weight(mountpoint="/boot"))]
+ def setDefaultPartitioning(self):
+ """Return the default platform-specific partitioning information."""
+ return self.setPlatformBootloaderReqs() + self.setPlatformBootPartition()
+
def weight(self, fstype=None, mountpoint=None):
""" Given an fstype (as a string) or a mountpoint, return an integer
for the base sorting weight. This is used to modify the sort
@@ -190,9 +201,9 @@ class X86(Platform):
def __init__(self):
super(X86, self).__init__()
- def setDefaultPartitioning(self):
+ def setPlatformBootloaderReqs(self):
"""Return the default platform-specific partitioning information."""
- ret = Platform.setDefaultPartitioning(self)
+ ret = Platform.setPlatformBootloaderReqs(self)
ret.append(PartSpec(fstype="biosboot", size=Size("1MiB"),
weight=self.weight(fstype="biosboot")))
return ret
@@ -223,8 +234,8 @@ class EFI(Platform):
"an EFI System Partition on a GPT-formatted "
"disk, mounted at /boot/efi.")
- def setDefaultPartitioning(self):
- ret = Platform.setDefaultPartitioning(self)
+ def setPlatformBootloaderReqs(self):
+ ret = Platform.setPlatformBootloaderReqs(self)
ret.append(PartSpec(mountpoint="/boot/efi", fstype="efi",
size=Size("20MiB"), maxSize=Size("200MiB"),
grow=True, weight=self.weight(fstype="efi")))
@@ -245,8 +256,8 @@ class MacEFI(EFI):
_non_linux_format_types = ["macefi"]
_packages = ["mactel-boot"]
- def setDefaultPartitioning(self):
- ret = Platform.setDefaultPartitioning(self)
+ def setPlatformBootloaderReqs(self):
+ ret = Platform.setPlatformBootloaderReqs(self)
ret.append(PartSpec(mountpoint="/boot/efi", fstype="macefi",
size=Size("20MiB"), maxSize=Size("200MiB"),
grow=True, weight=self.weight(mountpoint="/boot/efi")))
@@ -273,8 +284,8 @@ class IPSeriesPPC(PPC):
"within the first 4GiB of an MBR- "
"or GPT-formatted disk.")
- def setDefaultPartitioning(self):
- ret = PPC.setDefaultPartitioning(self)
+ def setPlatformBootloaderReqs(self):
+ ret = PPC.setPlatformBootloaderReqs(self)
ret.append(PartSpec(fstype="prepboot", size=Size("4MiB"),
weight=self.weight(fstype="prepboot")))
return ret
@@ -298,8 +309,8 @@ class NewWorldPPC(PPC):
"Partition on an Apple Partition Map-"
"formatted disk.")
- def setDefaultPartitioning(self):
- ret = Platform.setDefaultPartitioning(self)
+ def setPlatformBootloaderReqs(self):
+ ret = Platform.setPlatformBootloaderReqs(self)
ret.append(PartSpec(fstype="appleboot", size=Size("1MiB"),
weight=self.weight(fstype="appleboot")))
return ret
@@ -333,10 +344,11 @@ class S390(Platform):
def __init__(self):
Platform.__init__(self)
- def setDefaultPartitioning(self):
+ def setPlatformBootPartition(self):
"""Return the default platform-specific partitioning information."""
return [PartSpec(mountpoint="/boot", size=Size("500MiB"),
weight=self.weight(mountpoint="/boot"), lv=False)]
+
def requiredDiskLabelType(self, device_type):
"""The required disklabel type for the specified device type."""
if device_type == parted.DEVICE_DASD:
@@ -379,12 +391,16 @@ class omapARM(ARM):
_boot_stage1_missing_error = N_("You must include a U-Boot Partition on a "
"FAT-formatted disk, mounted at /boot/uboot.")
- def setDefaultPartitioning(self):
+ def setPlatformBootloaderReqs(self):
"""Return the ARM-OMAP platform-specific partitioning information."""
ret = [PartSpec(mountpoint="/boot/uboot", fstype="vfat",
size=Size("20MiB"), maxSize=Size("200MiB"),
grow=True,
weight=self.weight(fstype="vfat", mountpoint="/boot/uboot"))]
+ return ret
+
+ def setDefaultPartitioning(self):
+ ret = ARM.setDefaultPartitioning(self)
ret.append(PartSpec(mountpoint="/", fstype="ext4",
size=Size("2GiB"), maxSize=Size("3GiB"),
weight=self.weight(mountpoint="/")))
--
2.2.2
8 years, 11 months
Take 03: libblockdev s390 things
by Samantha N. Bueno
This introoduces the libblockdev s390 plugin and adapts blivet and
anaconda code for the changes.
The only s390-related functions not moved into libblockdev as of this
moment are the zfcp online/offline functions. They're terrible. They'll
be moved a little later.
Issues fixed in this edition:
-- s390x tests are all arch specific
-- Various other minor errors pointed out by vpodzime
8 years, 11 months
Updated: [rhinstaller/blivet/pulls/120 master] Run the test suite with both Python 2 and Python 3
by dashea
Since blivet is supposed to be compatible with both python 2 and 3 IMO it makes sense to run the test suite with both versions. (not to mention build the entire package with 2 or 3) At present only python2 is used to execute the test suite while python3 is used for pylint (due to pocketlint being python3 only).
This PR introduces the following changes:
- adds Makefile targets to execute the test suite under python 2 and 3 separately
- make test now runs the test suite with *both* python 2 and 3
- adds 2 separate targets to execute test suite with coverage report for python 2 and 3
- adds new check-requires target which checks if Requires:/BuildRequires and a few manual added ones are present
- replaces `/usr/bin/python` with `/usr/bin/env python` inside test cases. NOTE: I don't see any executable tests/*.py files but maybe this is a good measure. Otherwise this line doesn't have any effect and can be removed.
- updates the test cases to take care of several deprecation warnings coming from unittest. I've introduces a BlivetTestCase class which adds some aliases in case we're running with python2.
TODO:
There are still a few places which use hard-coded python version:
- Makefile uses PYTHON=python2 which is used in a few places calling setup.py
- some scripts/ use /usr/bin/python explicitly
- runpylint.py uses /usr/bin/python3 explicitly
make check uses pocketlint which is Python3 only. I have not looked into how hard it will be to build it for Python2. Will do it tomorrow.
Test results:
Running the test suite with python2 gives me 4 errors:
```
======================================================================
ERROR: testAvailabilityMDRAIDplugin (devices_test.dependencies_test.MockingDeviceDependenciesTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/root/blivet/tests/devices_test/dependencies_test.py", line 64, in testAvailabilityMDRAIDplugin
self.assertIsNotNone(ActionCreateFormat(self.luks, fmt=getFormat("macefi")))
File "blivet/deviceaction.py", line 530, in __init__
raise ValueError("resource to create this format %s is unavailable" % fmt)
ValueError: resource to create this format non-existent macefi filesystem is unavailable
======================================================================
ERROR: testGetLabelArgs (formats_test.labeling_test.MethodsTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/root/blivet/tests/formats_test/labeling_test.py", line 73, in testGetLabelArgs
reiserfs = self.fs["reiserfs"]
KeyError: 'reiserfs'
======================================================================
ERROR: testActionDependencies (action_test.DeviceActionTestCase)
Verify correct functioning of action dependencies.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/root/blivet/tests/action_test.py", line 944, in testActionDependencies
format_lv = ActionCreateFormat(testlv, fmt)
File "blivet/deviceaction.py", line 530, in __init__
raise ValueError("resource to create this format %s is unavailable" % fmt)
ValueError: resource to create this format non-existent None is unavailable
======================================================================
ERROR: testContainerActions (action_test.DeviceActionTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/root/blivet/tests/action_test.py", line 1122, in testContainerActions
fmt=new_lv_format)
File "tests/storagetestcase.py", line 245, in scheduleCreateFormat
action = blivet.deviceaction.ActionCreateFormat(device, fmt)
File "blivet/deviceaction.py", line 530, in __init__
raise ValueError("resource to create this format %s is unavailable" % fmt)
ValueError: resource to create this format non-existent xfs filesystem is unavailable
----------------------------------------------------------------------
Ran 467 tests in 704.377s
FAILED (errors=4, skipped=319)
```
Running with python3 gives me much more of the type:
```
======================================================================
ERROR: testMountingXFS (formats_test.selinux_test.SELinuxContextTestCase)
XFS does not have a lost+found directory.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/root/blivet/tests/formats_test/selinux_test.py", line 67, in testMountingXFS
an_fs = fs.XFS(device=self.loopDevices[0], label="test")
File "/root/blivet/blivet/formats/fs.py", line 101, in __init__
DeviceFormat.__init__(self, **kwargs)
File "/root/blivet/blivet/formats/__init__.py", line 186, in __init__
self.device = kwargs.get("device")
File "/root/blivet/blivet/formats/__init__.py", line 315, in <lambda>
lambda f,d: f._setDevice(d),
File "/root/blivet/blivet/formats/__init__.py", line 306, in _setDevice
error_msg = self._deviceCheck(devspec)
File "/root/blivet/blivet/formats/__init__.py", line 301, in _deviceCheck
if devspec and not devspec.startswith("/"):
TypeError: startswith first arg must be bytes or a tuple of bytes, not str
----------------------------------------------------------------------
I'm running on a recent F22 system upgraded to packages from the Rawhide repo. Let me know how would you like to proceed.
```
--
To view this pull request on github, visit https://github.com/rhinstaller/blivet/pull/120
8 years, 11 months