Setup cgroups for all subsystems
Fixes #5117 Fixes #5118 Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael) Upstream-commit: 031fcb31d3a81fbd5c5ab8d898d53fbd486413e6 Component: engine
This commit is contained in:
@ -7,7 +7,7 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestTop(t *testing.T) {
|
||||
func TestTopNonPrivileged(t *testing.T) {
|
||||
runCmd := exec.Command(dockerBinary, "run", "-i", "-d", "busybox", "sleep", "20")
|
||||
out, _, err := runCommandWithOutput(runCmd)
|
||||
errorOut(err, t, fmt.Sprintf("failed to start the container: %v", err))
|
||||
@ -28,5 +28,29 @@ func TestTop(t *testing.T) {
|
||||
t.Fatal("top should've listed sleep 20 in the process list")
|
||||
}
|
||||
|
||||
logDone("top - sleep process should be listed")
|
||||
logDone("top - sleep process should be listed in non privileged mode")
|
||||
}
|
||||
|
||||
func TestTopPrivileged(t *testing.T) {
|
||||
runCmd := exec.Command(dockerBinary, "run", "--privileged", "-i", "-d", "busybox", "sleep", "20")
|
||||
out, _, err := runCommandWithOutput(runCmd)
|
||||
errorOut(err, t, fmt.Sprintf("failed to start the container: %v", err))
|
||||
|
||||
cleanedContainerID := stripTrailingCharacters(out)
|
||||
|
||||
topCmd := exec.Command(dockerBinary, "top", cleanedContainerID)
|
||||
out, _, err = runCommandWithOutput(topCmd)
|
||||
errorOut(err, t, fmt.Sprintf("failed to run top: %v %v", out, err))
|
||||
|
||||
killCmd := exec.Command(dockerBinary, "kill", cleanedContainerID)
|
||||
_, err = runCommand(killCmd)
|
||||
errorOut(err, t, fmt.Sprintf("failed to kill container: %v", err))
|
||||
|
||||
deleteContainer(cleanedContainerID)
|
||||
|
||||
if !strings.Contains(out, "sleep 20") {
|
||||
t.Fatal("top should've listed sleep 20 in the process list")
|
||||
}
|
||||
|
||||
logDone("top - sleep process should be listed in privileged mode")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user