mirror of
https://github.com/containers/podman.git
synced 2025-11-29 17:48:05 +08:00
fix usermode test
Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
This commit is contained in:
@@ -89,7 +89,7 @@ func inspect(cmd *cobra.Command, args []string) error {
|
||||
Resources: mc.Resources,
|
||||
SSHConfig: mc.SSH,
|
||||
State: state,
|
||||
UserModeNetworking: false,
|
||||
UserModeNetworking: provider.UserModeNetworkEnabled(mc),
|
||||
// TODO I think this should be the HostUser
|
||||
Rootful: mc.HostUser.Rootful,
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"github.com/Microsoft/go-winio/vhd"
|
||||
"github.com/containers/libhvee/pkg/hypervctl"
|
||||
"github.com/containers/podman/v5/pkg/machine/define"
|
||||
"github.com/containers/podman/v5/pkg/machine/wsl/wutil"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
. "github.com/onsi/gomega/gexec"
|
||||
@@ -36,6 +37,18 @@ var _ = Describe("podman machine init - windows only", func() {
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(session).To(Exit(0))
|
||||
|
||||
defer func() {
|
||||
_, err := runSystemCommand(wutil.FindWSL(), []string{"--terminate", "podman-net-usermode"}, defaultTimeout, true)
|
||||
if err != nil {
|
||||
fmt.Println("unable to terminate podman-net-usermode")
|
||||
}
|
||||
|
||||
_, err = runSystemCommand(wutil.FindWSL(), []string{"--unregister", "podman-net-usermode"}, defaultTimeout, true)
|
||||
if err != nil {
|
||||
fmt.Println("unable to unregister podman-net-usermode")
|
||||
}
|
||||
}()
|
||||
|
||||
inspect := new(inspectMachine)
|
||||
inspect = inspect.withFormat("{{.UserModeNetworking}}")
|
||||
inspectSession, err := mb.setName(name).setCmd(inspect).run()
|
||||
@@ -81,10 +94,6 @@ var _ = Describe("podman machine init - windows only", func() {
|
||||
It("init should not overwrite existing WSL vms", func() {
|
||||
skipIfNotVmtype(define.WSLVirt, "WSL test only")
|
||||
|
||||
var (
|
||||
wsl string = "wsl"
|
||||
)
|
||||
|
||||
name := randomString()
|
||||
distName := fmt.Sprintf("podman-%s", name)
|
||||
exportedPath := filepath.Join(testDir, "bogus.tar")
|
||||
@@ -102,17 +111,17 @@ var _ = Describe("podman machine init - windows only", func() {
|
||||
// a vm outside the context of podman-machine and also
|
||||
// so we dont have to download a distribution from microsoft
|
||||
// servers
|
||||
exportSession, err := runSystemCommand(wsl, []string{"--export", "podman-foobarexport", exportedPath}, defaultTimeout, true)
|
||||
exportSession, err := runSystemCommand(wutil.FindWSL(), []string{"--export", "podman-foobarexport", exportedPath}, defaultTimeout, true)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(exportSession).To(Exit(0))
|
||||
|
||||
// importing the machine and creating a vm
|
||||
importSession, err := runSystemCommand(wsl, []string{"--import", distName, distrDir, exportedPath}, defaultTimeout, true)
|
||||
importSession, err := runSystemCommand(wutil.FindWSL(), []string{"--import", distName, distrDir, exportedPath}, defaultTimeout, true)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(importSession).To(Exit(0))
|
||||
|
||||
defer func() {
|
||||
_, err := runSystemCommand(wsl, []string{"--unregister", distName}, defaultTimeout, true)
|
||||
_, err := runSystemCommand(wutil.FindWSL(), []string{"--unregister", distName}, defaultTimeout, true)
|
||||
if err != nil {
|
||||
fmt.Println("unable to remove bogus wsl instance")
|
||||
}
|
||||
|
||||
@@ -201,6 +201,7 @@ func teardown(origHomeDir string, testDir string, mb *machineTestBuilder) {
|
||||
GinkgoWriter.Printf("error occurred rm'ing machine: %q\n", err)
|
||||
}
|
||||
}
|
||||
|
||||
if err := utils.GuardedRemoveAll(testDir); err != nil {
|
||||
Fail(fmt.Sprintf("failed to remove test dir: %q", err))
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ func List(vmstubbers []vmconfigs.VMProvider, _ machine.ListOptions) ([]*machine.
|
||||
Port: mc.SSH.Port,
|
||||
RemoteUsername: mc.SSH.RemoteUsername,
|
||||
IdentityPath: mc.SSH.IdentityPath,
|
||||
UserModeNetworking: false, // TODO Need to plumb this for WSL
|
||||
UserModeNetworking: s.UserModeNetworkEnabled(mc),
|
||||
}
|
||||
lrs = append(lrs, &lr)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user