|
@@ -16,12 +16,6 @@ import (
|
|
"github.com/go-check/check"
|
|
"github.com/go-check/check"
|
|
)
|
|
)
|
|
|
|
|
|
-func init() {
|
|
|
|
- if daemonPlatform == "windows" {
|
|
|
|
- sleepCmd = "sleep"
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
func (s *DockerSuite) TestPsListContainersBase(c *check.C) {
|
|
func (s *DockerSuite) TestPsListContainersBase(c *check.C) {
|
|
// Problematic on Windows as busybox doesn't support top
|
|
// Problematic on Windows as busybox doesn't support top
|
|
testRequires(c, DaemonIsLinux)
|
|
testRequires(c, DaemonIsLinux)
|
|
@@ -220,7 +214,7 @@ func (s *DockerSuite) TestPsListContainersFilterID(c *check.C) {
|
|
firstID := strings.TrimSpace(out)
|
|
firstID := strings.TrimSpace(out)
|
|
|
|
|
|
// start another container
|
|
// start another container
|
|
- dockerCmd(c, "run", "-d", "busybox", sleepCmd, "60")
|
|
|
|
|
|
+ runSleepingContainer(c)
|
|
|
|
|
|
// filter containers by id
|
|
// filter containers by id
|
|
out, _ = dockerCmd(c, "ps", "-a", "-q", "--filter=id="+firstID)
|
|
out, _ = dockerCmd(c, "ps", "-a", "-q", "--filter=id="+firstID)
|
|
@@ -235,7 +229,7 @@ func (s *DockerSuite) TestPsListContainersFilterName(c *check.C) {
|
|
firstID := strings.TrimSpace(out)
|
|
firstID := strings.TrimSpace(out)
|
|
|
|
|
|
// start another container
|
|
// start another container
|
|
- dockerCmd(c, "run", "-d", "--name=b_name_to_match", "busybox", sleepCmd, "60")
|
|
|
|
|
|
+ runSleepingContainer(c, "--name=b_name_to_match")
|
|
|
|
|
|
// filter containers by name
|
|
// filter containers by name
|
|
out, _ = dockerCmd(c, "ps", "-a", "-q", "--filter=name=a_name_to_match")
|
|
out, _ = dockerCmd(c, "ps", "-a", "-q", "--filter=name=a_name_to_match")
|
|
@@ -386,7 +380,7 @@ func (s *DockerSuite) TestPsListContainersFilterLabel(c *check.C) {
|
|
func (s *DockerSuite) TestPsListContainersFilterExited(c *check.C) {
|
|
func (s *DockerSuite) TestPsListContainersFilterExited(c *check.C) {
|
|
// TODO Windows CI: Enable for TP5. Fails on TP4
|
|
// TODO Windows CI: Enable for TP5. Fails on TP4
|
|
testRequires(c, DaemonIsLinux)
|
|
testRequires(c, DaemonIsLinux)
|
|
- dockerCmd(c, "run", "-d", "--name", "sleep", "busybox", sleepCmd, "60")
|
|
|
|
|
|
+ runSleepingContainer(c, "--name=sleep")
|
|
|
|
|
|
dockerCmd(c, "run", "--name", "zero1", "busybox", "true")
|
|
dockerCmd(c, "run", "--name", "zero1", "busybox", "true")
|
|
firstZero, err := getIDByName("zero1")
|
|
firstZero, err := getIDByName("zero1")
|
|
@@ -429,11 +423,11 @@ func (s *DockerSuite) TestPsRightTagName(c *check.C) {
|
|
dockerCmd(c, "tag", "busybox", tag)
|
|
dockerCmd(c, "tag", "busybox", tag)
|
|
|
|
|
|
var id1 string
|
|
var id1 string
|
|
- out, _ := dockerCmd(c, "run", "-d", "busybox", sleepCmd, "60")
|
|
|
|
|
|
+ out, _ := runSleepingContainer(c)
|
|
id1 = strings.TrimSpace(string(out))
|
|
id1 = strings.TrimSpace(string(out))
|
|
|
|
|
|
var id2 string
|
|
var id2 string
|
|
- out, _ = dockerCmd(c, "run", "-d", tag, sleepCmd, "60")
|
|
|
|
|
|
+ out, _ = runSleepingContainerInImage(c, tag)
|
|
id2 = strings.TrimSpace(string(out))
|
|
id2 = strings.TrimSpace(string(out))
|
|
|
|
|
|
var imageID string
|
|
var imageID string
|
|
@@ -441,7 +435,7 @@ func (s *DockerSuite) TestPsRightTagName(c *check.C) {
|
|
imageID = strings.TrimSpace(string(out))
|
|
imageID = strings.TrimSpace(string(out))
|
|
|
|
|
|
var id3 string
|
|
var id3 string
|
|
- out, _ = dockerCmd(c, "run", "-d", imageID, sleepCmd, "60")
|
|
|
|
|
|
+ out, _ = runSleepingContainerInImage(c, imageID)
|
|
id3 = strings.TrimSpace(string(out))
|
|
id3 = strings.TrimSpace(string(out))
|
|
|
|
|
|
out, _ = dockerCmd(c, "ps", "--no-trunc")
|
|
out, _ = dockerCmd(c, "ps", "--no-trunc")
|
|
@@ -467,8 +461,8 @@ func (s *DockerSuite) TestPsRightTagName(c *check.C) {
|
|
func (s *DockerSuite) TestPsLinkedWithNoTrunc(c *check.C) {
|
|
func (s *DockerSuite) TestPsLinkedWithNoTrunc(c *check.C) {
|
|
// Problematic on Windows as it doesn't support links as of Jan 2016
|
|
// Problematic on Windows as it doesn't support links as of Jan 2016
|
|
testRequires(c, DaemonIsLinux)
|
|
testRequires(c, DaemonIsLinux)
|
|
- dockerCmd(c, "run", "--name=first", "-d", "busybox", sleepCmd, "60")
|
|
|
|
- dockerCmd(c, "run", "--name=second", "--link=first:first", "-d", "busybox", sleepCmd, "60")
|
|
|
|
|
|
+ runSleepingContainer(c, "--name=first")
|
|
|
|
+ runSleepingContainer(c, "--name=second", "--link=first:first")
|
|
|
|
|
|
out, _ := dockerCmd(c, "ps", "--no-trunc")
|
|
out, _ := dockerCmd(c, "ps", "--no-trunc")
|
|
lines := strings.Split(strings.TrimSpace(string(out)), "\n")
|
|
lines := strings.Split(strings.TrimSpace(string(out)), "\n")
|
|
@@ -569,7 +563,7 @@ func (s *DockerSuite) TestPsFormatHeaders(c *check.C) {
|
|
c.Assert(out, checker.Equals, "CONTAINER ID\n", check.Commentf(`Expected 'CONTAINER ID\n', got %v`, out))
|
|
c.Assert(out, checker.Equals, "CONTAINER ID\n", check.Commentf(`Expected 'CONTAINER ID\n', got %v`, out))
|
|
|
|
|
|
// verify that "docker ps" with a container still prints the header row also
|
|
// verify that "docker ps" with a container still prints the header row also
|
|
- dockerCmd(c, "run", "--name=test", "-d", "busybox", sleepCmd, "60")
|
|
|
|
|
|
+ runSleepingContainer(c, "--name=test")
|
|
out, _ = dockerCmd(c, "ps", "--format", "table {{.Names}}")
|
|
out, _ = dockerCmd(c, "ps", "--format", "table {{.Names}}")
|
|
c.Assert(out, checker.Equals, "NAMES\ntest\n", check.Commentf(`Expected 'NAMES\ntest\n', got %v`, out))
|
|
c.Assert(out, checker.Equals, "NAMES\ntest\n", check.Commentf(`Expected 'NAMES\ntest\n', got %v`, out))
|
|
}
|
|
}
|
|
@@ -585,7 +579,7 @@ func (s *DockerSuite) TestPsDefaultFormatAndQuiet(c *check.C) {
|
|
err = ioutil.WriteFile(filepath.Join(d, "config.json"), []byte(config), 0644)
|
|
err = ioutil.WriteFile(filepath.Join(d, "config.json"), []byte(config), 0644)
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
|
|
- out, _ := dockerCmd(c, "run", "--name=test", "-d", "busybox", sleepCmd, "60")
|
|
|
|
|
|
+ out, _ := runSleepingContainer(c, "--name=test")
|
|
id := strings.TrimSpace(out)
|
|
id := strings.TrimSpace(out)
|
|
|
|
|
|
out, _ = dockerCmd(c, "--config", d, "ps", "-q")
|
|
out, _ = dockerCmd(c, "--config", d, "ps", "-q")
|
|
@@ -606,7 +600,7 @@ func (s *DockerSuite) TestPsImageIDAfterUpdate(c *check.C) {
|
|
originalImageID, err := getIDByName(originalImageName)
|
|
originalImageID, err := getIDByName(originalImageName)
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
|
|
- runCmd = exec.Command(dockerBinary, "run", "-d", originalImageName, sleepCmd, "60")
|
|
|
|
|
|
+ runCmd = exec.Command(dockerBinary, append([]string{"run", "-d", originalImageName}, defaultSleepCommand...)...)
|
|
out, _, err = runCommandWithOutput(runCmd)
|
|
out, _, err = runCommandWithOutput(runCmd)
|
|
c.Assert(err, checker.IsNil)
|
|
c.Assert(err, checker.IsNil)
|
|
containerID := strings.TrimSpace(out)
|
|
containerID := strings.TrimSpace(out)
|