From c495f74951caa0104636032e00704a83ab5f73b1 Mon Sep 17 00:00:00 2001 From: Vojtech Trefny Date: Tue, 26 Mar 2019 12:58:53 +0100 Subject: [PATCH 1/3] Properly clean after availability test case We need to set availability of the 'mkfs.hfsplus' utility back to it's real value after changing it to "always available" for this test case. --- tests/devices_test/dependencies_test.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/devices_test/dependencies_test.py b/tests/devices_test/dependencies_test.py index 9dbdd24d..76bf758b 100644 --- a/tests/devices_test/dependencies_test.py +++ b/tests/devices_test/dependencies_test.py @@ -69,6 +69,7 @@ class MockingDeviceDependenciesTestCase1(unittest.TestCase): self.mdraid_method = availability.BLOCKDEV_MDRAID_PLUGIN._method self.dm_method = availability.BLOCKDEV_DM_PLUGIN._method + self.hfsplus_method = availability.MKFS_HFSPLUS_APP._method self.cache_availability = availability.CACHE_AVAILABILITY self.addCleanup(self._clean_up) @@ -105,10 +106,12 @@ class MockingDeviceDependenciesTestCase1(unittest.TestCase): def _clean_up(self): availability.BLOCKDEV_MDRAID_PLUGIN._method = self.mdraid_method availability.BLOCKDEV_DM_PLUGIN._method = self.dm_method + availability.MKFS_HFSPLUS_APP._method = self.hfsplus_method availability.CACHE_AVAILABILITY = False availability.BLOCKDEV_MDRAID_PLUGIN.available # pylint: disable=pointless-statement availability.BLOCKDEV_DM_PLUGIN.available # pylint: disable=pointless-statement + availability.MKFS_HFSPLUS_APP.available # pylint: disable=pointless-statement availability.CACHE_AVAILABILITY = self.cache_availability -- 2.20.1 From a6798882f5ba5b1e0ea655255d6f1fd5eda85f64 Mon Sep 17 00:00:00 2001 From: Vojtech Trefny Date: Tue, 26 Mar 2019 13:00:40 +0100 Subject: [PATCH 2/3] Skip weak dependencies test if we don't have all libblockdev plugins This test checks that creating devices works when we have all plugins and fails "nicely" if we don't have all plugins so we actually need all the plugins for this test case. --- tests/devices_test/dependencies_test.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/devices_test/dependencies_test.py b/tests/devices_test/dependencies_test.py index 76bf758b..308d6192 100644 --- a/tests/devices_test/dependencies_test.py +++ b/tests/devices_test/dependencies_test.py @@ -157,6 +157,11 @@ class MissingWeakDependenciesTestCase(unittest.TestCase): self.disk1_file = create_sparse_tempfile("disk1", Size("2GiB")) self.plugins = blockdev.plugin_specs_from_names(blockdev.get_available_plugin_names()) + loaded_plugins = self.load_all_plugins() + if not all(p in loaded_plugins for p in ("btrfs", "crypto", "lvm", "md")): + # we don't have all plugins needed for this test case + self.skipTest("Missing libblockdev plugins needed from weak dependencies test.") + def _clean_up(self): # reload all libblockdev plugins self.load_all_plugins() -- 2.20.1 From 151fce2c9a98dc5a7943b314828518518a755ec8 Mon Sep 17 00:00:00 2001 From: Vojtech Trefny Date: Tue, 26 Mar 2019 13:36:31 +0100 Subject: [PATCH 3/3] Check for format tools availability in action_test --- tests/action_test.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/action_test.py b/tests/action_test.py index 93ed9e57..101d5a21 100644 --- a/tests/action_test.py +++ b/tests/action_test.py @@ -19,6 +19,13 @@ from blivet.devices import MDRaidArrayDevice from blivet.devices import LVMVolumeGroupDevice from blivet.devices import LVMLogicalVolumeDevice +# format classes +from blivet.formats.fs import Ext2FS +from blivet.formats.fs import Ext3FS +from blivet.formats.fs import Ext4FS +from blivet.formats.fs import FATFS +from blivet.formats.fs import XFS + # action classes from blivet.deviceaction import ActionCreateDevice from blivet.deviceaction import ActionResizeDevice @@ -39,8 +46,17 @@ DEVICE_CLASSES = [ LVMLogicalVolumeDevice ] +FORMAT_CLASSES = [ + Ext2FS, + Ext3FS, + Ext4FS, + FATFS, + XFS +] + @unittest.skipUnless(not any(x.unavailable_type_dependencies() for x in DEVICE_CLASSES), "some unsupported device classes required for this test") +@unittest.skipUnless(not any(x().utils_available for x in FORMAT_CLASSES), "some unsupported format classes required for this test") class DeviceActionTestCase(StorageTestCase): """ DeviceActionTestSuite """ -- 2.20.1