Skip to content

Commit

Permalink
Merge pull request #20137 from baude/applehvenablee2e
Browse files Browse the repository at this point in the history
Enable machine e2e test for applehv
  • Loading branch information
openshift-merge-robot authored Sep 26, 2023
2 parents cfc176d + 33a92aa commit 72033cd
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 9 deletions.
14 changes: 12 additions & 2 deletions pkg/machine/applehv/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"io/fs"
"net"
"os"
"os/exec"
"path/filepath"
"strconv"
"strings"
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions pkg/machine/e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/<yourname>`
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
3 changes: 3 additions & 0 deletions pkg/machine/e2e/config_darwin_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package e2e_test

const podmanBinary = "../../../bin/darwin/podman"
7 changes: 0 additions & 7 deletions pkg/machine/e2e/config_linux_test.go
Original file line number Diff line number Diff line change
@@ -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
}
7 changes: 7 additions & 0 deletions pkg/machine/e2e/config_unix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
package e2e_test

import (
"os/exec"

"github.com/containers/podman/v4/pkg/machine"
. "github.com/onsi/ginkgo/v2"
)
Expand All @@ -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
}

0 comments on commit 72033cd

Please sign in to comment.