summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGiuseppe Scrivano <gscrivan@redhat.com>2021-02-10 14:46:08 +0100
committerGiuseppe Scrivano <gscrivan@redhat.com>2021-02-12 09:53:47 +0100
commitf74a195e5e90f7bae51fc160c168c0233835ef08 (patch)
tree2410dc356ad730af1235900af751797bc7a5732b /test
parent66dc8355df0904a6ef1e3abe6808d95348c07d93 (diff)
downloadpodman-f74a195e5e90f7bae51fc160c168c0233835ef08.tar.gz
podman-f74a195e5e90f7bae51fc160c168c0233835ef08.tar.bz2
podman-f74a195e5e90f7bae51fc160c168c0233835ef08.zip
utils: takes the longest path on cgroup v1
now getCgroupProcess takes the longest path on cgroup v1, instead of complaining if the paths are different. This should help when --cgroups=split is used on cgroup v1 and the process cgroups look like: $ cat /proc/self/cgroup 11:pids:/user.slice/user-0.slice/session-4.scope 10:blkio:/ 9:cpuset:/ 8:devices:/user.slice 7:freezer:/ 6:memory:/user.slice/user-0.slice/session-4.scope 5:net_cls,net_prio:/ 4:hugetlb:/ 3:cpu,cpuacct:/ 2:perf_event:/ Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com> (cherry picked from commit 660a06f2f79fc1edf68e286ee452ceb9dcd5e03a)
Diffstat (limited to 'test')
-rw-r--r--test/e2e/common_test.go7
-rw-r--r--test/e2e/run_test.go31
2 files changed, 38 insertions, 0 deletions
diff --git a/test/e2e/common_test.go b/test/e2e/common_test.go
index a870117d9..8a452f340 100644
--- a/test/e2e/common_test.go
+++ b/test/e2e/common_test.go
@@ -600,6 +600,13 @@ func SkipIfNotRootless(reason string) {
}
}
+func SkipIfNotSystemd(manager, reason string) {
+ checkReason(reason)
+ if manager != "systemd" {
+ ginkgo.Skip("[notSystemd]: " + reason)
+ }
+}
+
func SkipIfNotFedora() {
info := GetHostDistributionInfo()
if info.Distribution != "fedora" {
diff --git a/test/e2e/run_test.go b/test/e2e/run_test.go
index 19060ecdc..7d367cccf 100644
--- a/test/e2e/run_test.go
+++ b/test/e2e/run_test.go
@@ -1185,6 +1185,37 @@ USER mail`
Expect(found).To(BeTrue())
})
+ It("podman run with cgroups=split", func() {
+ SkipIfNotSystemd(podmanTest.CgroupManager, "do not test --cgroups=split if not running on systemd")
+ SkipIfRootlessCgroupsV1("Disable cgroups not supported on cgroupv1 for rootless users")
+ SkipIfRemote("--cgroups=split cannot be used in remote mode")
+
+ container := podmanTest.Podman([]string{"run", "--rm", "--cgroups=split", ALPINE, "cat", "/proc/self/cgroup"})
+ container.WaitWithDefaultTimeout()
+ Expect(container.ExitCode()).To(Equal(0))
+ lines := container.OutputToStringArray()
+
+ cgroup := ""
+ for _, line := range lines {
+ parts := strings.SplitN(line, ":", 3)
+ if !CGROUPSV2 {
+ // ignore unified on cgroup v1
+ // both runc and crun do not set it.
+ if parts[1] == "" {
+ continue
+ }
+ }
+ if parts[2] == "/" {
+ continue
+ }
+ if cgroup == "" {
+ cgroup = parts[2]
+ continue
+ }
+ Expect(cgroup).To(Equal(parts[2]))
+ }
+ })
+
It("podman run with cgroups=disabled runs without cgroups", func() {
SkipIfRootless("FIXME: I believe this should work but need to fix this test")
SkipIfRootlessCgroupsV1("Disable cgroups not supported on cgroupv1 for rootless users")