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 }
0 commit comments