github.com/AbhinandanKurakure/podman/v3@v3.4.10/test/e2e/namespace_test.go (about) 1 package integration 2 3 import ( 4 "os" 5 6 . "github.com/containers/podman/v3/test/utils" 7 . "github.com/onsi/ginkgo" 8 . "github.com/onsi/gomega" 9 . "github.com/onsi/gomega/gexec" 10 ) 11 12 var _ = Describe("Podman namespaces", func() { 13 var ( 14 tempdir string 15 err error 16 podmanTest *PodmanTestIntegration 17 ) 18 19 BeforeEach(func() { 20 tempdir, err = CreateTempDirInTempDir() 21 if err != nil { 22 os.Exit(1) 23 } 24 podmanTest = PodmanTestCreate(tempdir) 25 podmanTest.Setup() 26 podmanTest.SeedImages() 27 }) 28 29 AfterEach(func() { 30 podmanTest.Cleanup() 31 f := CurrentGinkgoTestDescription() 32 processTestResult(f) 33 34 }) 35 36 It("podman namespace test", func() { 37 podman1 := podmanTest.Podman([]string{"--namespace", "test1", "run", "-d", ALPINE, "echo", "hello"}) 38 podman1.WaitWithDefaultTimeout() 39 if IsRemote() { 40 // --namespace flag not supported in podman remote 41 Expect(podman1).Should(Exit(125)) 42 Expect(podman1.ErrorToString()).To(ContainSubstring("unknown flag: --namespace")) 43 return 44 } 45 Expect(podman1).Should(Exit(0)) 46 47 podman2 := podmanTest.Podman([]string{"--namespace", "test2", "ps", "-aq"}) 48 podman2.WaitWithDefaultTimeout() 49 Expect(podman2).Should(Exit(0)) 50 output := podman2.OutputToStringArray() 51 numCtrs := 0 52 for _, outputLine := range output { 53 if outputLine != "" { 54 numCtrs = numCtrs + 1 55 } 56 } 57 Expect(numCtrs).To(Equal(0)) 58 59 numberOfCtrsNoNamespace := podmanTest.NumberOfContainers() 60 Expect(numberOfCtrsNoNamespace).To(Equal(1)) 61 }) 62 })