summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-09-11 00:58:46 +0200
committerGitHub <noreply@github.com>2019-09-11 00:58:46 +0200
commit7ac6ed3b4b27621e7aa15da335e65ffa601fb83e (patch)
tree397083da135855ec39a94abd834fefc18079607a /test
parent997c4b56ed2121726e966afe9a102ed16ba78f93 (diff)
parentc2284962c798a11f3c956ee237f27cfd3b0fcb21 (diff)
downloadpodman-7ac6ed3b4b27621e7aa15da335e65ffa601fb83e.tar.gz
podman-7ac6ed3b4b27621e7aa15da335e65ffa601fb83e.tar.bz2
podman-7ac6ed3b4b27621e7aa15da335e65ffa601fb83e.zip
Merge pull request #3581 from mheon/no_cgroups
Support running containers without CGroups
Diffstat (limited to 'test')
-rw-r--r--test/e2e/run_test.go71
1 files changed, 71 insertions, 0 deletions
diff --git a/test/e2e/run_test.go b/test/e2e/run_test.go
index 6e102cfa5..4d2cee8e3 100644
--- a/test/e2e/run_test.go
+++ b/test/e2e/run_test.go
@@ -903,4 +903,75 @@ USER mail`
}
Expect(found).To(BeTrue())
})
+
+ It("podman run with cgroups=disabled runs without cgroups", func() {
+ SkipIfRemote()
+ SkipIfRootless()
+ // Only works on crun
+ if !strings.Contains(podmanTest.OCIRuntime, "crun") {
+ Skip("Test only works on crun")
+ }
+
+ curCgroupsBytes, err := ioutil.ReadFile("/proc/self/cgroup")
+ Expect(err).To(BeNil())
+ var curCgroups string = string(curCgroupsBytes)
+ fmt.Printf("Output:\n%s\n", curCgroups)
+ Expect(curCgroups).To(Not(Equal("")))
+
+ ctrName := "testctr"
+ container := podmanTest.Podman([]string{"run", "--name", ctrName, "-d", "--cgroups=disabled", ALPINE, "top"})
+ container.WaitWithDefaultTimeout()
+ Expect(container.ExitCode()).To(Equal(0))
+
+ // Get PID and get cgroups of that PID
+ inspectOut := podmanTest.InspectContainer(ctrName)
+ Expect(len(inspectOut)).To(Equal(1))
+ pid := inspectOut[0].State.Pid
+ Expect(pid).To(Not(Equal(0)))
+ Expect(inspectOut[0].HostConfig.CgroupParent).To(Equal(""))
+
+ ctrCgroupsBytes, err := ioutil.ReadFile(fmt.Sprintf("/proc/%d/cgroup", pid))
+ Expect(err).To(BeNil())
+ var ctrCgroups string = string(ctrCgroupsBytes)
+ fmt.Printf("Output\n:%s\n", ctrCgroups)
+ Expect(curCgroups).To(Equal(ctrCgroups))
+ })
+
+ It("podman run with cgroups=enabled makes cgroups", func() {
+ SkipIfRemote()
+ SkipIfRootless()
+ // Only works on crun
+ if !strings.Contains(podmanTest.OCIRuntime, "crun") {
+ Skip("Test only works on crun")
+ }
+
+ curCgroupsBytes, err := ioutil.ReadFile("/proc/self/cgroup")
+ Expect(err).To(BeNil())
+ var curCgroups string = string(curCgroupsBytes)
+ fmt.Printf("Output:\n%s\n", curCgroups)
+ Expect(curCgroups).To(Not(Equal("")))
+
+ ctrName := "testctr"
+ container := podmanTest.Podman([]string{"run", "--name", ctrName, "-d", "--cgroups=enabled", ALPINE, "top"})
+ container.WaitWithDefaultTimeout()
+ Expect(container.ExitCode()).To(Equal(0))
+
+ // Get PID and get cgroups of that PID
+ inspectOut := podmanTest.InspectContainer(ctrName)
+ Expect(len(inspectOut)).To(Equal(1))
+ pid := inspectOut[0].State.Pid
+ Expect(pid).To(Not(Equal(0)))
+
+ ctrCgroupsBytes, err := ioutil.ReadFile(fmt.Sprintf("/proc/%d/cgroup", pid))
+ Expect(err).To(BeNil())
+ var ctrCgroups string = string(ctrCgroupsBytes)
+ fmt.Printf("Output\n:%s\n", ctrCgroups)
+ Expect(curCgroups).To(Not(Equal(ctrCgroups)))
+ })
+
+ It("podman run with cgroups=garbage errors", func() {
+ session := podmanTest.Podman([]string{"run", "-d", "--cgroups=garbage", ALPINE, "top"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Not(Equal(0)))
+ })
})