github.com/containers/libpod@v1.9.4-0.20220419124438-4284fd425507/test/e2e/run_cgroup_parent_test.go (about) 1 // +build !remoteclient 2 3 package integration 4 5 import ( 6 "os" 7 8 . "github.com/containers/libpod/test/utils" 9 . "github.com/onsi/ginkgo" 10 . "github.com/onsi/gomega" 11 ) 12 13 var _ = Describe("Podman run with --cgroup-parent", func() { 14 var ( 15 tempdir string 16 err error 17 podmanTest *PodmanTestIntegration 18 ) 19 20 BeforeEach(func() { 21 SkipIfRootless() 22 tempdir, err = CreateTempDirInTempDir() 23 if err != nil { 24 os.Exit(1) 25 } 26 podmanTest = PodmanTestCreate(tempdir) 27 podmanTest.Setup() 28 podmanTest.SeedImages() 29 }) 30 31 AfterEach(func() { 32 podmanTest.Cleanup() 33 f := CurrentGinkgoTestDescription() 34 processTestResult(f) 35 36 }) 37 38 Specify("valid --cgroup-parent using cgroupfs", func() { 39 if !Containerized() { 40 Skip("Must be containerized to run this test.") 41 } 42 cgroup := "/zzz" 43 run := podmanTest.Podman([]string{"run", "--cgroupns=host", "--cgroup-parent", cgroup, fedoraMinimal, "cat", "/proc/self/cgroup"}) 44 run.WaitWithDefaultTimeout() 45 Expect(run.ExitCode()).To(Equal(0)) 46 ok, _ := run.GrepString(cgroup) 47 Expect(ok).To(BeTrue()) 48 }) 49 50 Specify("no --cgroup-parent", func() { 51 cgroup := "/libpod_parent" 52 if !Containerized() && podmanTest.CgroupManager != "cgroupfs" { 53 cgroup = "/machine.slice" 54 } 55 run := podmanTest.Podman([]string{"run", "--cgroupns=host", fedoraMinimal, "cat", "/proc/self/cgroup"}) 56 run.WaitWithDefaultTimeout() 57 Expect(run.ExitCode()).To(Equal(0)) 58 ok, _ := run.GrepString(cgroup) 59 Expect(ok).To(BeTrue()) 60 }) 61 62 Specify("valid --cgroup-parent using slice", func() { 63 if Containerized() || podmanTest.CgroupManager == "cgroupfs" { 64 Skip("Requires Systemd cgroup manager support") 65 } 66 cgroup := "aaaa.slice" 67 run := podmanTest.Podman([]string{"run", "--cgroupns=host", "--cgroup-parent", cgroup, fedoraMinimal, "cat", "/proc/1/cgroup"}) 68 run.WaitWithDefaultTimeout() 69 Expect(run.ExitCode()).To(Equal(0)) 70 ok, _ := run.GrepString(cgroup) 71 Expect(ok).To(BeTrue()) 72 }) 73 })