summaryrefslogtreecommitdiff
path: root/test/e2e/run_test.go
diff options
context:
space:
mode:
authorGiuseppe Scrivano <gscrivan@redhat.com>2021-09-14 09:57:37 +0200
committerMatthew Heon <mheon@redhat.com>2021-09-16 09:42:14 -0400
commite0881fd5eb655952528536bb89b70fc781b930ce (patch)
tree42a5cea92d895f6760d6a3a5f7660d32fee2c453 /test/e2e/run_test.go
parent74bc365eb6f036a87313ffe5acd3561d3c44638f (diff)
downloadpodman-e0881fd5eb655952528536bb89b70fc781b930ce.tar.gz
podman-e0881fd5eb655952528536bb89b70fc781b930ce.tar.bz2
podman-e0881fd5eb655952528536bb89b70fc781b930ce.zip
tests: simplify --cgroups=disabled test
read the cgroup directly from the container. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Diffstat (limited to 'test/e2e/run_test.go')
-rw-r--r--test/e2e/run_test.go21
1 files changed, 8 insertions, 13 deletions
diff --git a/test/e2e/run_test.go b/test/e2e/run_test.go
index 846da283d..cf1ce699e 100644
--- a/test/e2e/run_test.go
+++ b/test/e2e/run_test.go
@@ -1330,28 +1330,23 @@ USER mail`, BB)
Skip("Test only works on crun")
}
+ trim := func(i string) string {
+ return strings.TrimSuffix(i, "\n")
+ }
+
curCgroupsBytes, err := ioutil.ReadFile("/proc/self/cgroup")
Expect(err).ShouldNot(HaveOccurred())
- var curCgroups = string(curCgroupsBytes)
+ curCgroups := trim(string(curCgroupsBytes))
fmt.Printf("Output:\n%s\n", curCgroups)
Expect(curCgroups).ToNot(Equal(""))
- ctrName := "testctr"
- container := podmanTest.Podman([]string{"run", "--name", ctrName, "-d", "--cgroups=disabled", ALPINE, "top"})
+ container := podmanTest.Podman([]string{"run", "--cgroupns=host", "--cgroups=disabled", ALPINE, "cat", "/proc/self/cgroup"})
container.WaitWithDefaultTimeout()
Expect(container).Should(Exit(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).ToNot(Equal(0))
- Expect(inspectOut[0].HostConfig.CgroupParent).To(Equal(""))
-
- ctrCgroupsBytes, err := ioutil.ReadFile(fmt.Sprintf("/proc/%d/cgroup", pid))
- Expect(err).ShouldNot(HaveOccurred())
- var ctrCgroups = string(ctrCgroupsBytes)
+ ctrCgroups := trim(container.OutputToString())
fmt.Printf("Output\n:%s\n", ctrCgroups)
+
Expect(ctrCgroups).To(Equal(curCgroups))
})