From 33a92aa006d39abfff24cf3112b0568b7f4906da Mon Sep 17 00:00:00 2001 From: Brent Baude Date: Sun, 17 Sep 2023 09:10:00 -0500 Subject: [PATCH] Enable machine e2e test for applehv This PR allows you to run the pkg/machine/e2e tests for the applehv PROVIDER. This does not mean they pass, only that they can run. There also appears to be leftover gvproxy processes at the conclusion of a single test. This will need to be corrected. [NO NEW TESTS NEEDED] Signed-off-by: Brent Baude --- pkg/machine/applehv/machine.go | 14 ++++++++++++-- pkg/machine/e2e/README.md | 13 +++++++++++++ pkg/machine/e2e/config_darwin_test.go | 3 +++ pkg/machine/e2e/config_linux_test.go | 7 ------- pkg/machine/e2e/config_unix_test.go | 7 +++++++ 5 files changed, 35 insertions(+), 9 deletions(-) create mode 100644 pkg/machine/e2e/config_darwin_test.go diff --git a/pkg/machine/applehv/machine.go b/pkg/machine/applehv/machine.go index b20f598368..d91c602fb0 100644 --- a/pkg/machine/applehv/machine.go +++ b/pkg/machine/applehv/machine.go @@ -11,6 +11,7 @@ import ( "io/fs" "net" "os" + "os/exec" "path/filepath" "strconv" "strings" @@ -263,7 +264,7 @@ func (m *MacMachine) Init(opts machine.InitOptions) (bool, error) { return false, err } - // Until the disk resize can be fixed, we ignore it + logrus.Debugf("resizing disk to %d GiB", opts.DiskSize) if err := m.resizeDisk(strongunits.GiB(opts.DiskSize)); err != nil { return false, err } @@ -952,7 +953,16 @@ func (m *MacMachine) resizeDisk(newSize strongunits.GiB) error { // error has not merged return fmt.Errorf("invalid disk size %d: new disk must be larger than %dGB", newSize, m.DiskSize) } - return os.Truncate(m.ImagePath.GetPath(), int64(newSize.ToBytes())) + logrus.Debugf("resizing %s to %d bytes", m.ImagePath.GetPath(), newSize.ToBytes()) + // seems like os.truncate() is not very performant with really large files + // so exec'ing out to the command truncate + size := fmt.Sprintf("%dG", newSize) + c := exec.Command("truncate", "-s", size, m.ImagePath.GetPath()) + if logrus.IsLevelEnabled(logrus.DebugLevel) { + c.Stderr = os.Stderr + c.Stdout = os.Stdout + } + return c.Run() } // isFirstBoot returns a bool reflecting if the machine has been booted before diff --git a/pkg/machine/e2e/README.md b/pkg/machine/e2e/README.md index 1f90accf2b..bf64b5c3fa 100644 --- a/pkg/machine/e2e/README.md +++ b/pkg/machine/e2e/README.md @@ -24,3 +24,16 @@ Note: Add `--focus-file "basic_test.go" ` to only run basic test 1. `./test/tools/build/ginkgo.exe -vv --tags "remote exclude_graphdriver_btrfs btrfs_noversion exclude_graphdriver_devicemapper containers_image_openpgp remote" -timeout=90m --trace --no-color pkg/machine/e2e/. ` Note: Add `--focus-file "basic_test.go" ` to only run basic test + +## MacOS + +### Apple Hypervisor + +1. `make podman-remote` +1. `make .install.ginkgo` +1. `export TMPDIR=/Users/` +1. `export CONTAINERS_MACHINE_PROVIDER="applehv"` +1. `export MACHINE_IMAGE="https://fedorapeople.org/groups/podman/testing/applehv/arm64/fedora-coreos-38.20230925.dev.0-applehv.aarch64.raw.gz"` +1. `./test/tools/build/ginkgo -vv --tags "remote exclude_graphdriver_btrfs btrfs_noversion exclude_graphdriver_devicemapper containers_image_openpgp remote" -timeout=90m --trace --no-color pkg/machine/e2e/.` + +Note: Add `--focus-file "basic_test.go" ` to only run basic test diff --git a/pkg/machine/e2e/config_darwin_test.go b/pkg/machine/e2e/config_darwin_test.go new file mode 100644 index 0000000000..a04695c32c --- /dev/null +++ b/pkg/machine/e2e/config_darwin_test.go @@ -0,0 +1,3 @@ +package e2e_test + +const podmanBinary = "../../../bin/darwin/podman" diff --git a/pkg/machine/e2e/config_linux_test.go b/pkg/machine/e2e/config_linux_test.go index 644c7bff65..f07121a90f 100644 --- a/pkg/machine/e2e/config_linux_test.go +++ b/pkg/machine/e2e/config_linux_test.go @@ -1,10 +1,3 @@ package e2e_test -import "os/exec" - const podmanBinary = "../../../bin/podman-remote" - -func pgrep(n string) (string, error) { - out, err := exec.Command("pgrep", "gvproxy").Output() - return string(out), err -} diff --git a/pkg/machine/e2e/config_unix_test.go b/pkg/machine/e2e/config_unix_test.go index b46b596efe..027021ca43 100644 --- a/pkg/machine/e2e/config_unix_test.go +++ b/pkg/machine/e2e/config_unix_test.go @@ -3,6 +3,8 @@ package e2e_test import ( + "os/exec" + "github.com/containers/podman/v4/pkg/machine" . "github.com/onsi/ginkgo/v2" ) @@ -20,3 +22,8 @@ func getDownloadLocation(p machine.VirtProvider) string { return fcd.Location } + +func pgrep(n string) (string, error) { + out, err := exec.Command("pgrep", "gvproxy").Output() + return string(out), err +}