Skip to content

Commit

Permalink
Enable machine e2e tests for WSL
Browse files Browse the repository at this point in the history
this pr allows us to run the machine e2e tests with the wsl provider.

[NO NEW TESTS NEEDED]

Signed-off-by: Brent Baude <[email protected]>
  • Loading branch information
baude committed Sep 19, 2023
1 parent 696f4a6 commit 38f5ead
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 11 deletions.
13 changes: 10 additions & 3 deletions pkg/machine/e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,15 @@
### HyperV

1. Open a powershell as admin
2. $env:CONTAINERS_MACHINE_PROVIDER="hyperv"
3. $env:MACHINE_IMAGE="https://fedorapeople.org/groups/podman/testing/hyperv/fedora-coreos-38.20230830.dev.0-hyperv.x86_64.vhdx.zip"
4. `./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/. `
1. $env:CONTAINERS_MACHINE_PROVIDER="hyperv"
1. $env:MACHINE_IMAGE="https://fedorapeople.org/groups/podman/testing/hyperv/fedora-coreos-38.20230830.dev.0-hyperv.x86_64.vhdx.zip"
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

### WSL
1. Open a powershell as a regular user
1. Build and copy win-sshproxy into bin/
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
22 changes: 22 additions & 0 deletions pkg/machine/e2e/config_unix_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd

package e2e_test

import (
"github.com/containers/podman/v4/pkg/machine"
. "github.com/onsi/ginkgo/v2"
)

func getDownloadLocation(p machine.VirtProvider) string {
dd, err := p.NewDownload("")
if err != nil {
Fail("unable to create new download")
}

fcd, err := dd.GetFCOSDownload(defaultStream)
if err != nil {
Fail("unable to get virtual machine image")
}

return fcd.Location
}
14 changes: 14 additions & 0 deletions pkg/machine/e2e/config_windows_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
package e2e_test

import (
"github.com/containers/podman/v4/pkg/machine"
"github.com/containers/podman/v4/pkg/machine/wsl"
. "github.com/onsi/ginkgo/v2"
)

const podmanBinary = "../../../bin/windows/podman.exe"

func getDownloadLocation(_ machine.VirtProvider) string {
fd, err := wsl.NewFedoraDownloader(machine.WSLVirt, "", defaultStream.String())
if err != nil {
Fail("unable to get WSL virtual image")
}
return fd.Get().URL.String()
}
15 changes: 7 additions & 8 deletions pkg/machine/e2e/machine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,23 @@ func TestMachine(t *testing.T) {
}

var _ = BeforeSuite(func() {

testProvider, err := provider.Get()
if err != nil {
Fail("unable to create testProvider")
}

downloadLocation := os.Getenv("MACHINE_IMAGE")

dd, err := testProvider.NewDownload("")
if err != nil {
Fail("unable to create new download")
}
if len(downloadLocation) < 1 {
fcd, err := dd.GetFCOSDownload(defaultStream)
if err != nil {
Fail("unable to get virtual machine image")
downloadLocation = getDownloadLocation(testProvider)
// we cannot simply use OS here because hyperv uses fcos; so WSL is just
// special here
if testProvider.VMType() != machine.WSLVirt {
downloadLocation = getDownloadLocation(testProvider)
}
downloadLocation = fcd.Location
}

compressionExtension := fmt.Sprintf(".%s", testProvider.Compression().String())
suiteImageName = strings.TrimSuffix(path.Base(downloadLocation), compressionExtension)
fqImageName = filepath.Join(tmpDir, suiteImageName)
Expand Down

0 comments on commit 38f5ead

Please sign in to comment.