Files
podman/pkg/machine/e2e/machine_wsl_test.go
Brent Baude fd1d951262 Move ignition functions into Containerfiles
We used to use ignition to perform any customization required for podman
machine because our input was a generic FCOS image.  Now that we are
building our own images, some of this customization can be migrated to
the Containerfile itself and be less of a burden in our code at boot up.

At the time of this PR, the Containerfile can be found at
https://github.com/baude/podman-machine-images/tree/main.  It is only
present for a so-called daily image.  There is little liklihood that
this would the final location for the Containerfile so consider it a
working version only.

Split WSL and rest apart in the e2e tests so we no longer ppull the
generic FCOS image for testing.

Note: the change to the pull image name is so PRs are not immediately
broken that are already in the queue.

[NO NEW TESTS REQUIRED]

Signed-off-by: Brent Baude <bbaude@redhat.com>
2024-02-28 16:05:50 -06:00

56 lines
1.7 KiB
Go

package e2e_test
import (
"errors"
"fmt"
url2 "net/url"
"os"
"path"
"path/filepath"
"strings"
"time"
"github.com/containers/podman/v5/pkg/machine"
"github.com/containers/podman/v5/pkg/machine/compression"
"github.com/containers/podman/v5/pkg/machine/define"
"github.com/containers/podman/v5/pkg/machine/wsl"
. "github.com/onsi/ginkgo/v2"
)
func pullWSLDisk() error {
downloadLocation := os.Getenv("MACHINE_IMAGE")
if downloadLocation == "" {
dl, _, _, _, err := wsl.GetFedoraDownloadForWSL()
if err != nil {
return errors.New("unable to determine WSL download")
}
downloadLocation = dl.String()
}
if downloadLocation == "" {
return errors.New("machine tests require a file reference to a disk image right now")
}
compressionExtension := ".xz"
suiteImageName = strings.TrimSuffix(path.Base(downloadLocation), compressionExtension)
fqImageName = filepath.Join(tmpDir, suiteImageName)
getMe, err := url2.Parse(downloadLocation)
if err != nil {
return fmt.Errorf("unable to create url for download: %q", err)
}
now := time.Now()
if err := machine.DownloadVMImage(getMe, suiteImageName, fqImageName+compressionExtension); err != nil {
return fmt.Errorf("unable to download machine image: %q", err)
}
GinkgoWriter.Println("Download took: ", time.Since(now).String())
diskImage, err := define.NewMachineFile(fqImageName+compressionExtension, nil)
if err != nil {
return fmt.Errorf("unable to create vmfile %q: %v", fqImageName+compressionExtension, err)
}
compressionStart := time.Now()
if err := compression.Decompress(diskImage, fqImageName); err != nil {
return fmt.Errorf("unable to decompress image file: %q", err)
}
GinkgoWriter.Println("compression took: ", time.Since(compressionStart))
return nil
}