github.com/containers/podman/v5@v5.1.0-rc1/test/e2e/pod_pod_namespaces_test.go (about)

     1  package integration
     2  
     3  import (
     4  	. "github.com/containers/podman/v5/test/utils"
     5  	. "github.com/onsi/ginkgo/v2"
     6  	. "github.com/onsi/gomega"
     7  )
     8  
     9  var _ = Describe("Podman pod create", func() {
    10  
    11  	It("podman pod container share Namespaces", func() {
    12  		session := podmanTest.Podman([]string{"pod", "create"})
    13  		session.WaitWithDefaultTimeout()
    14  		Expect(session).Should(ExitCleanly())
    15  		podID := session.OutputToString()
    16  
    17  		session = podmanTest.Podman([]string{"pod", "start", podID})
    18  		session.WaitWithDefaultTimeout()
    19  		Expect(session).Should(ExitCleanly())
    20  
    21  		session = podmanTest.Podman([]string{"run", "--pod", podID, "-d", ALPINE, "top"})
    22  		session.WaitWithDefaultTimeout()
    23  		Expect(session).Should(ExitCleanly())
    24  
    25  		check := podmanTest.Podman([]string{"ps", "-a", "--ns", "--format", "{{.Namespaces.IPC}} {{.Namespaces.UTS}} {{.Namespaces.NET}}"})
    26  		check.WaitWithDefaultTimeout()
    27  		Expect(check).Should(ExitCleanly())
    28  		outputArray := check.OutputToStringArray()
    29  		Expect(outputArray).To(HaveLen(2))
    30  
    31  		NAMESPACE1 := outputArray[0]
    32  		GinkgoWriter.Println("NAMESPACE1:", NAMESPACE1)
    33  		NAMESPACE2 := outputArray[1]
    34  		GinkgoWriter.Println("NAMESPACE2:", NAMESPACE2)
    35  		Expect(NAMESPACE1).To(Equal(NAMESPACE2))
    36  	})
    37  
    38  	It("podman pod container share ipc && /dev/shm ", func() {
    39  		session := podmanTest.Podman([]string{"pod", "create"})
    40  		session.WaitWithDefaultTimeout()
    41  		Expect(session).Should(ExitCleanly())
    42  		podID := session.OutputToString()
    43  
    44  		session = podmanTest.Podman([]string{"pod", "start", podID})
    45  		session.WaitWithDefaultTimeout()
    46  		Expect(session).Should(ExitCleanly())
    47  
    48  		session = podmanTest.Podman([]string{"run", "--rm", "--pod", podID, ALPINE, "touch", "/dev/shm/test"})
    49  		session.WaitWithDefaultTimeout()
    50  		Expect(session).Should(ExitCleanly())
    51  
    52  		session = podmanTest.Podman([]string{"run", "--rm", "--pod", podID, ALPINE, "ls", "/dev/shm/test"})
    53  		session.WaitWithDefaultTimeout()
    54  		Expect(session).Should(ExitCleanly())
    55  	})
    56  
    57  	It("podman pod container dontshare PIDNS", func() {
    58  		session := podmanTest.Podman([]string{"pod", "create"})
    59  		session.WaitWithDefaultTimeout()
    60  		Expect(session).Should(ExitCleanly())
    61  		podID := session.OutputToString()
    62  
    63  		session = podmanTest.Podman([]string{"pod", "start", podID})
    64  		session.WaitWithDefaultTimeout()
    65  		Expect(session).Should(ExitCleanly())
    66  
    67  		session = podmanTest.Podman([]string{"run", "--pod", podID, "-d", ALPINE, "top"})
    68  		session.WaitWithDefaultTimeout()
    69  		Expect(session).Should(ExitCleanly())
    70  
    71  		check := podmanTest.Podman([]string{"ps", "-a", "--ns", "--format", "{{.Namespaces.PIDNS}}"})
    72  		check.WaitWithDefaultTimeout()
    73  		Expect(check).Should(ExitCleanly())
    74  		outputArray := check.OutputToStringArray()
    75  		Expect(outputArray).To(HaveLen(2))
    76  
    77  		NAMESPACE1 := outputArray[0]
    78  		GinkgoWriter.Println("NAMESPACE1:", NAMESPACE1)
    79  		NAMESPACE2 := outputArray[1]
    80  		GinkgoWriter.Println("NAMESPACE2:", NAMESPACE2)
    81  		Expect(NAMESPACE1).To(Not(Equal(NAMESPACE2)))
    82  	})
    83  
    84  })