mirror of
https://github.com/containers/podman.git
synced 2025-10-15 18:23:30 +08:00
test/e2e: unshare --rootless-netns cleanup slirp4netns
podman unshare --rootless-netns leaks the namespace and slirp4netns by design as there is no safe way to remove it without any races. To trigger a cleanup we can spin up a container and it will automaticallt teardown the netns for us. Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
@ -9,6 +9,14 @@ import (
|
||||
. "github.com/onsi/gomega/gexec"
|
||||
)
|
||||
|
||||
// podman unshare --rootless-netns leaks the process by design.
|
||||
// Running a container will cause the cleanup to kick in when this container gets stopped.
|
||||
func cleanupRootlessSlirp4netns(p *PodmanTestIntegration) {
|
||||
session := p.Podman([]string{"run", "--network", "bridge", ALPINE, "true"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Exit(0))
|
||||
}
|
||||
|
||||
var _ = Describe("Podman unshare", func() {
|
||||
var (
|
||||
tempdir string
|
||||
@ -49,8 +57,9 @@ var _ = Describe("Podman unshare", func() {
|
||||
Expect(session.OutputToString()).ToNot(ContainSubstring(userNS))
|
||||
})
|
||||
|
||||
It("podman unshare --rootless-cni", func() {
|
||||
It("podman unshare --rootless-netns", func() {
|
||||
SkipIfRemote("podman-remote unshare is not supported")
|
||||
defer cleanupRootlessSlirp4netns(podmanTest)
|
||||
session := podmanTest.Podman([]string{"unshare", "--rootless-netns", "ip", "addr"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Exit(0))
|
||||
|
Reference in New Issue
Block a user