debian-forge-composer/cmd/osbuild-dnf-json-tests/main_test.go
Jacob Kozol 678de9d1ef distro: add fedora 33 support
Fedora 33 images can now be built and test cases are added for the new
images. The fedora 33 qcow2 and vmdk images are based off of the
official images and their kickstarters found here:
https://pagure.io/fedora-kickstarts. The fedora 33 iot image is based
off of the the config found here: https://pagure.io/fedora-iot/ostree.
The openstack, azure, and amazon image types have changes made to them
based off of the changes made to the qcow2. The changes between fedora
32 and fedora 33 are as follows:

Grub now loads its kernel command line options from
etc/kernel/cmdline, /usr/lib/kernel/cmdline, and /proc/cmdline instead
of from grub env. This is addressed by adding kernelCmdlineStageOptions
to use osbuild's kernel-cmdline stage to set these options. Alongside
`ro biosdevname=0 net.ifnames=0`, we also set `no_timer_check
console=tty1 console=ttyS0,115200n8` per what is set in the official
qcow2. For azure and amazon, the kernelOptions are still set as they
were in fedora 32.

The timezone is now set to UTC if a user does not set a timezone in the
blueprint customizations. Also, the hostname is set to
localhost.localdomain if the hostname isn't set in the blueprint.

Finally, the following packages have been removed:

polkit
geolite2-city
geolite2-country
zram-generator-defaults
2020-10-01 10:11:03 +02:00

97 lines
3.5 KiB
Go

// This package contains tests related to dnf-json and rpmmd package.
// +build integration
package main
import (
"fmt"
"io/ioutil"
"os"
"path"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/osbuild/osbuild-composer/internal/blueprint"
"github.com/osbuild/osbuild-composer/internal/distro"
"github.com/osbuild/osbuild-composer/internal/distro/fedora31"
"github.com/osbuild/osbuild-composer/internal/distro/fedora32"
"github.com/osbuild/osbuild-composer/internal/distro/fedora33"
"github.com/osbuild/osbuild-composer/internal/rpmmd"
"github.com/osbuild/osbuild-composer/internal/test"
)
func TestFetchChecksum(t *testing.T) {
dir, err := test.SetUpTemporaryRepository()
defer func(dir string) {
err := test.TearDownTemporaryRepository(dir)
assert.Nil(t, err, "Failed to clean up temporary repository.")
}(dir)
assert.Nilf(t, err, "Failed to set up temporary repository: %v", err)
repoCfg := rpmmd.RepoConfig{
Name: "repo",
BaseURL: fmt.Sprintf("file://%s", dir),
IgnoreSSL: true,
}
// use a fullpath to dnf-json, this allows this test to have an arbitrary
// working directory
rpmMetadata := rpmmd.NewRPMMD(path.Join(dir, "rpmmd"), "/usr/libexec/osbuild-composer/dnf-json")
_, c, err := rpmMetadata.FetchMetadata([]rpmmd.RepoConfig{repoCfg}, "platform:f31", "x86_64")
assert.Nilf(t, err, "Failed to fetch checksum: %v", err)
assert.NotEqual(t, "", c["repo"], "The checksum is empty")
}
// This test loads all the repositories available in /repositories directory
// and tries to run depsolve for each architecture. With N architectures available
// this should run cross-arch dependency solving N-1 times.
func TestCrossArchDepsolve(t *testing.T) {
// Load repositories from the definition we provide in the RPM package
repoDir := "/usr/share/osbuild-composer"
// NOTE: we can add RHEL, but don't make it hard requirement because it will fail outside of VPN
for _, distroStruct := range []distro.Distro{fedora31.New(), fedora32.New(), fedora33.New()} {
t.Run(distroStruct.Name(), func(t *testing.T) {
// Run tests in parallel to speed up run times.
t.Parallel()
// Set up temporary directory for rpm/dnf cache
dir, err := ioutil.TempDir("/tmp", "rpmmd-test-")
require.Nilf(t, err, "Failed to create tmp dir for depsolve test: %v", err)
defer os.RemoveAll(dir)
// use a fullpath to dnf-json, this allows this test to have an arbitrary
// working directory
rpm := rpmmd.NewRPMMD(dir, "/usr/libexec/osbuild-composer/dnf-json")
repos, err := rpmmd.LoadRepositories([]string{repoDir}, distroStruct.Name())
require.NoErrorf(t, err, "Failed to LoadRepositories %v", distroStruct.Name())
for _, archStr := range distroStruct.ListArches() {
t.Run(archStr, func(t *testing.T) {
arch, err := distroStruct.GetArch(archStr)
require.NoError(t, err)
for _, imgTypeStr := range arch.ListImageTypes() {
t.Run(imgTypeStr, func(t *testing.T) {
imgType, err := arch.GetImageType(imgTypeStr)
require.NoError(t, err)
buildPackages := imgType.BuildPackages()
_, _, err = rpm.Depsolve(buildPackages, []string{}, repos[archStr], distroStruct.ModulePlatformID(), archStr)
assert.NoError(t, err)
basePackagesInclude, basePackagesExclude := imgType.Packages(blueprint.Blueprint{})
_, _, err = rpm.Depsolve(basePackagesInclude, basePackagesExclude, repos[archStr], distroStruct.ModulePlatformID(), archStr)
assert.NoError(t, err)
})
}
})
}
})
}
}