From c671a0dab149b019c9dbd87bb6d6b8eef986bfaf Mon Sep 17 00:00:00 2001 From: Gianluca Zuccarelli Date: Thu, 8 Jul 2021 13:55:23 +0100 Subject: [PATCH] distro: test filesystem errors --- internal/distro/fedora33/distro_test.go | 52 ++++++++++++++++++ internal/distro/rhel8/distro_test.go | 51 ++++++++++++++++++ internal/distro/rhel84/distro_test.go | 72 +++++++++++++++++++++++++ internal/distro/rhel85/distro_test.go | 56 +++++++++++++++++++ internal/distro/rhel90/distro_test.go | 44 +++++++++++++++ 5 files changed, 275 insertions(+) diff --git a/internal/distro/fedora33/distro_test.go b/internal/distro/fedora33/distro_test.go index e2133f815..e3b20f3b2 100644 --- a/internal/distro/fedora33/distro_test.go +++ b/internal/distro/fedora33/distro_test.go @@ -379,3 +379,55 @@ func TestFedora33_ModulePlatformID(t *testing.T) { func TestFedora33_KernelOption(t *testing.T) { distro_test_common.TestDistro_KernelOption(t, fedora33.New()) } + +func TestDistro_CustomFileSystemManifestError(t *testing.T) { + f33distro := fedora33.New() + bp := blueprint.Blueprint{ + Customizations: &blueprint.Customizations{ + Filesystem: []blueprint.FilesystemCustomization{ + { + MinSize: 1024, + Mountpoint: "/boot", + }, + }, + }, + } + for _, archName := range f33distro.ListArches() { + arch, _ := f33distro.GetArch(archName) + for _, imgTypeName := range arch.ListImageTypes() { + imgType, _ := arch.GetImageType(imgTypeName) + _, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, nil, 0) + if imgTypeName == "fedora-iot-commit" { + assert.EqualError(t, err, "Custom mountpoints are not supported for ostree types") + } else { + assert.EqualError(t, err, "The following custom mountpoints are not supported [\"/boot\"]") + } + } + } +} + +func TestDistro_TestRootMountPoint(t *testing.T) { + f33distro := fedora33.New() + bp := blueprint.Blueprint{ + Customizations: &blueprint.Customizations{ + Filesystem: []blueprint.FilesystemCustomization{ + { + MinSize: 1024, + Mountpoint: "/", + }, + }, + }, + } + for _, archName := range f33distro.ListArches() { + arch, _ := f33distro.GetArch(archName) + for _, imgTypeName := range arch.ListImageTypes() { + imgType, _ := arch.GetImageType(imgTypeName) + _, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, nil, 0) + if imgTypeName == "fedora-iot-commit" { + assert.EqualError(t, err, "Custom mountpoints are not supported for ostree types") + } else { + assert.NoError(t, err) + } + } + } +} diff --git a/internal/distro/rhel8/distro_test.go b/internal/distro/rhel8/distro_test.go index 75a73e1f8..a3a6961e2 100644 --- a/internal/distro/rhel8/distro_test.go +++ b/internal/distro/rhel8/distro_test.go @@ -381,6 +381,57 @@ func TestDistro_ManifestError(t *testing.T) { } } } +func TestDistro_CustomFileSystemManifestError(t *testing.T) { + r8distro := rhel8.New() + bp := blueprint.Blueprint{ + Customizations: &blueprint.Customizations{ + Filesystem: []blueprint.FilesystemCustomization{ + { + MinSize: 1024, + Mountpoint: "/boot", + }, + }, + }, + } + for _, archName := range r8distro.ListArches() { + arch, _ := r8distro.GetArch(archName) + for _, imgTypeName := range arch.ListImageTypes() { + imgType, _ := arch.GetImageType(imgTypeName) + _, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, nil, 0) + if imgTypeName == "rhel-edge-commit" { + assert.EqualError(t, err, "Custom mountpoints are not supported for ostree types") + } else { + assert.EqualError(t, err, "The following custom mountpoints are not supported [\"/var\"]") + } + } + } +} + +func TestDistro_TestRootMountPoint(t *testing.T) { + r8distro := rhel8.New() + bp := blueprint.Blueprint{ + Customizations: &blueprint.Customizations{ + Filesystem: []blueprint.FilesystemCustomization{ + { + MinSize: 1024, + Mountpoint: "/", + }, + }, + }, + } + for _, archName := range r8distro.ListArches() { + arch, _ := r8distro.GetArch(archName) + for _, imgTypeName := range arch.ListImageTypes() { + imgType, _ := arch.GetImageType(imgTypeName) + _, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, nil, 0) + if imgTypeName == "rhel-edge-commit" { + assert.EqualError(t, err, "Custom mountpoints are not supported for ostree types") + } else { + assert.NoError(t, err) + } + } + } +} func TestRhel8_ListArches(t *testing.T) { distro := rhel8.New() diff --git a/internal/distro/rhel84/distro_test.go b/internal/distro/rhel84/distro_test.go index e1fe95410..49b2ec7a0 100644 --- a/internal/distro/rhel84/distro_test.go +++ b/internal/distro/rhel84/distro_test.go @@ -590,3 +590,75 @@ func TestRhel84_ModulePlatformID(t *testing.T) { func TestRhel84_KernelOption(t *testing.T) { distro_test_common.TestDistro_KernelOption(t, rhel84.New()) } + +func TestDistro_CustomFileSystemManifestError(t *testing.T) { + bp := blueprint.Blueprint{ + Customizations: &blueprint.Customizations{ + Filesystem: []blueprint.FilesystemCustomization{ + { + MinSize: 1024, + Mountpoint: "/boot", + }, + }, + }, + } + for _, dist := range rhelFamilyDistros { + t.Run(dist.name, func(t *testing.T) { + d := dist.distro + for _, archName := range d.ListArches() { + arch, _ := d.GetArch(archName) + for _, imgTypeName := range arch.ListImageTypes() { + if (archName == "s390x" && imgTypeName == "tar") || imgTypeName == "rhel-edge-installer" { + continue + } + imgType, _ := arch.GetImageType(imgTypeName) + imgOpts := distro.ImageOptions{ + Size: imgType.Size(0), + } + _, err := imgType.Manifest(bp.Customizations, imgOpts, nil, nil, 0) + if imgTypeName == "rhel-edge-commit" || imgTypeName == "rhel-edge-container" { + assert.EqualError(t, err, "Custom mountpoints are not supported for ostree types") + } else { + assert.EqualError(t, err, "The following custom mountpoints are not supported [\"/boot\"]") + } + } + } + }) + } +} + +func TestDistro_TestRootMountPoint(t *testing.T) { + bp := blueprint.Blueprint{ + Customizations: &blueprint.Customizations{ + Filesystem: []blueprint.FilesystemCustomization{ + { + MinSize: 1024, + Mountpoint: "/", + }, + }, + }, + } + for _, dist := range rhelFamilyDistros { + t.Run(dist.name, func(t *testing.T) { + d := dist.distro + for _, archName := range d.ListArches() { + arch, _ := d.GetArch(archName) + for _, imgTypeName := range arch.ListImageTypes() { + if (archName == "s390x" && imgTypeName == "tar") || imgTypeName == "rhel-edge-installer" { + continue + } + imgType, _ := arch.GetImageType(imgTypeName) + imgOpts := distro.ImageOptions{ + Size: imgType.Size(0), + } + _, err := imgType.Manifest(bp.Customizations, imgOpts, nil, nil, 0) + if imgTypeName == "rhel-edge-commit" || imgTypeName == "rhel-edge-container" { + assert.EqualError(t, err, "Custom mountpoints are not supported for ostree types") + } else { + assert.NoError(t, err) + } + } + } + }) + } +} diff --git a/internal/distro/rhel85/distro_test.go b/internal/distro/rhel85/distro_test.go index 7d148c933..0376c3c65 100644 --- a/internal/distro/rhel85/distro_test.go +++ b/internal/distro/rhel85/distro_test.go @@ -524,3 +524,59 @@ func TestRhel85_ModulePlatformID(t *testing.T) { func TestRhel85_KernelOption(t *testing.T) { distro_test_common.TestDistro_KernelOption(t, rhel85.New()) } + +func TestDistro_CustomFileSystemManifestError(t *testing.T) { + r8distro := rhel85.New() + bp := blueprint.Blueprint{ + Customizations: &blueprint.Customizations{ + Filesystem: []blueprint.FilesystemCustomization{ + { + MinSize: 1024, + Mountpoint: "/boot", + }, + }, + }, + } + for _, archName := range r8distro.ListArches() { + arch, _ := r8distro.GetArch(archName) + for _, imgTypeName := range arch.ListImageTypes() { + imgType, _ := arch.GetImageType(imgTypeName) + _, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, nil, 0) + if imgTypeName == "edge-commit" || imgTypeName == "edge-container" { + assert.EqualError(t, err, "Custom mountpoints are not supported for ostree types") + } else if imgTypeName == "edge-installer" { + continue + } else { + assert.EqualError(t, err, "The following custom mountpoints are not supported [\"/boot\"]") + } + } + } +} + +func TestDistro_TestRootMountPoint(t *testing.T) { + r8distro := rhel85.New() + bp := blueprint.Blueprint{ + Customizations: &blueprint.Customizations{ + Filesystem: []blueprint.FilesystemCustomization{ + { + MinSize: 1024, + Mountpoint: "/", + }, + }, + }, + } + for _, archName := range r8distro.ListArches() { + arch, _ := r8distro.GetArch(archName) + for _, imgTypeName := range arch.ListImageTypes() { + imgType, _ := arch.GetImageType(imgTypeName) + _, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, nil, 0) + if imgTypeName == "edge-commit" || imgTypeName == "edge-container" { + assert.EqualError(t, err, "Custom mountpoints are not supported for ostree types") + } else if imgTypeName == "edge-installer" { + continue + } else { + assert.NoError(t, err) + } + } + } +} diff --git a/internal/distro/rhel90/distro_test.go b/internal/distro/rhel90/distro_test.go index 7dd99fef3..5422fe8cb 100644 --- a/internal/distro/rhel90/distro_test.go +++ b/internal/distro/rhel90/distro_test.go @@ -378,3 +378,47 @@ func TestRhel84_ModulePlatformID(t *testing.T) { func TestRhel90_KernelOption(t *testing.T) { distro_test_common.TestDistro_KernelOption(t, rhel90.New()) } + +func TestDistro_CustomFileSystemManifestError(t *testing.T) { + r9distro := rhel90.New() + bp := blueprint.Blueprint{ + Customizations: &blueprint.Customizations{ + Filesystem: []blueprint.FilesystemCustomization{ + { + MinSize: 1024, + Mountpoint: "/boot", + }, + }, + }, + } + for _, archName := range r9distro.ListArches() { + arch, _ := r9distro.GetArch(archName) + for _, imgTypeName := range arch.ListImageTypes() { + imgType, _ := arch.GetImageType(imgTypeName) + _, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, nil, 0) + assert.EqualError(t, err, "The following custom mountpoints are not supported [\"/boot\"]") + } + } +} + +func TestDistro_TestRootMountPoint(t *testing.T) { + r9distro := rhel90.New() + bp := blueprint.Blueprint{ + Customizations: &blueprint.Customizations{ + Filesystem: []blueprint.FilesystemCustomization{ + { + MinSize: 1024, + Mountpoint: "/", + }, + }, + }, + } + for _, archName := range r9distro.ListArches() { + arch, _ := r9distro.GetArch(archName) + for _, imgTypeName := range arch.ListImageTypes() { + imgType, _ := arch.GetImageType(imgTypeName) + _, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, nil, 0) + assert.NoError(t, err) + } + } +}