def get_arguments_test(self): """Test GetArguments.""" with self.assertRaises(UnavailableStorageError): self.bootloader_interface.GetArguments() storage = Mock() self.bootloader_module.on_storage_reset(storage) storage.bootloader = GRUB2() storage.bootloader.boot_args.update(["x=1", "y=2"]) self.assertEqual(self.bootloader_interface.GetArguments(), ["x=1", "y=2"])
def is_efi_test(self): """Test IsEFI.""" with self.assertRaises(UnavailableStorageError): self.bootloader_interface.IsEFI() storage = Mock() self.bootloader_module.on_storage_changed(storage) storage.bootloader = GRUB2() self.assertEqual(self.bootloader_interface.IsEFI(), False) storage.bootloader = EFIGRUB() self.assertEqual(self.bootloader_interface.IsEFI(), True)
def collect_requirements_test(self): """Test CollectRequirements.""" storage = Mock() storage.bootloader = GRUB2() storage.packages = ["lvm2"] self.storage_module.set_storage(storage) self.assertEqual(self.storage_interface.CollectRequirements(), [{ "type": get_variant(Str, "package"), "name": get_variant(Str, "lvm2"), "reason": get_variant(Str, "storage") }, { "type": get_variant(Str, "package"), "name": get_variant(Str, "grub2"), "reason": get_variant(Str, "bootloader") }, { "type": get_variant(Str, "package"), "name": get_variant(Str, "grub2-tools"), "reason": get_variant(Str, "bootloader") }])
def setUp(self): """Create some device objects to test with. This sets up two disks (sda, sdb). The first partition of each is a biosboot partition. The second partitions comprise a RAID1 array formatted as /boot. sda additionally contains a third partition formatted as ext4. """ super(GRUBRaidSimpleTest, self).setUp() # Make some disks self.sda = DiskDevice(name="sda", size=Size("100 GiB")) self.sda.format = get_format("disklabel") self.sdb = DiskDevice(name="sdb", size=Size("100 GiB")) self.sdb.format = get_format("disklabel") # Set up biosboot partitions, an mdarray for /boot, and a btrfs array on sda + sdb. # Start with the partitions self.sda1 = PartitionDevice(name="sda1", parents=[self.sda], size=Size("1 MiB")) self.sda1.format = get_format("biosboot") self.sda2 = PartitionDevice(name="sda2", parents=[self.sda], size=Size("500 MiB")) self.sda2.format = get_format("mdmember") self.sda4 = PartitionDevice(name="sda4", parents=[self.sda], size=Size("500 MiB")) self.sda4.format = get_format("btrfs") self.sdb1 = PartitionDevice(name="sdb1", parents=[self.sdb], size=Size("1 MiB")) self.sdb1.format = get_format("biosboot") self.sdb2 = PartitionDevice(name="sdb2", parents=[self.sdb], size=Size("500 MiB")) self.sdb2.format = get_format("mdmember") self.sdb4 = PartitionDevice(name="sdb4", parents=[self.sdb], size=Size("4 GiB")) self.sdb4.format = get_format("btrfs") # Add an extra partition for /boot on not-RAID self.sda3 = PartitionDevice(name="sda3", parents=[self.sda], size=Size("500 MiB")) self.sda3.format = get_format("ext4", mountpoint="/boot") # Pretend that the partitions are real with real parent disks for part in (self.sda1, self.sda2, self.sda3, self.sda4, self.sdb1, self.sdb2, self.sdb4): part.parents = part.req_disks self.boot_md = MDRaidArrayDevice(name="md1", size=Size("500 MiB"), parents=[self.sda2, self.sdb2], level=1, member_devices=2, total_devices=2) self.boot_md.format = get_format("ext4", mountpoint="/boot") # Set up the btrfs raid1 volume with a subvolume for /boot self.btrfs_volume = BTRFSVolumeDevice(parents=[self.sda4, self.sdb4], data_level=RAID1) self.btrfs_volume.format = get_format("btrfs") self.boot_btrfs = BTRFSSubVolumeDevice(parents=[self.btrfs_volume]) self.boot_btrfs.format = get_format("btrfs", mountpoint="/boot") self.grub = GRUB2()