disk: use GenerateUUIDs in CreatePartitionTable

Instead of generating the UUIDs directly when new partitions are
created and separately for the boot and root partition, use the
new `PartitionTable.GenerateUUIDs` method to generate all UUIDs
that are missing in one go. Since this changes the order in
which the uuids are generated the test manifests UUIDs changed
and needed to be updated:
I used to following patch to get the updated manifests:

--- a/internal/distro/distro_test_common/distro_test_common.go
+++ b/internal/distro/distro_test_common/distro_test_common.go
@@ -105,6 +105,12 @@ func TestDistro_Manifest(t *testing.T, pipelinePath string, prefix string, regis
                                require.NoError(t, err)

                                diff := cmp.Diff(expected, actual)
+                               if diff != "" {
+                                       tt.Manifest = got
+                                       data, _ := json.MarshalIndent(tt, "", "  ")
+                                       path := filepath.Join("/tmp", filepath.Base(fileName))
+                                       _ = ioutil.WriteFile(path, data, 0644)
+                               }
                                require.Emptyf(t, diff, "Distro: %s\nArch: %s\nImage type: %s\nTest case file: %s\n", d.Name(), arch.Name(), imageType.Name(), fileName)
                        }
                })

And the following fish snippet to update the existing ones, using the
jq and sponge utilities:

for file in /tmp/rhel_85-*.json
  set filename (basename $file)
  jq -s '.[0].manifest = .[1].manifest | .[0]' test/data/manifests/$filename /tmp/$filename | sponge test/data/manifests/$filename
end
This commit is contained in:
Christian Kellner 2021-11-15 21:42:07 +01:00 committed by Tom Gundersen
parent 58112e7152
commit d9ef268809
5 changed files with 33 additions and 39 deletions

View file

