diff options
author | Valentin Rothberg <rothberg@redhat.com> | 2020-11-10 13:31:19 +0100 |
---|---|---|
committer | Valentin Rothberg <rothberg@redhat.com> | 2020-11-17 12:29:50 +0100 |
commit | 39bf07694c5716cce3cb7e25c6d01b441b6b4e01 (patch) | |
tree | 4afffd1c244936ba54bff308e6df1373dea896d4 /test/e2e/stats_test.go | |
parent | 3502860e1cfe1042aca7a8de8446360662a5a2fd (diff) | |
download | podman-39bf07694c5716cce3cb7e25c6d01b441b6b4e01.tar.gz podman-39bf07694c5716cce3cb7e25c6d01b441b6b4e01.tar.bz2 podman-39bf07694c5716cce3cb7e25c6d01b441b6b4e01.zip |
use container cgroups path
When looking up a container's cgroup path, parse /proc/[PID]/cgroup.
This will work across all cgroup managers and configurations and is
supported on cgroups v1 and v2.
Fixes: #8265
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Diffstat (limited to 'test/e2e/stats_test.go')
-rw-r--r-- | test/e2e/stats_test.go | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/test/e2e/stats_test.go b/test/e2e/stats_test.go index c8f5efa9d..5e8a7a3d0 100644 --- a/test/e2e/stats_test.go +++ b/test/e2e/stats_test.go @@ -5,6 +5,7 @@ package integration import ( "fmt" "os" + "strconv" "time" . "github.com/containers/podman/v2/test/utils" @@ -126,4 +127,44 @@ var _ = Describe("Podman stats", func() { session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) }) + + // Regression test for #8265 + It("podman stats with custom memory limits", func() { + // Run thre containers. One with a memory limit. Make sure + // that the limits are different and the limited one has a + // lower limit. + ctrNoLimit0 := "no-limit-0" + ctrNoLimit1 := "no-limit-1" + ctrWithLimit := "with-limit" + + session := podmanTest.Podman([]string{"run", "-d", "--name", ctrNoLimit0, ALPINE, "top"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + session = podmanTest.Podman([]string{"run", "-d", "--name", ctrNoLimit1, ALPINE, "top"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + session = podmanTest.Podman([]string{"run", "-d", "--name", ctrWithLimit, "--memory", "50m", ALPINE, "top"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + session = podmanTest.Podman([]string{"stats", "--no-stream", "--format", "{{.MemLimit}}", ctrNoLimit0, ctrNoLimit1, ctrWithLimit}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + // We have three containers. The unlimited ones need to have + // the same limit, the limited one a lower one. + limits := session.OutputToStringArray() + Expect(len(limits)).To(BeNumerically("==", 3)) + Expect(limits[0]).To(Equal(limits[1])) + Expect(limits[0]).ToNot(Equal(limits[2])) + + defaultLimit, err := strconv.Atoi(limits[0]) + Expect(err).To(BeNil()) + customLimit, err := strconv.Atoi(limits[2]) + Expect(err).To(BeNil()) + + Expect(customLimit).To(BeNumerically("<", defaultLimit)) + }) }) |