From 49271e614b43262c53148957a3f9ddbc7acf18dc Mon Sep 17 00:00:00 2001 From: Achilleas Koutsou Date: Tue, 3 Dec 2024 19:54:55 +0100 Subject: [PATCH] blueprint: test the conversion --- internal/blueprint/blueprint_convert_test.go | 212 +++++++++++++++++++ 1 file changed, 212 insertions(+) diff --git a/internal/blueprint/blueprint_convert_test.go b/internal/blueprint/blueprint_convert_test.go index 88c49d667..520e18271 100644 --- a/internal/blueprint/blueprint_convert_test.go +++ b/internal/blueprint/blueprint_convert_test.go @@ -112,6 +112,112 @@ func TestConvert(t *testing.T) { MinSize: 1024, }, }, + Disk: &DiskCustomization{ + MinSize: 10240, + Partitions: []PartitionCustomization{ + { + // this partition is invalid, since only one of + // btrfs, vg, or filesystem should be set, but + // the converter copies everything + // unconditionally, so let's test the full + // thing + Type: "plain", + MinSize: 1024, + BtrfsVolumeCustomization: BtrfsVolumeCustomization{ + Subvolumes: []BtrfsSubvolumeCustomization{ + { + Name: "subvol1", + Mountpoint: "/subvol1", + }, + { + Name: "subvol2", + Mountpoint: "/subvol2", + }, + }, + }, + VGCustomization: VGCustomization{ + Name: "vg1", + LogicalVolumes: []LVCustomization{ + { + Name: "vg1lv1", + MinSize: 0, + FilesystemTypedCustomization: FilesystemTypedCustomization{ + Mountpoint: "/one", + Label: "one", + FSType: "xfs", + }, + }, + { + Name: "vg1lv2", + MinSize: 0, + FilesystemTypedCustomization: FilesystemTypedCustomization{ + Mountpoint: "/two", + Label: "two", + FSType: "ext4", + }, + }, + }, + }, + FilesystemTypedCustomization: FilesystemTypedCustomization{ + Mountpoint: "/root", + Label: "roothome", + FSType: "xfs", + }, + }, + { + Type: "plain", + MinSize: 1024, + FilesystemTypedCustomization: FilesystemTypedCustomization{ + Mountpoint: "/root", + Label: "roothome", + FSType: "xfs", + }, + }, + { + Type: "lvm", + MinSize: 1024, + VGCustomization: VGCustomization{ + Name: "vg1", + LogicalVolumes: []LVCustomization{ + { + Name: "vg1lv1", + MinSize: 0, + FilesystemTypedCustomization: FilesystemTypedCustomization{ + Mountpoint: "/one", + Label: "one", + FSType: "xfs", + }, + }, + { + Name: "vg1lv2", + MinSize: 0, + FilesystemTypedCustomization: FilesystemTypedCustomization{ + Mountpoint: "/two", + Label: "two", + FSType: "ext4", + }, + }, + }, + }, + }, + { + Type: "btrfs", + MinSize: 1024, + BtrfsVolumeCustomization: BtrfsVolumeCustomization{ + Subvolumes: []BtrfsSubvolumeCustomization{ + { + Name: "subvol1", + Mountpoint: "/subvol1", + }, + { + Name: "subvol2", + Mountpoint: "/subvol2", + }, + }, + }, + }, + }, + }, InstallationDevice: "/dev/sda", FDO: &FDOCustomization{ ManufacturingServerURL: "http://manufacturing.fdo", @@ -305,6 +411,112 @@ func TestConvert(t *testing.T) { MinSize: 1024, }, }, + Disk: &iblueprint.DiskCustomization{ + MinSize: 10240, + Partitions: []iblueprint.PartitionCustomization{ + { + // this partition is invalid, since only one of + // btrfs, vg, or filesystem should be set, but + // the converter copies everything + // unconditionally, so let's test the full + // thing + Type: "plain", + MinSize: 1024, + BtrfsVolumeCustomization: iblueprint.BtrfsVolumeCustomization{ + Subvolumes: []iblueprint.BtrfsSubvolumeCustomization{ + { + Name: "subvol1", + Mountpoint: "/subvol1", + }, + { + Name: "subvol2", + Mountpoint: "/subvol2", + }, + }, + }, + VGCustomization: iblueprint.VGCustomization{ + Name: "vg1", + LogicalVolumes: []iblueprint.LVCustomization{ + { + Name: "vg1lv1", + MinSize: 0, + FilesystemTypedCustomization: iblueprint.FilesystemTypedCustomization{ + Mountpoint: "/one", + Label: "one", + FSType: "xfs", + }, + }, + { + Name: "vg1lv2", + MinSize: 0, + FilesystemTypedCustomization: iblueprint.FilesystemTypedCustomization{ + Mountpoint: "/two", + Label: "two", + FSType: "ext4", + }, + }, + }, + }, + FilesystemTypedCustomization: iblueprint.FilesystemTypedCustomization{ + Mountpoint: "/root", + Label: "roothome", + FSType: "xfs", + }, + }, + { + Type: "plain", + MinSize: 1024, + FilesystemTypedCustomization: iblueprint.FilesystemTypedCustomization{ + Mountpoint: "/root", + Label: "roothome", + FSType: "xfs", + }, + }, + { + Type: "lvm", + MinSize: 1024, + VGCustomization: iblueprint.VGCustomization{ + Name: "vg1", + LogicalVolumes: []iblueprint.LVCustomization{ + { + Name: "vg1lv1", + MinSize: 0, + FilesystemTypedCustomization: iblueprint.FilesystemTypedCustomization{ + Mountpoint: "/one", + Label: "one", + FSType: "xfs", + }, + }, + { + Name: "vg1lv2", + MinSize: 0, + FilesystemTypedCustomization: iblueprint.FilesystemTypedCustomization{ + Mountpoint: "/two", + Label: "two", + FSType: "ext4", + }, + }, + }, + }, + }, + { + Type: "btrfs", + MinSize: 1024, + BtrfsVolumeCustomization: iblueprint.BtrfsVolumeCustomization{ + Subvolumes: []iblueprint.BtrfsSubvolumeCustomization{ + { + Name: "subvol1", + Mountpoint: "/subvol1", + }, + { + Name: "subvol2", + Mountpoint: "/subvol2", + }, + }, + }, + }, + }, + }, InstallationDevice: "/dev/sda", FDO: &iblueprint.FDOCustomization{ ManufacturingServerURL: "http://manufacturing.fdo",