From 7b02d43139c79adb43c4a1e80c520962a9ecdc46 Mon Sep 17 00:00:00 2001 From: Achilleas Koutsou Date: Wed, 24 Feb 2021 19:11:13 +0100 Subject: [PATCH] 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. --- cmd/osbuild-image-tests/constants/constants.go | 8 ++++++-- cmd/osbuild-image-tests/main_test.go | 17 +++++++++++------ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/cmd/osbuild-image-tests/constants/constants.go b/cmd/osbuild-image-tests/constants/constants.go index cf8811969..d3eecc357 100644 --- a/cmd/osbuild-image-tests/constants/constants.go +++ b/cmd/osbuild-image-tests/constants/constants.go @@ -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 { diff --git a/cmd/osbuild-image-tests/main_test.go b/cmd/osbuild-image-tests/main_test.go index 832ff7cf7..4b9351dc1 100644 --- a/cmd/osbuild-image-tests/main_test.go +++ b/cmd/osbuild-image-tests/main_test.go @@ -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