distro/*: test expected failure for ostree

Test for each distro that runs through all architecture - image type
combinations and calls the Manifest() method with a kernel boot option
customization and checks if the ostree image types produce the expected
error.
This commit is contained in:
Achilleas Koutsou 2021-02-11 16:26:45 +01:00 committed by Ondřej Budai
parent fd1cc343a5
commit d8c292ca79
4 changed files with 123 additions and 0 deletions

View file

@ -4,6 +4,7 @@ import (
"testing"
"github.com/osbuild/osbuild-composer/internal/blueprint"
"github.com/osbuild/osbuild-composer/internal/distro"
"github.com/osbuild/osbuild-composer/internal/distro/distro_test_common"
"github.com/osbuild/osbuild-composer/internal/distro/fedora32"
"github.com/stretchr/testify/assert"
@ -291,6 +292,34 @@ func TestDistro_Manifest(t *testing.T) {
distro_test_common.TestDistro_Manifest(t, "../../../test/data/manifests/", "fedora_32*", fedora32.New())
}
// Check that Manifest() function returns an error for unsupported
// configurations.
func TestDistro_ManifestError(t *testing.T) {
// Currently, the only unsupported configuration is OSTree commit types
// with Kernel boot options
f32distro := fedora32.New()
bp := blueprint.Blueprint{
Customizations: &blueprint.Customizations{
Kernel: &blueprint.KernelCustomization{
Append: "debug",
},
},
}
for _, archName := range f32distro.ListArches() {
arch, _ := f32distro.GetArch(archName)
for _, imgTypeName := range arch.ListImageTypes() {
imgType, _ := arch.GetImageType(imgTypeName)
_, err := imgType.Manifest(bp.Customizations, distro.ImageOptions{}, nil, nil, nil, 0)
if imgTypeName == "fedora-iot-commit" {
assert.EqualError(t, err, "kernel boot parameter customizations are not supported for ostree types")
} else {
assert.NoError(t, err)
}
}
}
}
func TestFedora32_ListArches(t *testing.T) {
distro := fedora32.New()
arches := distro.ListArches()

View file

@ -4,6 +4,7 @@ import (
"testing"
"github.com/osbuild/osbuild-composer/internal/blueprint"
"github.com/osbuild/osbuild-composer/internal/distro"
"github.com/osbuild/osbuild-composer/internal/distro/distro_test_common"
"github.com/osbuild/osbuild-composer/internal/distro/fedora33"
"github.com/stretchr/testify/assert"
@ -297,6 +298,34 @@ func TestDistro_Manifest(t *testing.T) {
distro_test_common.TestDistro_Manifest(t, "../../../test/data/manifests/", "fedora_33*", fedora33.New())
}
// Check that Manifest() function returns an error for unsupported
// configurations.
func TestDistro_ManifestError(t *testing.T) {
// Currently, the only unsupported configuration is OSTree commit types
// with Kernel boot options
f33distro := fedora33.New()
bp := blueprint.Blueprint{
Customizations: &blueprint.Customizations{
Kernel: &blueprint.KernelCustomization{
Append: "debug",
},
},
}
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, nil, 0)
if imgTypeName == "fedora-iot-commit" {
assert.EqualError(t, err, "kernel boot parameter customizations are not supported for ostree types")
} else {
assert.NoError(t, err)
}
}
}
}
func TestFedora33_ListArches(t *testing.T) {
distro := fedora33.New()
arches := distro.ListArches()

View file

@ -4,6 +4,7 @@ import (
"testing"
"github.com/osbuild/osbuild-composer/internal/blueprint"
"github.com/osbuild/osbuild-composer/internal/distro"
"github.com/osbuild/osbuild-composer/internal/distro/distro_test_common"
"github.com/osbuild/osbuild-composer/internal/distro/rhel8"
"github.com/stretchr/testify/assert"
@ -350,6 +351,33 @@ func TestDistro_Manifest(t *testing.T) {
distro_test_common.TestDistro_Manifest(t, "../../../test/data/manifests/", "rhel_8-*", rhel8.New())
}
// Check that Manifest() function returns an error for unsupported
// configurations.
func TestDistro_ManifestError(t *testing.T) {
// Currently, the only unsupported configuration is OSTree commit types
// with Kernel boot options
r8distro := rhel8.New()
bp := blueprint.Blueprint{
Customizations: &blueprint.Customizations{
Kernel: &blueprint.KernelCustomization{
Append: "debug",
},
},
}
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, nil, 0)
if imgTypeName == "rhel-edge-commit" {
assert.EqualError(t, err, "kernel boot parameter customizations are not supported for ostree types")
} else {
assert.NoError(t, err)
}
}
}
}
func TestRhel8_ListArches(t *testing.T) {
distro := rhel8.New()
arches := distro.ListArches()

View file

@ -4,6 +4,7 @@ import (
"testing"
"github.com/osbuild/osbuild-composer/internal/blueprint"
"github.com/osbuild/osbuild-composer/internal/distro"
"github.com/osbuild/osbuild-composer/internal/distro/distro_test_common"
"github.com/osbuild/osbuild-composer/internal/distro/rhel84"
"github.com/stretchr/testify/assert"
@ -356,6 +357,42 @@ func TestDistro_Manifest(t *testing.T) {
distro_test_common.TestDistro_Manifest(t, "../../../test/data/manifests/", "rhel_84*", rhel84.New())
}
// Check that Manifest() function returns an error for unsupported
// configurations.
func TestDistro_ManifestError(t *testing.T) {
// Currently, the only unsupported configuration is OSTree commit types
// with Kernel boot options
r8distro := rhel84.New()
bp := blueprint.Blueprint{
Customizations: &blueprint.Customizations{
Kernel: &blueprint.KernelCustomization{
Append: "debug",
},
},
}
for _, archName := range r8distro.ListArches() {
arch, _ := r8distro.GetArch(archName)
for _, imgTypeName := range arch.ListImageTypes() {
if archName == "s390x" && imgTypeName == "tar" {
// broken arch-imgType combination; see
// https://github.com/osbuild/osbuild-composer/issues/1220
continue
}
imgType, _ := arch.GetImageType(imgTypeName)
imgOpts := distro.ImageOptions{
Size: imgType.Size(0),
}
_, err := imgType.Manifest(bp.Customizations, imgOpts, nil, nil, nil, 0)
if imgTypeName == "rhel-edge-commit" {
assert.EqualError(t, err, "kernel boot parameter customizations are not supported for ostree types")
} else {
assert.NoError(t, err)
}
}
}
}
func TestRhel84_ListArches(t *testing.T) {
distro := rhel84.New()
arches := distro.ListArches()