Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add TestRunMemoryOOM test case #1552

Merged
merged 1 commit into from
Jun 22, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions test/cli_run_memory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,12 @@ func (suite *PouchRunMemorySuite) TestRunWithLimitedMemory(c *check.C) {

checkFileContains(c, path, "104857600")
}


// TestRunMemoryOOM is to verify return value when a container is OOM.
func (suite *PouchRunMemorySuite) TestRunMemoryOOM(c *check.C) {
cname := "TestRunMemoryOOM"
ret := command.PouchRun("run", "-m", "20m", "--name", cname, busyboxImage, "sh", "-c", "x=a; while true; do x=$x$x$x$x; done")
defer DelContainerForceMultyTime(c, cname)
ret.Assert(c, icmd.Expected{ExitCode: 137})
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we still need to use API to check whether this container is under OOM state. @sunyuan3
cc @HusterWan

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@allencloud How to check? I don't find other string to show the container is under OOM state expect return value.

#pouch inspect 038341
[
{
"Args": null,
"Created": "2018-06-20T09:00:04.906931671Z",
"ExecIDs": null,
"GraphDriver": {
"Data": {
"MergedDir": "",
"UpperDir": "/home/t4/pouch/containerd/root/io.containerd.snapshotter.v1.overlayfs/snapshots/927/fs"
},
"Name": "overlayfs"
},
"HostConfig": {
"LogConfig": {
"Type": "json-file"
},
"NetworkMode": "none",
"OomScoreAdj": -500,
"RestartPolicy": {
"Name": "no"
},
"Runtime": "runc",
"BlkioDeviceReadBps": null,
"BlkioDeviceReadIOps": null,
"BlkioDeviceWriteBps": null,
"BlkioDeviceWriteIOps": null,
"BlkioWeightDevice": null,
"CgroupParent": "default",
"DeviceCgroupRules": null,
"Devices": [],
"Memory": 4194304,
"MemoryExtra": 0,
"MemorySwappiness": -1,
"MemoryWmarkRatio": 0,
"OomKillDisable": false,
"Ulimits": null
},
"Id": "0383413d557a932dcdd006e5d731959a9dfc6f5feb6acdb50f2e36c5e03976ce",
"Image": "reg.docker.alibaba-inc.com/sunyuan/ubuntu:14.04",
"Mounts": [],
"Name": "038341",
"NetworkSettings": {
"Networks": {
"none": {
"Aliases": null,
"Links": null,
"NetworkID": "65f29c4d3becf916a635ebda8997e36e2e8acd87922c8b2466f3742563014ba1"
}
},
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null
},
"Snapshotter": {
"Data": {
"MergedDir": "",
"UpperDir": "/home/t4/pouch/containerd/root/io.containerd.snapshotter.v1.overlayfs/snapshots/927/fs"
},
"Name": "overlayfs"
},
"State": {
"ExitCode": 137,
"FinishedAt": "2018-06-20T09:01:02.354659891Z",
"Pid": -1,
"StartedAt": "2018-06-20T09:00:05.094187175Z",
"Status": "exited"
},
"Config": {
"Cmd": [
"bash",
"-c",
"x=a; while true; do x=$x$x$x$x; done"
],
"Entrypoint": null,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
"Image": "reg.docker.alibaba-inc.com/sunyuan/ubuntu:14.04",
"OnBuild": null,
"Shell": null
}
}
]

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I discussed with @HusterWan offline. And currently we have no way to be noticed that a container is under OOM. in moby, there is event policy to tell users.

}