osbuild-image-tests: call osbuild with export option

Call osbuild with the export option.  For now the only valid export
value is "assembler".

Run all exported images through testImage.
This commit is contained in:
Achilleas Koutsou 2021-02-24 19:11:13 +01:00 committed by Tom Gundersen
parent 164faa7503
commit 7b02d43139
2 changed files with 17 additions and 8 deletions

View file

@ -4,8 +4,8 @@ package constants
import "os/exec"
func GetOsbuildCommand(store, outputDirectory string) *exec.Cmd {
return exec.Command(
func GetOsbuildCommand(store, outputDirectory string, exports []string) *exec.Cmd {
cmd := exec.Command(
"osbuild",
"--store", store,
"--output-directory", outputDirectory,
@ -13,6 +13,10 @@ func GetOsbuildCommand(store, outputDirectory string) *exec.Cmd {
"--json",
"-",
)
for _, export := range exports {
cmd.Args = append(cmd.Args, "--export", export)
}
return cmd
}
func GetImageInfoCommand(imagePath string) *exec.Cmd {

View file

@ -14,6 +14,7 @@ import (
"os"
"os/exec"
"path"
"path/filepath"
"strings"
"testing"
"time"
@ -50,8 +51,8 @@ var disableLocalBoot = flag.Bool("disable-local-boot", false, "when this flag is
var failLocalBoot = flag.Bool("fail-local-boot", true, "when this flag is on (default), local boot will fail. Usually indicates missing cloud credentials")
// runOsbuild runs osbuild with the specified manifest and output-directory.
func runOsbuild(manifest []byte, store, outputDirectory string) error {
cmd := constants.GetOsbuildCommand(store, outputDirectory)
func runOsbuild(manifest []byte, store, outputDirectory string, exports []string) error {
cmd := constants.GetOsbuildCommand(store, outputDirectory, exports)
cmd.Stdin = bytes.NewReader(manifest)
var outBuffer, errBuffer bytes.Buffer
@ -475,12 +476,16 @@ func runTestcase(t *testing.T, testcase testcaseStruct, store string) {
require.NoError(t, err, "error removing temporary output directory")
}()
err = runOsbuild(testcase.Manifest, store, outputDirectory)
// NOTE(akoutsou) 1to2t: new v2 manifests name their last pipeline
// "assembler" for compatibility with v1
exports := []string{"assembler"}
err = runOsbuild(testcase.Manifest, store, outputDirectory, exports)
require.NoError(t, err)
imagePath := fmt.Sprintf("%s/%s", outputDirectory, testcase.ComposeRequest.Filename)
testImage(t, testcase, imagePath)
for _, export := range exports {
imagePath := filepath.Join(outputDirectory, export, testcase.ComposeRequest.Filename)
testImage(t, testcase, imagePath)
}
}
// getAllCases returns paths to all testcases in the testcase directory