def test_fw_raid_migrating(self): """Verify that md_examine works when array is migrating ("foo <-- bar" values in output) """ with fake_utils("tests/mdadm_fw_RAID_examine_migrate"): ex_data = BlockDev.md_examine("fake_dev") self.assertEqual(ex_data.chunk_size, 128 * 1024)
def test_fw_raid_examine(self): """Verify that md_examine works as expected on FW RAID data""" with fake_utils("tests/mdadm_fw_raid_examine"): ex_data = BlockDev.md_examine("fake_dev") self.assertEqual(ex_data.device, "/dev/md/Volume0")
def test_no_metadata_examine(self): """Verify that md_examine works as expected with no metadata spec""" # shouldn't raise any exception with fake_utils("tests/mdadm_no_metadata_examine"): ex_data = BlockDev.md_examine("fake_dev") self.assertIs(ex_data.metadata, None)
def test_f2fs_fsck_too_low(self): BlockDev.switch_init_checks(False) BlockDev.reinit(self.requested_plugins, True, None) # now try fake "low version of f2fs with utils.fake_utils("tests/fake_utils/fsck_f2fs_low_version/"): with six.assertRaisesRegex(self, GLib.GError, "Too low version of fsck.f2fs. At least 1.11.0 required."): BlockDev.fs_is_tech_avail(BlockDev.FSTech.F2FS, BlockDev.FSTechMode.CHECK)
def test_mdadm_name_extra_info(self): """Verify that md_examine and md_detail work with extra MD RAID name info""" with fake_utils("tests/mdadm_extra_name_stuff"): ex_data = BlockDev.md_examine("fake_dev") detail_data = BlockDev.md_detail("fake_dev") self.assertEqual(ex_data.name, "localhost:fedora") self.assertEqual(detail_data.name, "localhost:fedora")
def test_fw_raid_uppercase_examine(self): """Verify that md_examine works with output using "RAID" instead of "Raid" and other quirks """ with fake_utils("tests/mdadm_fw_RAID_examine"): ex_data = BlockDev.md_examine("fake_dev") self.assertEqual(ex_data.level, "container") self.assertEqual(ex_data.num_devices, 1) self.assertEqual(ex_data.uuid, "b42756a2-37e4-3e47-674b-d1dd6e822145") self.assertEqual(ex_data.device, None)
def test_list_subvols_weird_docker_data(self): """Verify that list_subvolumes works as expected on weird data from one Docker use case""" with fake_utils("tests/btrfs_subvols_docker"): subvols = BlockDev.btrfs_list_subvolumes("fake_dev", False) # make sure subvolumes are sorted properly (parents before children) seen = set() for subvol in subvols: seen.add(subvol) self.assertTrue(subvol.parent_id == BlockDev.BTRFS_MAIN_VOLUME_ID or any(subvol.parent_id == other.id for other in seen)) # check that one of the weird subvols is in the list of subvolumes self.assertTrue(any(subvol for subvol in subvols if subvol.path == "docker/btrfs/subvolumes/f2062b736fbabbe4da752632ac4deae87fcb916add6d7d8f5cecee4cbdc41fd9"))
def test_check_new_version_format(self): """Verify that checking the minimum BTRFS version works as expected with the new format""" # unload all plugins first self.assertTrue(BlockDev.reinit([], True, None)) # check that new version format is correctly parsed with fake_utils("tests/btrfs_new_version_format/"): BlockDev.reinit(self.requested_plugins, True, None) self.assertIn("btrfs", BlockDev.get_available_plugin_names()) BlockDev.reinit(self.requested_plugins, True, None) self.assertIn("btrfs", BlockDev.get_available_plugin_names())
def test_check_new_version_format(self): """Verify that checking the minimum BTRFS version works as expected with the new format""" # unload all plugins first self.assertTrue(BlockDev.reinit([], True, None)) # check that new version format is correctly parsed with fake_utils("tests/btrfs_new_version_format/"): BlockDev.reinit(None, True, None) self.assertIn("btrfs", BlockDev.get_available_plugin_names()) BlockDev.reinit(None, True, None) self.assertIn("btrfs", BlockDev.get_available_plugin_names())
def test_check_low_version(self): """Verify that checking the minimum swap utils versions works as expected""" # unload all plugins first self.assertTrue(BlockDev.reinit([], True, None)) with fake_utils("tests/swap_low_version/"): # too low version of mkswap available, the swap plugin should fail to load with self.assertRaises(GLib.GError): BlockDev.reinit(self.requested_plugins, True, None) self.assertNotIn("swap", BlockDev.get_available_plugin_names()) # load the plugins back self.assertTrue(BlockDev.reinit(self.requested_plugins, True, None)) self.assertIn("swap", BlockDev.get_available_plugin_names())
def test_check_low_version(self): """Verify that checking the minimum dmsetup version works as expected""" # unload all plugins first self.assertTrue(BlockDev.reinit([], True, None)) with fake_utils("tests/dm_low_version/"): # too low version of dmsetup available, the DM plugin should fail to load with self.assertRaises(GLib.GError): BlockDev.reinit(None, True, None) self.assertNotIn("dm", BlockDev.get_available_plugin_names()) # load the plugins back self.assertTrue(BlockDev.reinit(None, True, None)) self.assertIn("dm", BlockDev.get_available_plugin_names())
def test_check_low_version(self): """Verify that checking the minimum BTRFS version works as expected""" # unload all plugins first self.assertTrue(BlockDev.reinit([], True, None)) with fake_utils("tests/btrfs_low_version/"): # too low version of BTRFS available, the BTRFS plugin should fail to load with self.assertRaises(GLib.GError): BlockDev.reinit(None, True, None) self.assertNotIn("btrfs", BlockDev.get_available_plugin_names()) # load the plugins back self.assertTrue(BlockDev.reinit(None, True, None)) self.assertIn("btrfs", BlockDev.get_available_plugin_names())
def test_check_low_version(self): """Verify that checking the minimum dmsetup version works as expected""" # unload all plugins first self.assertTrue(BlockDev.reinit([], True, None)) with fake_utils("tests/fake_utils/mpath_low_version/"): # too low version of the multipath tool available, the mpath plugin # should fail to load with self.assertRaises(GLib.GError): BlockDev.reinit(self.requested_plugins, True, None) self.assertNotIn("mpath", BlockDev.get_available_plugin_names()) # load the plugins back self.assertTrue(BlockDev.reinit(self.requested_plugins, True, None)) self.assertIn("mpath", BlockDev.get_available_plugin_names())
def test_util_version(self): """Verify that checking utility availability works as expected""" with self.assertRaises(GLib.GError): BlockDev.utils_check_util_version("libblockdev-fake-util", None, None, None) with fake_utils("tests/utils_fake_util/"): with self.assertRaises(GLib.GError): # with no argument, the output is "Version: 1.2" which is not a # valid version without regexp BlockDev.utils_check_util_version("libblockdev-fake-util", "1.3", "", None) with self.assertRaises(GLib.GError): # libblockdev-fake-util with no arguments reports 1.2 which is too low BlockDev.utils_check_util_version("libblockdev-fake-util", "1.3", "", "Version:\\s(.*)") # just what we require self.assertTrue(BlockDev.utils_check_util_version("libblockdev-fake-util", "1.2", "", "Version:\\s(.*)")) with self.assertRaises(GLib.GError): # libblockdev-fake-util with "version" reports 1.1 which is too low BlockDev.utils_check_util_version("libblockdev-fake-util", "1.2", "version", "Version:\\s(.*)") # just what we require self.assertTrue(BlockDev.utils_check_util_version("libblockdev-fake-util", "1.1", "version", "Version:\\s(.*)")) with self.assertRaises(GLib.GError): # libblockdev-fake-util with "--version" reports 1.0 which is too low BlockDev.utils_check_util_version("libblockdev-fake-util", "1.1", "--version", None) # just what we require self.assertTrue(BlockDev.utils_check_util_version("libblockdev-fake-util", "1.0", "--version", None)) # lower required version self.assertTrue(BlockDev.utils_check_util_version("libblockdev-fake-util", "0.9", "--version", None)) # version on stderr self.assertTrue(BlockDev.utils_check_util_version("libblockdev-fake-util-stderr", "1.1", "version", "Version:\\s(.*)")) # exit code != 0 self.assertTrue(BlockDev.utils_check_util_version("libblockdev-fake-util-stderr", "1.1", "version", "Version:\\s(.*)"))
def test_util_version(self): """Verify that checking utility availability works as expected""" with self.assertRaises(GLib.GError): BlockDev.utils_check_util_version("libblockdev-fake-util", None, None, None) with fake_utils("tests/fake_utils/utils_fake_util/"): with self.assertRaises(GLib.GError): # with no argument, the output is "Version: 1.2" which is not a # valid version without regexp BlockDev.utils_check_util_version("libblockdev-fake-util", "1.3", "", None) with self.assertRaises(GLib.GError): # libblockdev-fake-util with no arguments reports 1.2 which is too low BlockDev.utils_check_util_version("libblockdev-fake-util", "1.3", "", "Version:\\s(.*)") # just what we require self.assertTrue(BlockDev.utils_check_util_version("libblockdev-fake-util", "1.2", "", "Version:\\s(.*)")) with self.assertRaises(GLib.GError): # libblockdev-fake-util with "version" reports 1.1 which is too low BlockDev.utils_check_util_version("libblockdev-fake-util", "1.2", "version", "Version:\\s(.*)") # just what we require self.assertTrue(BlockDev.utils_check_util_version("libblockdev-fake-util", "1.1", "version", "Version:\\s(.*)")) with self.assertRaises(GLib.GError): # libblockdev-fake-util with "--version" reports 1.0 which is too low BlockDev.utils_check_util_version("libblockdev-fake-util", "1.1", "--version", None) # just what we require self.assertTrue(BlockDev.utils_check_util_version("libblockdev-fake-util", "1.0", "--version", None)) # lower required version self.assertTrue(BlockDev.utils_check_util_version("libblockdev-fake-util", "0.9", "--version", None)) # version on stderr self.assertTrue(BlockDev.utils_check_util_version("libblockdev-fake-util-stderr", "1.1", "version", "Version:\\s(.*)")) # exit code != 0 self.assertTrue(BlockDev.utils_check_util_version("libblockdev-fake-util-fail", "1.1", "version", "Version:\\s(.*)"))