mirror of
https://github.com/containers/podman.git
synced 2025-12-03 19:59:39 +08:00
Merge pull request #21523 from umohnani8/memory-final
Use persist dir for oom file
This commit is contained in:
@@ -70,4 +70,39 @@ var _ = Describe("Podman run memory", func() {
|
||||
Expect(session.OutputToString()).To(Equal(limit))
|
||||
})
|
||||
}
|
||||
|
||||
It("podman run memory test on oomkilled container", func() {
|
||||
mem := SystemExec("cat", []string{"/proc/sys/vm/overcommit_memory"})
|
||||
mem.WaitWithDefaultTimeout()
|
||||
if mem.OutputToString() != "0" {
|
||||
Skip("overcommit memory is not set to 0")
|
||||
}
|
||||
|
||||
ctrName := "oomkilled-ctr"
|
||||
// create a container that gets oomkilled
|
||||
session := podmanTest.Podman([]string{"run", "--name", ctrName, "--read-only", "--memory-swap=20m", "--memory=20m", "--oom-score-adj=1000", ALPINE, "sort", "/dev/urandom"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(ExitWithError())
|
||||
|
||||
inspect := podmanTest.Podman(([]string{"inspect", "--format", "{{.State.OOMKilled}} {{.State.ExitCode}}", ctrName}))
|
||||
inspect.WaitWithDefaultTimeout()
|
||||
Expect(inspect).Should(ExitCleanly())
|
||||
// Check oomkilled and exit code values
|
||||
Expect(inspect.OutputToString()).Should(ContainSubstring("true"))
|
||||
Expect(inspect.OutputToString()).Should(ContainSubstring("137"))
|
||||
})
|
||||
|
||||
It("podman run memory test on successfully exited container", func() {
|
||||
ctrName := "success-ctr"
|
||||
session := podmanTest.Podman([]string{"run", "--name", ctrName, "--memory=40m", ALPINE, "echo", "hello"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(ExitCleanly())
|
||||
|
||||
inspect := podmanTest.Podman(([]string{"inspect", "--format", "{{.State.OOMKilled}} {{.State.ExitCode}}", ctrName}))
|
||||
inspect.WaitWithDefaultTimeout()
|
||||
Expect(inspect).Should(ExitCleanly())
|
||||
// Check oomkilled and exit code values
|
||||
Expect(inspect.OutputToString()).Should(ContainSubstring("false"))
|
||||
Expect(inspect.OutputToString()).Should(ContainSubstring("0"))
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user