@ -1334,13 +1334,13 @@
"options": {
"filesystems": [
{
"uuid": "e2d3d0d0-de6b-48f9-b44c-e85ff044c6b1",
"uuid": "0194fdc2-fa2f-4cc0-81d3-ff12045b73c8",
"vfs_type": "xfs",
"path": "/",
"options": "defaults"
},
{
"uuid": "0194fdc2-fa2f-4cc0-81d3-ff12045b73c8",
"uuid": "6e4ff95f-f662-45ee-a82a-bdf44a2d0b75",
"vfs_type": "xfs",
"path": "/usr",
"options": "defaults"
@ -1364,7 +1364,7 @@
{
"type": "org.osbuild.grub2",
"options": {
"root_fs_uuid": "e2d3d0d0-de6b-48f9-b44c-e85ff044c6b1",
"root_fs_uuid": "0194fdc2-fa2f-4cc0-81d3-ff12045b73c8",
"kernel_opts": "console=tty0 console=ttyS0,115200n8 no_timer_check net.ifnames=0 crashkernel=auto debug",
"uefi": {
"vendor": "redhat"
@ -1413,13 +1413,13 @@
"size": 4194304,
"start": 206848,
"type": "0FC63DAF-8483-4772-8E79-3D69D8477DE4",
"uuid": "6e4ff95f-f662-45ee-a82a-bdf44a2d0b75"
"uuid": "a178892e-e285-4ce1-9114-55780875d64e"
},
{
"size": 2097152,
"start": 4401152,
"type": "0FC63DAF-8483-4772-8E79-3D69D8477DE4",
"uuid": "a178892e-e285-4ce1-9114-55780875d64e"
"uuid": "e2d3d0d0-de6b-48f9-b44c-e85ff044c6b1"
}
]
},
@ -1451,7 +1451,7 @@
{
"type": "org.osbuild.mkfs.xfs",
"options": {
"uuid": "e2d3d0d0-de6b-48f9-b44c-e85ff044c6b1",
"uuid": "0194fdc2-fa2f-4cc0-81d3-ff12045b73c8",
"label": "root"
},
"devices": {
@ -1468,7 +1468,7 @@
{
"type": "org.osbuild.mkfs.xfs",
"options": {
"uuid": "0194fdc2-fa2f-4cc0-81d3-ff12045b73c8"
"uuid": "6e4ff95f-f662-45ee-a82a-bdf44a2d0b75"
},
"devices": {
"device": {

View file

@ -1441,19 +1441,19 @@
"options": {
"filesystems": [
{
"uuid": "fb180daf-48a7-4ee0-b10d-394651850fd4",
"uuid": "0194fdc2-fa2f-4cc0-81d3-ff12045b73c8",
"vfs_type": "xfs",
"path": "/",
"options": "defaults"
},
{
"uuid": "0194fdc2-fa2f-4cc0-81d3-ff12045b73c8",
"uuid": "6e4ff95f-f662-45ee-a82a-bdf44a2d0b75",
"vfs_type": "xfs",
"path": "/usr",
"options": "defaults"
},
{
"uuid": "6e4ff95f-f662-45ee-a82a-bdf44a2d0b75",
"uuid": "fb180daf-48a7-4ee0-b10d-394651850fd4",
"vfs_type": "xfs",
"path": "/var",
"options": "defaults"
@ -1464,7 +1464,7 @@
{
"type": "org.osbuild.grub2",
"options": {
"root_fs_uuid": "fb180daf-48a7-4ee0-b10d-394651850fd4",
"root_fs_uuid": "0194fdc2-fa2f-4cc0-81d3-ff12045b73c8",
"kernel_opts": "console=tty0 console=ttyS0,115200n8 no_timer_check net.ifnames=0 crashkernel=auto debug",
"legacy": "powerpc-ieee1275",
"saved_entry": "ffffffffffffffffffffffffffffffff-4.18.0-299.1.el8.ppc64le"
@ -1527,7 +1527,7 @@
{
"type": "org.osbuild.mkfs.xfs",
"options": {
"uuid": "fb180daf-48a7-4ee0-b10d-394651850fd4"
"uuid": "0194fdc2-fa2f-4cc0-81d3-ff12045b73c8"
},
"devices": {
"device": {
@ -1543,7 +1543,7 @@
{
"type": "org.osbuild.mkfs.xfs",
"options": {
"uuid": "0194fdc2-fa2f-4cc0-81d3-ff12045b73c8"
"uuid": "6e4ff95f-f662-45ee-a82a-bdf44a2d0b75"
},
"devices": {
"device": {
@ -1559,7 +1559,7 @@
{
"type": "org.osbuild.mkfs.xfs",
"options": {
"uuid": "6e4ff95f-f662-45ee-a82a-bdf44a2d0b75"
"uuid": "fb180daf-48a7-4ee0-b10d-394651850fd4"
},
"devices": {
"device": {

View file

@ -450,7 +450,7 @@
{
"type": "org.osbuild.kernel-cmdline",
"options": {
"root_fs_uuid": "fb180daf-48a7-4ee0-b10d-394651850fd4",
"root_fs_uuid": "0194fdc2-fa2f-4cc0-81d3-ff12045b73c8",
"kernel_opts": "console=tty0 console=ttyS0,115200n8 no_timer_check net.ifnames=0 crashkernel=auto"
}
},
@ -1464,19 +1464,19 @@
"options": {
"filesystems": [
{
"uuid": "fb180daf-48a7-4ee0-b10d-394651850fd4",
"uuid": "0194fdc2-fa2f-4cc0-81d3-ff12045b73c8",
"vfs_type": "xfs",
"path": "/",
"options": "defaults"
},
{
"uuid": "0194fdc2-fa2f-4cc0-81d3-ff12045b73c8",
"uuid": "6e4ff95f-f662-45ee-a82a-bdf44a2d0b75",
"vfs_type": "xfs",
"path": "/usr",
"options": "defaults"
},
{
"uuid": "6e4ff95f-f662-45ee-a82a-bdf44a2d0b75",
"uuid": "fb180daf-48a7-4ee0-b10d-394651850fd4",
"vfs_type": "xfs",
"path": "/var",
"options": "defaults"
@ -1540,7 +1540,7 @@
{
"type": "org.osbuild.mkfs.xfs",
"options": {
"uuid": "fb180daf-48a7-4ee0-b10d-394651850fd4"
"uuid": "0194fdc2-fa2f-4cc0-81d3-ff12045b73c8"
},
"devices": {
"device": {
@ -1556,7 +1556,7 @@
{
"type": "org.osbuild.mkfs.xfs",
"options": {
"uuid": "0194fdc2-fa2f-4cc0-81d3-ff12045b73c8"
"uuid": "6e4ff95f-f662-45ee-a82a-bdf44a2d0b75"
},
"devices": {
"device": {
@ -1572,7 +1572,7 @@
{
"type": "org.osbuild.mkfs.xfs",
"options": {
"uuid": "6e4ff95f-f662-45ee-a82a-bdf44a2d0b75"
"uuid": "fb180daf-48a7-4ee0-b10d-394651850fd4"
},
"devices": {
"device": {

View file

@ -1350,13 +1350,13 @@
"options": {
"filesystems": [
{
"uuid": "e2d3d0d0-de6b-48f9-b44c-e85ff044c6b1",
"uuid": "0194fdc2-fa2f-4cc0-81d3-ff12045b73c8",
"vfs_type": "xfs",
"path": "/",
"options": "defaults"
},
{
"uuid": "0194fdc2-fa2f-4cc0-81d3-ff12045b73c8",
"uuid": "6e4ff95f-f662-45ee-a82a-bdf44a2d0b75",
"vfs_type": "xfs",
"path": "/usr",
"options": "defaults"
@ -1380,7 +1380,7 @@
{
"type": "org.osbuild.grub2",
"options": {
"root_fs_uuid": "e2d3d0d0-de6b-48f9-b44c-e85ff044c6b1",
"root_fs_uuid": "0194fdc2-fa2f-4cc0-81d3-ff12045b73c8",
"kernel_opts": "console=tty0 console=ttyS0,115200n8 no_timer_check net.ifnames=0 crashkernel=auto debug",
"legacy": "i386-pc",
"uefi": {
@ -1437,13 +1437,13 @@
"size": 4194304,
"start": 208896,
"type": "0FC63DAF-8483-4772-8E79-3D69D8477DE4",
"uuid": "6e4ff95f-f662-45ee-a82a-bdf44a2d0b75"
"uuid": "a178892e-e285-4ce1-9114-55780875d64e"
},
{
"size": 2097152,
"start": 4403200,
"type": "0FC63DAF-8483-4772-8E79-3D69D8477DE4",
"uuid": "a178892e-e285-4ce1-9114-55780875d64e"
"uuid": "e2d3d0d0-de6b-48f9-b44c-e85ff044c6b1"
}
]
},
@ -1475,7 +1475,7 @@
{
"type": "org.osbuild.mkfs.xfs",
"options": {
"uuid": "e2d3d0d0-de6b-48f9-b44c-e85ff044c6b1",
"uuid": "0194fdc2-fa2f-4cc0-81d3-ff12045b73c8",
"label": "root"
},
"devices": {
@ -1492,7 +1492,7 @@
{
"type": "org.osbuild.mkfs.xfs",
"options": {
"uuid": "0194fdc2-fa2f-4cc0-81d3-ff12045b73c8"
"uuid": "6e4ff95f-f662-45ee-a82a-bdf44a2d0b75"
},
"devices": {
"device": {