Prompted by jenkins, I ran blivet's unit tests as root in a vm and here is what I had to do to make it run, aside from applying my recent pyparted patch to the code in python's site-lib.
Patch 2 is old code that I've wanted to remove for some time now, which I found was getting triggered erroneously when manipulating a container's member set as part of the action tests.
David Lehman (4): Bypass size getter when mocking new devices. Remove unused lvm and md activation code. Clean up mocking done by udev tests when finished. Update selinux tests for default context of mounts under /tmp.
blivet/devices.py | 20 -------------------- tests/formats_test/selinux_test.py | 6 +++--- tests/storagetestcase.py | 2 +- tests/udev_test.py | 12 ++++++++++-- 4 files changed, 14 insertions(+), 26 deletions(-)
The size getter gets the size from the partedDevice, which is not advisable while we're in the process of mocking the partedDevice. --- tests/storagetestcase.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/storagetestcase.py b/tests/storagetestcase.py index 18b6f57..11de630 100644 --- a/tests/storagetestcase.py +++ b/tests/storagetestcase.py @@ -66,7 +66,7 @@ class StorageTestCase(unittest.TestCase): if exists: # set up mock parted.Device w/ correct size device._partedDevice = Mock() - device._partedDevice.getLength = Mock(return_value=int(device.size.convertTo(spec="B"))) + device._partedDevice.getLength = Mock(return_value=int(device._size.convertTo(spec="B"))) device._partedDevice.sectorSize = 512
if isinstance(device, blivet.devices.PartitionDevice):
This was used before we let systemd/udev set up storage for us. --- blivet/devices.py | 20 -------------------- 1 file changed, 20 deletions(-)
diff --git a/blivet/devices.py b/blivet/devices.py index 25b7586..fc353e0 100644 --- a/blivet/devices.py +++ b/blivet/devices.py @@ -2601,12 +2601,6 @@ class LVMVolumeGroupDevice(ContainerDevice): def _addParent(self, member): super(LVMVolumeGroupDevice, self)._addParent(member)
- # now see if the VG can be activated - ## XXX TODO: remove this activation code - if self.exists and member.format.exists and self.complete and \ - flags.installer_mode: - self.setup() - if (self.exists and member.format.exists and len(self.parents) + 1 == self.pvCount): self._complete = True @@ -3794,20 +3788,6 @@ class MDRaidArrayDevice(ContainerDevice): def _addParent(self, member): super(MDRaidArrayDevice, self)._addParent(member)
- ## XXX TODO: remove this whole block of activation code - if self.exists and member.format.exists and flags.installer_mode: - member.setup() - udev.settle() - - if self.spares <= 0: - try: - mdraid.mdnominate(member.path) - # mdadd causes udev events - udev.settle() - except errors.MDRaidError as e: - log.warning("failed to add member %s to md array %s: %s", - member.path, self.path, e) - if self.status and member.format.exists: # we always probe since the device may not be set up when we want # information about it
--- tests/udev_test.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/tests/udev_test.py b/tests/udev_test.py index a930031..e3e817d 100644 --- a/tests/udev_test.py +++ b/tests/udev_test.py @@ -7,8 +7,18 @@ class UdevTest(unittest.TestCase):
def setUp(self): import blivet.udev + self._blivet_os = blivet.udev.os + self._blivet_log = blivet.udev.log + self._blivet_util = blivet.udev.util blivet.udev.os = mock.Mock() blivet.udev.log = mock.Mock() + blivet.udev.util = mock.Mock() + + def tearDown(self): + import blivet.udev + blivet.udev.log = self._blivet_log + blivet.udev.os = self._blivet_os + blivet.udev.util = self._blivet_util
def test_udev_get_device(self): import blivet.udev @@ -18,13 +28,11 @@ class UdevTest(unittest.TestCase):
def udev_settle_test(self): import blivet.udev - blivet.udev.util = mock.Mock() blivet.udev.settle() self.assertTrue(blivet.udev.util.run_program.called)
def udev_trigger_test(self): import blivet.udev - blivet.udev.util = mock.Mock() blivet.udev.trigger() self.assertTrue(blivet.udev.util.run_program.called)
Filesystems mounted under /tmp now have type unlabeled_t unless their context is reset after mounting. --- tests/formats_test/selinux_test.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tests/formats_test/selinux_test.py b/tests/formats_test/selinux_test.py index 2b6d9d9..00771ad 100755 --- a/tests/formats_test/selinux_test.py +++ b/tests/formats_test/selinux_test.py @@ -33,10 +33,10 @@ class SELinuxContextTestCase(loopbackedtestcase.LoopBackedTestCase): an_fs.unmount() os.rmdir(mountpoint)
- self.assertEqual(root_selinux_context[1], 'system_u:object_r:file_t:s0') + self.assertEqual(root_selinux_context[1], 'system_u:object_r:unlabeled_t:s0')
self.assertEqual(lost_and_found_selinux_context[1], - 'system_u:object_r:file_t:s0') + 'system_u:object_r:unlabeled_t:s0')
blivet.flags.installer_mode = True mountpoint = tempfile.mkdtemp("test.selinux") @@ -73,7 +73,7 @@ class SELinuxContextTestCase(loopbackedtestcase.LoopBackedTestCase): an_fs.unmount() os.rmdir(mountpoint)
- self.assertEqual(root_selinux_context[1], 'system_u:object_r:file_t:s0') + self.assertEqual(root_selinux_context[1], 'system_u:object_r:unlabeled_t:s0')
blivet.flags.installer_mode = True mountpoint = tempfile.mkdtemp("test.selinux")
On Thu, Jul 31, 2014 at 05:16:18PM -0500, David Lehman wrote:
Prompted by jenkins, I ran blivet's unit tests as root in a vm and here is what I had to do to make it run, aside from applying my recent pyparted patch to the code in python's site-lib.
Patch 2 is old code that I've wanted to remove for some time now, which I found was getting triggered erroneously when manipulating a container's member set as part of the action tests.
David Lehman (4): Bypass size getter when mocking new devices. Remove unused lvm and md activation code. Clean up mocking done by udev tests when finished. Update selinux tests for default context of mounts under /tmp.
blivet/devices.py | 20 -------------------- tests/formats_test/selinux_test.py | 6 +++--- tests/storagetestcase.py | 2 +- tests/udev_test.py | 12 ++++++++++-- 4 files changed, 14 insertions(+), 26 deletions(-)
-- 1.9.3
ACK
----- Original Message -----
From: "Brian C. Lane" bcl@redhat.com To: anaconda-patches@lists.fedorahosted.org Sent: Friday, August 1, 2014 2:20:54 AM Subject: Re: [blivet] unit test updates
On Thu, Jul 31, 2014 at 05:16:18PM -0500, David Lehman wrote:
Prompted by jenkins, I ran blivet's unit tests as root in a vm and here is what I had to do to make it run, aside from applying my recent pyparted patch to the code in python's site-lib.
Patch 2 is old code that I've wanted to remove for some time now, which I found was getting triggered erroneously when manipulating a container's member set as part of the action tests.
David Lehman (4): Bypass size getter when mocking new devices. Remove unused lvm and md activation code. Clean up mocking done by udev tests when finished. Update selinux tests for default context of mounts under /tmp.
blivet/devices.py | 20 -------------------- tests/formats_test/selinux_test.py | 6 +++--- tests/storagetestcase.py | 2 +- tests/udev_test.py | 12 ++++++++++-- 4 files changed, 14 insertions(+), 26 deletions(-)
-- 1.9.3
ACK
-- Brian C. Lane | Anaconda Team | IRC: bcl #anaconda | Port Orchard, WA (PST8PDT) _______________________________________________ anaconda-patches mailing list anaconda-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/anaconda-patches
These seem fine to me.
Note that with the change, we lose the only use of mdnominate within the blivet code base. IMHO, tt's a toss-up whether the definition of mdnominate should be removed or not, but I thought I'ld mention it.
- mulhern
anaconda-patches@lists.fedorahosted.org