Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -5,6 +5,7 @@ import ( |
| 5 | 5 |
"strings" |
| 6 | 6 |
"testing" |
| 7 | 7 |
|
| 8 |
+ "github.com/docker/docker/integration-cli/cli" |
|
| 8 | 9 |
"gotest.tools/v3/assert" |
| 9 | 10 |
"gotest.tools/v3/icmd" |
| 10 | 11 |
) |
| ... | ... |
@@ -32,7 +33,7 @@ func (s *DockerCLITopSuite) TestTopMultipleArgs(c *testing.T) {
|
| 32 | 32 |
default: |
| 33 | 33 |
expected = icmd.Expected{Out: "PID"}
|
| 34 | 34 |
} |
| 35 |
- result := dockerCmdWithResult("top", cleanedContainerID, "-o", "pid")
|
|
| 35 |
+ result := cli.Docker(cli.Args("top", cleanedContainerID, "-o", "pid"))
|
|
| 36 | 36 |
result.Assert(c, expected) |
| 37 | 37 |
} |
| 38 | 38 |
|
| ... | ... |
@@ -40,9 +41,9 @@ func (s *DockerCLITopSuite) TestTopNonPrivileged(c *testing.T) {
|
| 40 | 40 |
out := runSleepingContainer(c, "-d") |
| 41 | 41 |
cleanedContainerID := strings.TrimSpace(out) |
| 42 | 42 |
|
| 43 |
- out1, _ := dockerCmd(c, "top", cleanedContainerID) |
|
| 44 |
- out2, _ := dockerCmd(c, "top", cleanedContainerID) |
|
| 45 |
- dockerCmd(c, "kill", cleanedContainerID) |
|
| 43 |
+ out1 := cli.DockerCmd(c, "top", cleanedContainerID).Combined() |
|
| 44 |
+ out2 := cli.DockerCmd(c, "top", cleanedContainerID).Combined() |
|
| 45 |
+ cli.DockerCmd(c, "kill", cleanedContainerID) |
|
| 46 | 46 |
|
| 47 | 47 |
// Windows will list the name of the launched executable which in this case is busybox.exe, without the parameters. |
| 48 | 48 |
// Linux will display the command executed in the container |
| ... | ... |
@@ -62,9 +63,8 @@ func (s *DockerCLITopSuite) TestTopNonPrivileged(c *testing.T) {
|
| 62 | 62 |
// very different to Linux in this regard. |
| 63 | 63 |
func (s *DockerCLITopSuite) TestTopWindowsCoreProcesses(c *testing.T) {
|
| 64 | 64 |
testRequires(c, DaemonIsWindows) |
| 65 |
- out := runSleepingContainer(c, "-d") |
|
| 66 |
- cleanedContainerID := strings.TrimSpace(out) |
|
| 67 |
- out1, _ := dockerCmd(c, "top", cleanedContainerID) |
|
| 65 |
+ cID := runSleepingContainer(c, "-d") |
|
| 66 |
+ out1 := cli.DockerCmd(c, "top", cID).Combined() |
|
| 68 | 67 |
lookingFor := []string{"smss.exe", "csrss.exe", "wininit.exe", "services.exe", "lsass.exe", "CExecSvc.exe"}
|
| 69 | 68 |
for i, s := range lookingFor {
|
| 70 | 69 |
assert.Assert(c, strings.Contains(out1, s), "top should've listed `%s` in the process list, but failed. Test case %d", s, i) |
| ... | ... |
@@ -74,12 +74,12 @@ func (s *DockerCLITopSuite) TestTopWindowsCoreProcesses(c *testing.T) {
|
| 74 | 74 |
func (s *DockerCLITopSuite) TestTopPrivileged(c *testing.T) {
|
| 75 | 75 |
// Windows does not support --privileged |
| 76 | 76 |
testRequires(c, DaemonIsLinux, NotUserNamespace) |
| 77 |
- out, _ := dockerCmd(c, "run", "--privileged", "-i", "-d", "busybox", "top") |
|
| 78 |
- cleanedContainerID := strings.TrimSpace(out) |
|
| 77 |
+ cID := cli.DockerCmd(c, "run", "--privileged", "-i", "-d", "busybox", "top").Stdout() |
|
| 78 |
+ cID = strings.TrimSpace(cID) |
|
| 79 | 79 |
|
| 80 |
- out1, _ := dockerCmd(c, "top", cleanedContainerID) |
|
| 81 |
- out2, _ := dockerCmd(c, "top", cleanedContainerID) |
|
| 82 |
- dockerCmd(c, "kill", cleanedContainerID) |
|
| 80 |
+ out1 := cli.DockerCmd(c, "top", cID).Combined() |
|
| 81 |
+ out2 := cli.DockerCmd(c, "top", cID).Combined() |
|
| 82 |
+ cli.DockerCmd(c, "kill", cID) |
|
| 83 | 83 |
|
| 84 | 84 |
assert.Assert(c, strings.Contains(out1, "top"), "top should've listed `top` in the process list, but failed the first time") |
| 85 | 85 |
assert.Assert(c, strings.Contains(out2, "top"), "top should've listed `top` in the process list, but failed the second time") |