Skip to content

Commit

Permalink
Merge pull request #23068 from ashley-cui/speedymacci
Browse files Browse the repository at this point in the history
pkg/machine/e2e: Remove unnecessary copy of machine image.
  • Loading branch information
openshift-merge-bot[bot] authored Jun 24, 2024
2 parents 1128e5b + 4dc98e3 commit fe18a87
Showing 1 changed file with 1 addition and 34 deletions.
35 changes: 1 addition & 34 deletions pkg/machine/e2e/machine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@ package e2e_test
import (
"errors"
"fmt"
"io"
"os"
"path/filepath"
"runtime"
"strings"
"testing"

"github.com/containers/common/pkg/config"
"github.com/containers/podman/v5/pkg/machine/compression"
"github.com/containers/podman/v5/pkg/machine/define"
"github.com/containers/podman/v5/pkg/machine/provider"
"github.com/containers/podman/v5/pkg/machine/vmconfigs"
Expand Down Expand Up @@ -126,26 +124,7 @@ func setup() (string, *machineTestBuilder) {
Fail(fmt.Sprintf("failed to close src reader %q: %q", src.Name(), err))
}
}()
mb.imagePath = filepath.Join(homeDir, suiteImageName)
dest, err := os.Create(mb.imagePath)
if err != nil {
Fail(fmt.Sprintf("failed to create file %s: %q", mb.imagePath, err))
}
defer func() {
if err := dest.Close(); err != nil {
Fail(fmt.Sprintf("failed to close destination file %q: %q\n", dest.Name(), err))
}
}()
fmt.Printf("--> copying %q to %q\n", src.Name(), dest.Name())
if runtime.GOOS != "darwin" {
if _, err := io.Copy(dest, src); err != nil {
Fail(fmt.Sprintf("failed to copy %ss to %s: %q", fqImageName, mb.imagePath, err))
}
} else {
if err := copySparse(dest, src); err != nil {
Fail(fmt.Sprintf("failed to copy %q to %q: %q", src.Name(), dest.Name(), err))
}
}
mb.imagePath = fqImageName
return homeDir, mb
}

Expand All @@ -171,18 +150,6 @@ func teardown(origHomeDir string, testDir string, mb *machineTestBuilder) {
}
}

// copySparse is a helper method for tests only; caller is responsible for closures
func copySparse(dst io.WriteSeeker, src io.Reader) (retErr error) {
spWriter := compression.NewSparseWriter(dst)
defer func() {
if err := spWriter.Close(); err != nil && retErr == nil {
retErr = err
}
}()
_, err := io.Copy(spWriter, src)
return err
}

func setTmpDir(value string) (string, error) {
switch {
case runtime.GOOS != "darwin":
Expand Down

0 comments on commit fe18a87

Please sign in to comment.