tests: manually convert to streamOptimized vmdk

This commit is contained in:
Alexander Todorov 2020-08-19 06:41:02 -04:00 committed by Tom Gundersen
parent dcee05d8b6
commit 5a395cda38
2 changed files with 26 additions and 0 deletions

View file

@ -344,6 +344,12 @@ func testBootUsingVMware(t *testing.T, imagePath string) {
}
require.NoError(t, err)
// convert to streamOptimized vmdk
imagePath, err = vmwaretest.ConvertToStreamOptimizedVmdk(imagePath)
require.NoError(t, err)
require.NotEqual(t, "", imagePath)
defer os.Remove(imagePath)
// create a random test id to name all the resources used in this test
imageName, err := generateRandomString("osbuild-image-tests-vmware-image-")
require.NoError(t, err)

View file

@ -7,6 +7,7 @@ import (
"os"
"os/exec"
"fmt"
"io/ioutil"
"path/filepath"
// importing the packages registers these cli commands
@ -209,3 +210,22 @@ func WithSSHKeyPair(f func(privateKey, publicKey string) error) error {
return f(private, public)
}
func ConvertToStreamOptimizedVmdk(imagePath string) (string, error) {
optimizedVmdk, err := ioutil.TempFile("/var/tmp", "osbuild-composer-stream-optimized-*.vmdk")
if err != nil {
return "", err
}
optimizedVmdk.Close()
cmd := exec.Command(
"/usr/bin/qemu-img", "convert", "-O", "vmdk", "-o", "subformat=streamOptimized",
imagePath, optimizedVmdk.Name())
err = cmd.Run()
if err != nil {
return "", err
}
return optimizedVmdk.Name(), nil
}