mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
initial version of cli integration tests
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
This commit is contained in:
32
integration-cli/docker_cli_top_test.go
Normal file
32
integration-cli/docker_cli_top_test.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestTop(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))
|
||||
|
||||
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))
|
||||
|
||||
go 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")
|
||||
}
|
||||
Reference in New Issue
Block a user