mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #32647 from vdemeester/integration-runSleepingContainer-using-cli
[integration] make runSleepingContainer use cli package
This commit is contained in:
commit
3482b45e60
19 changed files with 61 additions and 71 deletions
|
@ -212,7 +212,7 @@ func (s *DockerSuite) TestGetContainerStats(c *check.C) {
|
|||
}
|
||||
|
||||
func (s *DockerSuite) TestGetContainerStatsRmRunning(c *check.C) {
|
||||
out, _ := runSleepingContainer(c)
|
||||
out := runSleepingContainer(c)
|
||||
id := strings.TrimSpace(out)
|
||||
|
||||
buf := &testutil.ChannelBuffer{C: make(chan []byte, 1)}
|
||||
|
@ -401,7 +401,7 @@ func (s *DockerSuite) TestContainerAPITop(c *check.C) {
|
|||
|
||||
func (s *DockerSuite) TestContainerAPITopWindows(c *check.C) {
|
||||
testRequires(c, DaemonIsWindows)
|
||||
out, _ := runSleepingContainer(c, "-d")
|
||||
out := runSleepingContainer(c, "-d")
|
||||
id := strings.TrimSpace(string(out))
|
||||
c.Assert(waitRun(id), checker.IsNil)
|
||||
|
||||
|
@ -892,7 +892,7 @@ func (s *DockerSuite) TestContainerAPIRestart(c *check.C) {
|
|||
|
||||
func (s *DockerSuite) TestContainerAPIRestartNotimeoutParam(c *check.C) {
|
||||
name := "test-api-restart-no-timeout-param"
|
||||
out, _ := runSleepingContainer(c, "-di", "--name", name)
|
||||
out := runSleepingContainer(c, "-di", "--name", name)
|
||||
id := strings.TrimSpace(out)
|
||||
c.Assert(waitRun(id), checker.IsNil)
|
||||
|
||||
|
@ -1047,7 +1047,7 @@ func (s *DockerSuite) TestContainerAPICopyContainerNotFoundPr124(c *check.C) {
|
|||
}
|
||||
|
||||
func (s *DockerSuite) TestContainerAPIDelete(c *check.C) {
|
||||
out, _ := runSleepingContainer(c)
|
||||
out := runSleepingContainer(c)
|
||||
|
||||
id := strings.TrimSpace(out)
|
||||
c.Assert(waitRun(id), checker.IsNil)
|
||||
|
@ -1067,7 +1067,7 @@ func (s *DockerSuite) TestContainerAPIDeleteNotExist(c *check.C) {
|
|||
}
|
||||
|
||||
func (s *DockerSuite) TestContainerAPIDeleteForce(c *check.C) {
|
||||
out, _ := runSleepingContainer(c)
|
||||
out := runSleepingContainer(c)
|
||||
|
||||
id := strings.TrimSpace(out)
|
||||
c.Assert(waitRun(id), checker.IsNil)
|
||||
|
@ -1102,7 +1102,7 @@ func (s *DockerSuite) TestContainerAPIDeleteRemoveLinks(c *check.C) {
|
|||
}
|
||||
|
||||
func (s *DockerSuite) TestContainerAPIDeleteConflict(c *check.C) {
|
||||
out, _ := runSleepingContainer(c)
|
||||
out := runSleepingContainer(c)
|
||||
|
||||
id := strings.TrimSpace(out)
|
||||
c.Assert(waitRun(id), checker.IsNil)
|
||||
|
@ -1120,7 +1120,7 @@ func (s *DockerSuite) TestContainerAPIDeleteRemoveVolume(c *check.C) {
|
|||
vol = `c:\testvolume`
|
||||
}
|
||||
|
||||
out, _ := runSleepingContainer(c, "-v", vol)
|
||||
out := runSleepingContainer(c, "-v", vol)
|
||||
|
||||
id := strings.TrimSpace(out)
|
||||
c.Assert(waitRun(id), checker.IsNil)
|
||||
|
@ -1158,7 +1158,7 @@ func (s *DockerSuite) TestContainerAPIChunkedEncoding(c *check.C) {
|
|||
}
|
||||
|
||||
func (s *DockerSuite) TestContainerAPIPostContainerStop(c *check.C) {
|
||||
out, _ := runSleepingContainer(c)
|
||||
out := runSleepingContainer(c)
|
||||
|
||||
containerID := strings.TrimSpace(out)
|
||||
c.Assert(waitRun(containerID), checker.IsNil)
|
||||
|
|
|
@ -40,7 +40,7 @@ func (s *DockerSuite) TestEventsAPIBackwardsCompatible(c *check.C) {
|
|||
since := daemonTime(c).Unix()
|
||||
ts := strconv.FormatInt(since, 10)
|
||||
|
||||
out, _ := runSleepingContainer(c, "--name=foo", "-d")
|
||||
out := runSleepingContainer(c, "--name=foo", "-d")
|
||||
containerID := strings.TrimSpace(out)
|
||||
c.Assert(waitRun(containerID), checker.IsNil)
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
)
|
||||
|
||||
func (s *DockerSuite) TestResizeAPIResponse(c *check.C) {
|
||||
out, _ := runSleepingContainer(c, "-d")
|
||||
out := runSleepingContainer(c, "-d")
|
||||
cleanedContainerID := strings.TrimSpace(out)
|
||||
|
||||
endpoint := "/containers/" + cleanedContainerID + "/resize?h=40&w=40"
|
||||
|
@ -20,7 +20,7 @@ func (s *DockerSuite) TestResizeAPIResponse(c *check.C) {
|
|||
}
|
||||
|
||||
func (s *DockerSuite) TestResizeAPIHeightWidthNoInt(c *check.C) {
|
||||
out, _ := runSleepingContainer(c, "-d")
|
||||
out := runSleepingContainer(c, "-d")
|
||||
cleanedContainerID := strings.TrimSpace(out)
|
||||
|
||||
endpoint := "/containers/" + cleanedContainerID + "/resize?h=foo&w=bar"
|
||||
|
|
|
@ -98,7 +98,7 @@ func (s *DockerSuite) TestAPIStatsStoppedContainerInGoroutines(c *check.C) {
|
|||
func (s *DockerSuite) TestAPIStatsNetworkStats(c *check.C) {
|
||||
testRequires(c, SameHostDaemon)
|
||||
|
||||
out, _ := runSleepingContainer(c)
|
||||
out := runSleepingContainer(c)
|
||||
id := strings.TrimSpace(out)
|
||||
c.Assert(waitRun(id), checker.IsNil)
|
||||
|
||||
|
@ -166,7 +166,7 @@ func (s *DockerSuite) TestAPIStatsNetworkStatsVersioning(c *check.C) {
|
|||
// Windows doesn't support API versions less than 1.25, so no point testing 1.17 .. 1.21
|
||||
testRequires(c, SameHostDaemon, DaemonIsLinux)
|
||||
|
||||
out, _ := runSleepingContainer(c)
|
||||
out := runSleepingContainer(c)
|
||||
id := strings.TrimSpace(out)
|
||||
c.Assert(waitRun(id), checker.IsNil)
|
||||
wg := sync.WaitGroup{}
|
||||
|
@ -274,11 +274,11 @@ func (s *DockerSuite) TestAPIStatsContainerNotFound(c *check.C) {
|
|||
func (s *DockerSuite) TestAPIStatsNoStreamConnectedContainers(c *check.C) {
|
||||
testRequires(c, DaemonIsLinux)
|
||||
|
||||
out1, _ := runSleepingContainer(c)
|
||||
out1 := runSleepingContainer(c)
|
||||
id1 := strings.TrimSpace(out1)
|
||||
c.Assert(waitRun(id1), checker.IsNil)
|
||||
|
||||
out2, _ := runSleepingContainer(c, "--net", "container:"+id1)
|
||||
out2 := runSleepingContainer(c, "--net", "container:"+id1)
|
||||
id2 := strings.TrimSpace(out2)
|
||||
c.Assert(waitRun(id2), checker.IsNil)
|
||||
|
||||
|
|
|
@ -452,7 +452,7 @@ func (s *DockerSuite) TestEventsCommit(c *check.C) {
|
|||
// Problematic on Windows as cannot commit a running container
|
||||
testRequires(c, DaemonIsLinux)
|
||||
|
||||
out, _ := runSleepingContainer(c)
|
||||
out := runSleepingContainer(c)
|
||||
cID := strings.TrimSpace(out)
|
||||
cli.WaitRun(c, cID)
|
||||
|
||||
|
@ -495,7 +495,7 @@ func (s *DockerSuite) TestEventsCopy(c *check.C) {
|
|||
}
|
||||
|
||||
func (s *DockerSuite) TestEventsResize(c *check.C) {
|
||||
out, _ := runSleepingContainer(c, "-d")
|
||||
out := runSleepingContainer(c, "-d")
|
||||
cID := strings.TrimSpace(out)
|
||||
c.Assert(waitRun(cID), checker.IsNil)
|
||||
|
||||
|
@ -561,7 +561,7 @@ func (s *DockerSuite) TestEventsTop(c *check.C) {
|
|||
// Problematic on Windows as Windows does not support top
|
||||
testRequires(c, DaemonIsLinux)
|
||||
|
||||
out, _ := runSleepingContainer(c, "-d")
|
||||
out := runSleepingContainer(c, "-d")
|
||||
cID := strings.TrimSpace(out)
|
||||
c.Assert(waitRun(cID), checker.IsNil)
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ func (s *DockerSuite) TestExecInteractive(c *check.C) {
|
|||
}
|
||||
|
||||
func (s *DockerSuite) TestExecAfterContainerRestart(c *check.C) {
|
||||
out, _ := runSleepingContainer(c)
|
||||
out := runSleepingContainer(c)
|
||||
cleanedContainerID := strings.TrimSpace(out)
|
||||
c.Assert(waitRun(cleanedContainerID), check.IsNil)
|
||||
dockerCmd(c, "restart", cleanedContainerID)
|
||||
|
@ -139,7 +139,7 @@ func (s *DockerSuite) TestExecExitStatus(c *check.C) {
|
|||
func (s *DockerSuite) TestExecPausedContainer(c *check.C) {
|
||||
testRequires(c, IsPausable)
|
||||
|
||||
out, _ := runSleepingContainer(c, "-d", "--name", "testing")
|
||||
out := runSleepingContainer(c, "-d", "--name", "testing")
|
||||
ContainerID := strings.TrimSpace(out)
|
||||
|
||||
dockerCmd(c, "pause", "testing")
|
||||
|
@ -305,7 +305,7 @@ func (s *DockerSuite) TestExecCgroup(c *check.C) {
|
|||
}
|
||||
|
||||
func (s *DockerSuite) TestExecInspectID(c *check.C) {
|
||||
out, _ := runSleepingContainer(c, "-d")
|
||||
out := runSleepingContainer(c, "-d")
|
||||
id := strings.TrimSuffix(out, "\n")
|
||||
|
||||
out = inspectField(c, id, "ExecIDs")
|
||||
|
|
|
@ -146,7 +146,7 @@ func (s *DockerSuite) TestInfoDisplaysRunningContainers(c *check.C) {
|
|||
func (s *DockerSuite) TestInfoDisplaysPausedContainers(c *check.C) {
|
||||
testRequires(c, IsPausable)
|
||||
|
||||
out, _ := runSleepingContainer(c, "-d")
|
||||
out := runSleepingContainer(c, "-d")
|
||||
cleanedContainerID := strings.TrimSpace(out)
|
||||
|
||||
dockerCmd(c, "pause", cleanedContainerID)
|
||||
|
|
|
@ -53,7 +53,7 @@ func (s *DockerSuite) TestInspectDefault(c *check.C) {
|
|||
}
|
||||
|
||||
func (s *DockerSuite) TestInspectStatus(c *check.C) {
|
||||
out, _ := runSleepingContainer(c, "-d")
|
||||
out := runSleepingContainer(c, "-d")
|
||||
out = strings.TrimSpace(out)
|
||||
|
||||
inspectOut := inspectField(c, out, "State.Status")
|
||||
|
|
|
@ -14,7 +14,7 @@ import (
|
|||
)
|
||||
|
||||
func (s *DockerSuite) TestKillContainer(c *check.C) {
|
||||
out, _ := runSleepingContainer(c, "-d")
|
||||
out := runSleepingContainer(c, "-d")
|
||||
cleanedContainerID := strings.TrimSpace(out)
|
||||
cli.WaitRun(c, cleanedContainerID)
|
||||
|
||||
|
@ -27,7 +27,7 @@ func (s *DockerSuite) TestKillContainer(c *check.C) {
|
|||
}
|
||||
|
||||
func (s *DockerSuite) TestKillOffStoppedContainer(c *check.C) {
|
||||
out, _ := runSleepingContainer(c, "-d")
|
||||
out := runSleepingContainer(c, "-d")
|
||||
cleanedContainerID := strings.TrimSpace(out)
|
||||
|
||||
cli.DockerCmd(c, "stop", cleanedContainerID)
|
||||
|
@ -103,7 +103,7 @@ func (s *DockerSuite) TestKillWithStopSignalWithDifferentSignalShouldKeepRestart
|
|||
|
||||
// FIXME(vdemeester) should be a unit test
|
||||
func (s *DockerSuite) TestKillWithInvalidSignal(c *check.C) {
|
||||
out, _ := runSleepingContainer(c, "-d")
|
||||
out := runSleepingContainer(c, "-d")
|
||||
cid := strings.TrimSpace(out)
|
||||
c.Assert(waitRun(cid), check.IsNil)
|
||||
|
||||
|
@ -114,7 +114,7 @@ func (s *DockerSuite) TestKillWithInvalidSignal(c *check.C) {
|
|||
running := inspectField(c, cid, "State.Running")
|
||||
c.Assert(running, checker.Equals, "true", check.Commentf("Container should be in running state after an invalid signal"))
|
||||
|
||||
out, _ = runSleepingContainer(c, "-d")
|
||||
out = runSleepingContainer(c, "-d")
|
||||
cid = strings.TrimSpace(out)
|
||||
c.Assert(waitRun(cid), check.IsNil)
|
||||
|
||||
|
|
|
@ -334,7 +334,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkCreateHostBind(c *check.C) {
|
|||
dockerCmd(c, "network", "create", "--subnet=192.168.10.0/24", "--gateway=192.168.10.1", "-o", "com.docker.network.bridge.host_binding_ipv4=192.168.10.1", "testbind")
|
||||
assertNwIsAvailable(c, "testbind")
|
||||
|
||||
out, _ := runSleepingContainer(c, "--net=testbind", "-p", "5000:5000")
|
||||
out := runSleepingContainer(c, "--net=testbind", "-p", "5000:5000")
|
||||
id := strings.TrimSpace(out)
|
||||
c.Assert(waitRun(id), checker.IsNil)
|
||||
out, _ = dockerCmd(c, "ps")
|
||||
|
|
|
@ -19,17 +19,17 @@ import (
|
|||
)
|
||||
|
||||
func (s *DockerSuite) TestPsListContainersBase(c *check.C) {
|
||||
out, _ := runSleepingContainer(c, "-d")
|
||||
out := runSleepingContainer(c, "-d")
|
||||
firstID := strings.TrimSpace(out)
|
||||
|
||||
out, _ = runSleepingContainer(c, "-d")
|
||||
out = runSleepingContainer(c, "-d")
|
||||
secondID := strings.TrimSpace(out)
|
||||
|
||||
// not long running
|
||||
out, _ = dockerCmd(c, "run", "-d", "busybox", "true")
|
||||
thirdID := strings.TrimSpace(out)
|
||||
|
||||
out, _ = runSleepingContainer(c, "-d")
|
||||
out = runSleepingContainer(c, "-d")
|
||||
fourthID := strings.TrimSpace(out)
|
||||
|
||||
// make sure the second is running
|
||||
|
@ -228,7 +228,7 @@ func (s *DockerSuite) TestPsListContainersFilterStatus(c *check.C) {
|
|||
|
||||
func (s *DockerSuite) TestPsListContainersFilterHealth(c *check.C) {
|
||||
// Test legacy no health check
|
||||
out, _ := runSleepingContainer(c, "--name=none_legacy")
|
||||
out := runSleepingContainer(c, "--name=none_legacy")
|
||||
containerID := strings.TrimSpace(out)
|
||||
|
||||
cli.WaitRun(c, containerID)
|
||||
|
@ -238,7 +238,7 @@ func (s *DockerSuite) TestPsListContainersFilterHealth(c *check.C) {
|
|||
c.Assert(containerOut, checker.Equals, containerID, check.Commentf("Expected id %s, got %s for legacy none filter, output: %q", containerID, containerOut, out))
|
||||
|
||||
// Test no health check specified explicitly
|
||||
out, _ = runSleepingContainer(c, "--name=none", "--no-healthcheck")
|
||||
out = runSleepingContainer(c, "--name=none", "--no-healthcheck")
|
||||
containerID = strings.TrimSpace(out)
|
||||
|
||||
cli.WaitRun(c, containerID)
|
||||
|
@ -248,7 +248,7 @@ func (s *DockerSuite) TestPsListContainersFilterHealth(c *check.C) {
|
|||
c.Assert(containerOut, checker.Equals, containerID, check.Commentf("Expected id %s, got %s for none filter, output: %q", containerID, containerOut, out))
|
||||
|
||||
// Test failing health check
|
||||
out, _ = runSleepingContainer(c, "--name=failing_container", "--health-cmd=exit 1", "--health-interval=1s")
|
||||
out = runSleepingContainer(c, "--name=failing_container", "--health-cmd=exit 1", "--health-interval=1s")
|
||||
containerID = strings.TrimSpace(out)
|
||||
|
||||
waitForHealthStatus(c, "failing_container", "starting", "unhealthy")
|
||||
|
@ -258,7 +258,7 @@ func (s *DockerSuite) TestPsListContainersFilterHealth(c *check.C) {
|
|||
c.Assert(containerOut, checker.Equals, containerID, check.Commentf("Expected containerID %s, got %s for unhealthy filter, output: %q", containerID, containerOut, out))
|
||||
|
||||
// Check passing healthcheck
|
||||
out, _ = runSleepingContainer(c, "--name=passing_container", "--health-cmd=exit 0", "--health-interval=1s")
|
||||
out = runSleepingContainer(c, "--name=passing_container", "--health-cmd=exit 0", "--health-interval=1s")
|
||||
containerID = strings.TrimSpace(out)
|
||||
|
||||
waitForHealthStatus(c, "passing_container", "starting", "healthy")
|
||||
|
@ -473,11 +473,11 @@ func (s *DockerSuite) TestPsRightTagName(c *check.C) {
|
|||
dockerCmd(c, "tag", "busybox", tag)
|
||||
|
||||
var id1 string
|
||||
out, _ := runSleepingContainer(c)
|
||||
out := runSleepingContainer(c)
|
||||
id1 = strings.TrimSpace(string(out))
|
||||
|
||||
var id2 string
|
||||
out, _ = runSleepingContainerInImage(c, tag)
|
||||
out = runSleepingContainerInImage(c, tag)
|
||||
id2 = strings.TrimSpace(string(out))
|
||||
|
||||
var imageID string
|
||||
|
@ -485,7 +485,7 @@ func (s *DockerSuite) TestPsRightTagName(c *check.C) {
|
|||
imageID = strings.TrimSpace(string(out))
|
||||
|
||||
var id3 string
|
||||
out, _ = runSleepingContainerInImage(c, imageID)
|
||||
out = runSleepingContainerInImage(c, imageID)
|
||||
id3 = strings.TrimSpace(string(out))
|
||||
|
||||
out, _ = dockerCmd(c, "ps", "--no-trunc")
|
||||
|
@ -638,7 +638,7 @@ func (s *DockerSuite) TestPsDefaultFormatAndQuiet(c *check.C) {
|
|||
err = ioutil.WriteFile(filepath.Join(d, "config.json"), []byte(config), 0644)
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
out, _ := runSleepingContainer(c, "--name=test")
|
||||
out := runSleepingContainer(c, "--name=test")
|
||||
id := strings.TrimSpace(out)
|
||||
|
||||
out, _ = dockerCmd(c, "--config", d, "ps", "-q")
|
||||
|
@ -898,35 +898,25 @@ func (s *DockerSuite) TestPsListContainersFilterNetwork(c *check.C) {
|
|||
|
||||
func (s *DockerSuite) TestPsByOrder(c *check.C) {
|
||||
name1 := "xyz-abc"
|
||||
out, err := runSleepingContainer(c, "--name", name1)
|
||||
c.Assert(err, checker.NotNil)
|
||||
c.Assert(strings.TrimSpace(out), checker.Not(checker.Equals), "")
|
||||
out := runSleepingContainer(c, "--name", name1)
|
||||
container1 := strings.TrimSpace(out)
|
||||
|
||||
name2 := "xyz-123"
|
||||
out, err = runSleepingContainer(c, "--name", name2)
|
||||
c.Assert(err, checker.NotNil)
|
||||
c.Assert(strings.TrimSpace(out), checker.Not(checker.Equals), "")
|
||||
out = runSleepingContainer(c, "--name", name2)
|
||||
container2 := strings.TrimSpace(out)
|
||||
|
||||
name3 := "789-abc"
|
||||
out, err = runSleepingContainer(c, "--name", name3)
|
||||
c.Assert(err, checker.NotNil)
|
||||
c.Assert(strings.TrimSpace(out), checker.Not(checker.Equals), "")
|
||||
out = runSleepingContainer(c, "--name", name3)
|
||||
|
||||
name4 := "789-123"
|
||||
out, err = runSleepingContainer(c, "--name", name4)
|
||||
c.Assert(err, checker.NotNil)
|
||||
c.Assert(strings.TrimSpace(out), checker.Not(checker.Equals), "")
|
||||
out = runSleepingContainer(c, "--name", name4)
|
||||
|
||||
// Run multiple time should have the same result
|
||||
out, err = dockerCmd(c, "ps", "--no-trunc", "-q", "-f", "name=xyz")
|
||||
c.Assert(err, checker.NotNil)
|
||||
out = cli.DockerCmd(c, "ps", "--no-trunc", "-q", "-f", "name=xyz").Combined()
|
||||
c.Assert(strings.TrimSpace(out), checker.Equals, fmt.Sprintf("%s\n%s", container2, container1))
|
||||
|
||||
// Run multiple time should have the same result
|
||||
out, err = dockerCmd(c, "ps", "--no-trunc", "-q", "-f", "name=xyz")
|
||||
c.Assert(err, checker.NotNil)
|
||||
out = cli.DockerCmd(c, "ps", "--no-trunc", "-q", "-f", "name=xyz").Combined()
|
||||
c.Assert(strings.TrimSpace(out), checker.Equals, fmt.Sprintf("%s\n%s", container2, container1))
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ func (s *DockerSuite) TestRenameRunningContainer(c *check.C) {
|
|||
}
|
||||
|
||||
func (s *DockerSuite) TestRenameRunningContainerAndReuse(c *check.C) {
|
||||
out, _ := runSleepingContainer(c, "--name", "first_name")
|
||||
out := runSleepingContainer(c, "--name", "first_name")
|
||||
c.Assert(waitRun("first_name"), check.IsNil)
|
||||
|
||||
newName := "new_name"
|
||||
|
@ -46,7 +46,7 @@ func (s *DockerSuite) TestRenameRunningContainerAndReuse(c *check.C) {
|
|||
name := inspectField(c, ContainerID, "Name")
|
||||
c.Assert(name, checker.Equals, "/"+newName, check.Commentf("Failed to rename container"))
|
||||
|
||||
out, _ = runSleepingContainer(c, "--name", "first_name")
|
||||
out = runSleepingContainer(c, "--name", "first_name")
|
||||
c.Assert(waitRun("first_name"), check.IsNil)
|
||||
newContainerID := strings.TrimSpace(out)
|
||||
name = inspectField(c, newContainerID, "Name")
|
||||
|
@ -113,7 +113,7 @@ func (s *DockerSuite) TestRenameAnonymousContainer(c *check.C) {
|
|||
}
|
||||
|
||||
func (s *DockerSuite) TestRenameContainerWithSameName(c *check.C) {
|
||||
out, _ := runSleepingContainer(c, "--name", "old")
|
||||
out := runSleepingContainer(c, "--name", "old")
|
||||
ContainerID := strings.TrimSpace(out)
|
||||
|
||||
out, _, err := dockerCmdWithError("rename", "old", "old")
|
||||
|
|
|
@ -52,7 +52,7 @@ func (s *DockerSuite) TestRestartRunningContainer(c *check.C) {
|
|||
// Test that restarting a container with a volume does not create a new volume on restart. Regression test for #819.
|
||||
func (s *DockerSuite) TestRestartWithVolumes(c *check.C) {
|
||||
prefix, slash := getPrefixAndSlashFromDaemonPlatform()
|
||||
out, _ := runSleepingContainer(c, "-d", "-v", prefix+slash+"test")
|
||||
out := runSleepingContainer(c, "-d", "-v", prefix+slash+"test")
|
||||
|
||||
cleanedContainerID := strings.TrimSpace(out)
|
||||
out, err := inspectFilter(cleanedContainerID, "len .Mounts")
|
||||
|
@ -166,7 +166,7 @@ func (s *DockerSuite) TestRestartContainerwithGoodContainer(c *check.C) {
|
|||
func (s *DockerSuite) TestRestartContainerSuccess(c *check.C) {
|
||||
testRequires(c, SameHostDaemon)
|
||||
|
||||
out, _ := runSleepingContainer(c, "-d", "--restart=always")
|
||||
out := runSleepingContainer(c, "-d", "--restart=always")
|
||||
id := strings.TrimSpace(out)
|
||||
c.Assert(waitRun(id), check.IsNil)
|
||||
|
||||
|
@ -235,7 +235,7 @@ func (s *DockerSuite) TestRestartWithPolicyUserDefinedNetwork(c *check.C) {
|
|||
func (s *DockerSuite) TestRestartPolicyAfterRestart(c *check.C) {
|
||||
testRequires(c, SameHostDaemon)
|
||||
|
||||
out, _ := runSleepingContainer(c, "-d", "--restart=always")
|
||||
out := runSleepingContainer(c, "-d", "--restart=always")
|
||||
id := strings.TrimSpace(out)
|
||||
c.Assert(waitRun(id), check.IsNil)
|
||||
|
||||
|
@ -294,7 +294,7 @@ func (s *DockerSuite) TestRestartContainerwithRestartPolicy(c *check.C) {
|
|||
}
|
||||
|
||||
func (s *DockerSuite) TestRestartAutoRemoveContainer(c *check.C) {
|
||||
out, _ := runSleepingContainer(c, "--rm")
|
||||
out := runSleepingContainer(c, "--rm")
|
||||
|
||||
id := strings.TrimSpace(string(out))
|
||||
dockerCmd(c, "restart", id)
|
||||
|
|
|
@ -85,7 +85,7 @@ func (s *DockerSuite) TestRmiImgIDMultipleTag(c *check.C) {
|
|||
imgID := inspectField(c, "busybox-one:tag1", "Id")
|
||||
|
||||
// run a container with the image
|
||||
out, _ = runSleepingContainerInImage(c, "busybox-one")
|
||||
out = runSleepingContainerInImage(c, "busybox-one")
|
||||
containerID = strings.TrimSpace(out)
|
||||
|
||||
// first checkout without force it fails
|
||||
|
|
|
@ -147,7 +147,7 @@ func (s *DockerSuite) TestStatsAllNewContainersAdded(c *check.C) {
|
|||
}
|
||||
}()
|
||||
|
||||
out, _ := runSleepingContainer(c, "-d")
|
||||
out := runSleepingContainer(c, "-d")
|
||||
c.Assert(waitRun(strings.TrimSpace(out)), check.IsNil)
|
||||
id <- strings.TrimSpace(out)[:12]
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
)
|
||||
|
||||
func (s *DockerSuite) TestTopMultipleArgs(c *check.C) {
|
||||
out, _ := runSleepingContainer(c, "-d")
|
||||
out := runSleepingContainer(c, "-d")
|
||||
cleanedContainerID := strings.TrimSpace(out)
|
||||
|
||||
var expected icmd.Expected
|
||||
|
@ -24,7 +24,7 @@ func (s *DockerSuite) TestTopMultipleArgs(c *check.C) {
|
|||
}
|
||||
|
||||
func (s *DockerSuite) TestTopNonPrivileged(c *check.C) {
|
||||
out, _ := runSleepingContainer(c, "-d")
|
||||
out := runSleepingContainer(c, "-d")
|
||||
cleanedContainerID := strings.TrimSpace(out)
|
||||
|
||||
out1, _ := dockerCmd(c, "top", cleanedContainerID)
|
||||
|
@ -49,7 +49,7 @@ func (s *DockerSuite) TestTopNonPrivileged(c *check.C) {
|
|||
// very different to Linux in this regard.
|
||||
func (s *DockerSuite) TestTopWindowsCoreProcesses(c *check.C) {
|
||||
testRequires(c, DaemonIsWindows)
|
||||
out, _ := runSleepingContainer(c, "-d")
|
||||
out := runSleepingContainer(c, "-d")
|
||||
cleanedContainerID := strings.TrimSpace(out)
|
||||
out1, _ := dockerCmd(c, "top", cleanedContainerID)
|
||||
lookingFor := []string{"smss.exe", "csrss.exe", "wininit.exe", "services.exe", "lsass.exe", "CExecSvc.exe"}
|
||||
|
|
|
@ -32,7 +32,7 @@ func (s *DockerSuite) TestUpdateRestartPolicy(c *check.C) {
|
|||
}
|
||||
|
||||
func (s *DockerSuite) TestUpdateRestartWithAutoRemoveFlag(c *check.C) {
|
||||
out, _ := runSleepingContainer(c, "--rm")
|
||||
out := runSleepingContainer(c, "--rm")
|
||||
id := strings.TrimSpace(out)
|
||||
|
||||
// update restart policy for an AutoRemove container
|
||||
|
|
|
@ -487,18 +487,18 @@ func getInspectBody(c *check.C, version, id string) []byte {
|
|||
|
||||
// Run a long running idle task in a background container using the
|
||||
// system-specific default image and command.
|
||||
func runSleepingContainer(c *check.C, extraArgs ...string) (string, int) {
|
||||
func runSleepingContainer(c *check.C, extraArgs ...string) string {
|
||||
return runSleepingContainerInImage(c, defaultSleepImage, extraArgs...)
|
||||
}
|
||||
|
||||
// Run a long running idle task in a background container using the specified
|
||||
// image and the system-specific command.
|
||||
func runSleepingContainerInImage(c *check.C, image string, extraArgs ...string) (string, int) {
|
||||
func runSleepingContainerInImage(c *check.C, image string, extraArgs ...string) string {
|
||||
args := []string{"run", "-d"}
|
||||
args = append(args, extraArgs...)
|
||||
args = append(args, image)
|
||||
args = append(args, sleepCommandForDaemonPlatform()...)
|
||||
return dockerCmd(c, args...)
|
||||
return cli.DockerCmd(c, args...).Combined()
|
||||
}
|
||||
|
||||
// minimalBaseImage returns the name of the minimal base image for the current
|
||||
|
|
Loading…
Reference in a new issue