mirror of
https://github.com/containers/podman.git
synced 2025-11-29 01:28:22 +08:00
fake images: windows hyperv
this pr is a follow on to #27493. it adds support for hyperv "fake" images and suggests a benefit in terms of test speed. for hyperv, we create a generic 4MB vhdx and stick it into the temp dir. this saves us from any image copy or compression. i also followed up on a few comments Paul made about using windows|unix instead of each platform. Signed-off-by: Brent Baude <bbaude@redhat.com>
This commit is contained in:
@@ -1,12 +1,3 @@
|
|||||||
package e2e_test
|
package e2e_test
|
||||||
|
|
||||||
import "os"
|
|
||||||
|
|
||||||
const podmanBinary = "../../../bin/darwin/podman"
|
const podmanBinary = "../../../bin/darwin/podman"
|
||||||
|
|
||||||
var fakeImagePath string = os.DevNull
|
|
||||||
|
|
||||||
func (i *initMachine) withFakeImage(_ *machineTestBuilder) *initMachine {
|
|
||||||
i.image = fakeImagePath
|
|
||||||
return i
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,12 +1,3 @@
|
|||||||
package e2e_test
|
package e2e_test
|
||||||
|
|
||||||
import "os"
|
|
||||||
|
|
||||||
const podmanBinary = "../../../bin/podman-remote"
|
const podmanBinary = "../../../bin/podman-remote"
|
||||||
|
|
||||||
var fakeImagePath string = os.DevNull
|
|
||||||
|
|
||||||
func (i *initMachine) withFakeImage(_ *machineTestBuilder) *initMachine {
|
|
||||||
i.image = fakeImagePath
|
|
||||||
return i
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,12 +1,3 @@
|
|||||||
package e2e_test
|
package e2e_test
|
||||||
|
|
||||||
import "os"
|
|
||||||
|
|
||||||
const podmanBinary = "../../../bin/podman-remote"
|
const podmanBinary = "../../../bin/podman-remote"
|
||||||
|
|
||||||
var fakeImagePath string = os.DevNull
|
|
||||||
|
|
||||||
func (i *initMachine) withFakeImage(_ *machineTestBuilder) *initMachine {
|
|
||||||
i.image = fakeImagePath
|
|
||||||
return i
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -3,10 +3,24 @@
|
|||||||
package e2e_test
|
package e2e_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var fakeImagePath string = os.DevNull
|
||||||
|
|
||||||
func pgrep(_ string) (string, error) {
|
func pgrep(_ string) (string, error) {
|
||||||
out, err := exec.Command("pgrep", "gvproxy").Output()
|
out, err := exec.Command("pgrep", "gvproxy").Output()
|
||||||
return string(out), err
|
return string(out), err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func initPlatform() {}
|
||||||
|
func cleanupPlatform() {}
|
||||||
|
|
||||||
|
// withFakeImage should be used in tests where the machine is
|
||||||
|
// initialized (or not) but never started. It is intended
|
||||||
|
// to speed up CI by not processing our large machine files.
|
||||||
|
func (i *initMachine) withFakeImage(_ *machineTestBuilder) *initMachine {
|
||||||
|
i.image = fakeImagePath
|
||||||
|
return i
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,15 +2,44 @@ package e2e_test
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containers/libhvee/pkg/hypervctl"
|
||||||
|
"github.com/containers/podman/v6/pkg/machine/define"
|
||||||
. "github.com/onsi/ginkgo/v2"
|
. "github.com/onsi/ginkgo/v2"
|
||||||
. "github.com/onsi/gomega/gexec"
|
. "github.com/onsi/gomega/gexec"
|
||||||
)
|
)
|
||||||
|
|
||||||
const podmanBinary = "../../../bin/windows/podman.exe"
|
const podmanBinary = "../../../bin/windows/podman.exe"
|
||||||
|
|
||||||
|
var fakeImagePath string = ""
|
||||||
|
|
||||||
|
func initPlatform() {
|
||||||
|
switch testProvider.VMType().String() {
|
||||||
|
case define.HyperVVirt.String():
|
||||||
|
vmm := hypervctl.NewVirtualMachineManager()
|
||||||
|
name := fmt.Sprintf("podman-hyperv-%s.vhdx", randomString())
|
||||||
|
fullFileName := filepath.Join(tmpDir, name)
|
||||||
|
if err := vmm.CreateVhdxFile(fullFileName, 15*1024*1024); err != nil {
|
||||||
|
Fail(fmt.Sprintf("Failed to create file %s %q", fullFileName, err))
|
||||||
|
}
|
||||||
|
fakeImagePath = fullFileName
|
||||||
|
fmt.Println("Created fake disk image: " + fakeImagePath)
|
||||||
|
case define.WSLVirt.String():
|
||||||
|
default:
|
||||||
|
Fail(fmt.Sprintf("unknown Windows provider: %q", testProvider.VMType().String()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func cleanupPlatform() {
|
||||||
|
if err := os.Remove(fakeImagePath); err != nil {
|
||||||
|
fmt.Printf("Failed to remove %s image: %q\n", fakeImagePath, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// pgrep emulates the pgrep linux command
|
// pgrep emulates the pgrep linux command
|
||||||
func pgrep(n string) (string, error) {
|
func pgrep(n string) (string, error) {
|
||||||
// add filter to find the process and do no display a header
|
// add filter to find the process and do no display a header
|
||||||
@@ -41,7 +70,17 @@ func runWslCommand(cmdArgs []string) (*machineSession, error) {
|
|||||||
return &ms, nil
|
return &ms, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *initMachine) withFakeImage(_ *machineTestBuilder) *initMachine {
|
// withFakeImage should be used in tests where the machine is
|
||||||
i.image = mb.imagePath
|
// initialized (or not) but never started. It is intended
|
||||||
|
// to speed up CI by not processing our large machine files.
|
||||||
|
func (i *initMachine) withFakeImage(mb *machineTestBuilder) *initMachine {
|
||||||
|
switch testProvider.VMType() {
|
||||||
|
case define.HyperVVirt:
|
||||||
|
i.image = fakeImagePath
|
||||||
|
case define.WSLVirt:
|
||||||
|
i.image = mb.imagePath
|
||||||
|
default:
|
||||||
|
Fail(fmt.Sprintf("unknown Windows provider: %q", testProvider.VMType().String()))
|
||||||
|
}
|
||||||
return i
|
return i
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,6 +72,9 @@ var _ = BeforeSuite(func() {
|
|||||||
if pullError != nil {
|
if pullError != nil {
|
||||||
Fail(fmt.Sprintf("failed to pull disk: %q", pullError))
|
Fail(fmt.Sprintf("failed to pull disk: %q", pullError))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fmt.Println("Running platform specific set-up")
|
||||||
|
initPlatform()
|
||||||
})
|
})
|
||||||
|
|
||||||
type timing struct {
|
type timing struct {
|
||||||
@@ -96,6 +99,8 @@ var _ = SynchronizedAfterSuite(func() {}, func() {
|
|||||||
for _, t := range timings {
|
for _, t := range timings {
|
||||||
GinkgoWriter.Printf("%s\t\t%f seconds\n", t.name, t.length.Seconds())
|
GinkgoWriter.Printf("%s\t\t%f seconds\n", t.name, t.length.Seconds())
|
||||||
}
|
}
|
||||||
|
fmt.Println("Running platform specific cleanup")
|
||||||
|
cleanupPlatform()
|
||||||
})
|
})
|
||||||
|
|
||||||
// The config does not matter to much for our testing, however we
|
// The config does not matter to much for our testing, however we
|
||||||
|
|||||||
Reference in New Issue
Block a user