Skip to content

Commit f036476

Browse files
committed
fix usermode test
Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
1 parent 4fffa78 commit f036476

4 files changed

Lines changed: 19 additions & 9 deletions

File tree

cmd/podman/machine/inspect.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func inspect(cmd *cobra.Command, args []string) error {
8989
Resources: mc.Resources,
9090
SSHConfig: mc.SSH,
9191
State: state,
92-
UserModeNetworking: false,
92+
UserModeNetworking: provider.UserModeNetworkEnabled(mc),
9393
// TODO I think this should be the HostUser
9494
Rootful: mc.HostUser.Rootful,
9595
}

pkg/machine/e2e/init_windows_test.go

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"github.com/Microsoft/go-winio/vhd"
99
"github.com/containers/libhvee/pkg/hypervctl"
1010
"github.com/containers/podman/v5/pkg/machine/define"
11+
"github.com/containers/podman/v5/pkg/machine/wsl/wutil"
1112
. "github.com/onsi/ginkgo/v2"
1213
. "github.com/onsi/gomega"
1314
. "github.com/onsi/gomega/gexec"
@@ -36,6 +37,18 @@ var _ = Describe("podman machine init - windows only", func() {
3637
Expect(err).ToNot(HaveOccurred())
3738
Expect(session).To(Exit(0))
3839

40+
defer func() {
41+
_, err := runSystemCommand(wutil.FindWSL(), []string{"--terminate", "podman-net-usermode"}, defaultTimeout, true)
42+
if err != nil {
43+
fmt.Println("unable to terminate podman-net-usermode")
44+
}
45+
46+
_, err = runSystemCommand(wutil.FindWSL(), []string{"--unregister", "podman-net-usermode"}, defaultTimeout, true)
47+
if err != nil {
48+
fmt.Println("unable to unregister podman-net-usermode")
49+
}
50+
}()
51+
3952
inspect := new(inspectMachine)
4053
inspect = inspect.withFormat("{{.UserModeNetworking}}")
4154
inspectSession, err := mb.setName(name).setCmd(inspect).run()
@@ -81,10 +94,6 @@ var _ = Describe("podman machine init - windows only", func() {
8194
It("init should not overwrite existing WSL vms", func() {
8295
skipIfNotVmtype(define.WSLVirt, "WSL test only")
8396

84-
var (
85-
wsl string = "wsl"
86-
)
87-
8897
name := randomString()
8998
distName := fmt.Sprintf("podman-%s", name)
9099
exportedPath := filepath.Join(testDir, "bogus.tar")
@@ -102,17 +111,17 @@ var _ = Describe("podman machine init - windows only", func() {
102111
// a vm outside the context of podman-machine and also
103112
// so we dont have to download a distribution from microsoft
104113
// servers
105-
exportSession, err := runSystemCommand(wsl, []string{"--export", "podman-foobarexport", exportedPath}, defaultTimeout, true)
114+
exportSession, err := runSystemCommand(wutil.FindWSL(), []string{"--export", "podman-foobarexport", exportedPath}, defaultTimeout, true)
106115
Expect(err).ToNot(HaveOccurred())
107116
Expect(exportSession).To(Exit(0))
108117

109118
// importing the machine and creating a vm
110-
importSession, err := runSystemCommand(wsl, []string{"--import", distName, distrDir, exportedPath}, defaultTimeout, true)
119+
importSession, err := runSystemCommand(wutil.FindWSL(), []string{"--import", distName, distrDir, exportedPath}, defaultTimeout, true)
111120
Expect(err).ToNot(HaveOccurred())
112121
Expect(importSession).To(Exit(0))
113122

114123
defer func() {
115-
_, err := runSystemCommand(wsl, []string{"--unregister", distName}, defaultTimeout, true)
124+
_, err := runSystemCommand(wutil.FindWSL(), []string{"--unregister", distName}, defaultTimeout, true)
116125
if err != nil {
117126
fmt.Println("unable to remove bogus wsl instance")
118127
}

pkg/machine/e2e/machine_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ func teardown(origHomeDir string, testDir string, mb *machineTestBuilder) {
201201
GinkgoWriter.Printf("error occurred rm'ing machine: %q\n", err)
202202
}
203203
}
204+
204205
if err := utils.GuardedRemoveAll(testDir); err != nil {
205206
Fail(fmt.Sprintf("failed to remove test dir: %q", err))
206207
}

pkg/machine/shim/host.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func List(vmstubbers []vmconfigs.VMProvider, _ machine.ListOptions) ([]*machine.
5050
Port: mc.SSH.Port,
5151
RemoteUsername: mc.SSH.RemoteUsername,
5252
IdentityPath: mc.SSH.IdentityPath,
53-
UserModeNetworking: false, // TODO Need to plumb this for WSL
53+
UserModeNetworking: s.UserModeNetworkEnabled(mc),
5454
}
5555
lrs = append(lrs, &lr)
5656
}

0 commit comments

Comments
 (0)