mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Windows CI: Port docker_cli_restart_test.go
Signed-off-by: John Howard <jhoward@microsoft.com>
This commit is contained in:
parent
a7fefcf16c
commit
281c1ced6d
1 changed files with 13 additions and 18 deletions
|
@ -11,7 +11,6 @@ import (
|
|||
)
|
||||
|
||||
func (s *DockerSuite) TestRestartStoppedContainer(c *check.C) {
|
||||
testRequires(c, DaemonIsLinux)
|
||||
out, _ := dockerCmd(c, "run", "-d", "busybox", "echo", "foobar")
|
||||
|
||||
cleanedContainerID := strings.TrimSpace(out)
|
||||
|
@ -27,7 +26,6 @@ func (s *DockerSuite) TestRestartStoppedContainer(c *check.C) {
|
|||
}
|
||||
|
||||
func (s *DockerSuite) TestRestartRunningContainer(c *check.C) {
|
||||
testRequires(c, DaemonIsLinux)
|
||||
out, _ := dockerCmd(c, "run", "-d", "busybox", "sh", "-c", "echo foobar && sleep 30 && echo 'should not print this'")
|
||||
|
||||
cleanedContainerID := strings.TrimSpace(out)
|
||||
|
@ -48,8 +46,8 @@ 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) {
|
||||
testRequires(c, DaemonIsLinux)
|
||||
out, _ := dockerCmd(c, "run", "-d", "-v", "/test", "busybox", "top")
|
||||
prefix, slash := getPrefixAndSlashFromDaemonPlatform()
|
||||
out, _ := runSleepingContainer(c, "-d", "-v", prefix+slash+"test")
|
||||
|
||||
cleanedContainerID := strings.TrimSpace(out)
|
||||
out, err := inspectFilter(cleanedContainerID, "len .Mounts")
|
||||
|
@ -57,7 +55,7 @@ func (s *DockerSuite) TestRestartWithVolumes(c *check.C) {
|
|||
out = strings.Trim(out, " \n\r")
|
||||
c.Assert(out, checker.Equals, "1")
|
||||
|
||||
source, err := inspectMountSourceField(cleanedContainerID, "/test")
|
||||
source, err := inspectMountSourceField(cleanedContainerID, prefix+slash+"test")
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
dockerCmd(c, "restart", cleanedContainerID)
|
||||
|
@ -67,13 +65,12 @@ func (s *DockerSuite) TestRestartWithVolumes(c *check.C) {
|
|||
out = strings.Trim(out, " \n\r")
|
||||
c.Assert(out, checker.Equals, "1")
|
||||
|
||||
sourceAfterRestart, err := inspectMountSourceField(cleanedContainerID, "/test")
|
||||
sourceAfterRestart, err := inspectMountSourceField(cleanedContainerID, prefix+slash+"test")
|
||||
c.Assert(err, checker.IsNil)
|
||||
c.Assert(source, checker.Equals, sourceAfterRestart)
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestRestartPolicyNO(c *check.C) {
|
||||
testRequires(c, DaemonIsLinux)
|
||||
out, _ := dockerCmd(c, "run", "-d", "--restart=no", "busybox", "false")
|
||||
|
||||
id := strings.TrimSpace(string(out))
|
||||
|
@ -82,7 +79,6 @@ func (s *DockerSuite) TestRestartPolicyNO(c *check.C) {
|
|||
}
|
||||
|
||||
func (s *DockerSuite) TestRestartPolicyAlways(c *check.C) {
|
||||
testRequires(c, DaemonIsLinux)
|
||||
out, _ := dockerCmd(c, "run", "-d", "--restart=always", "busybox", "false")
|
||||
|
||||
id := strings.TrimSpace(string(out))
|
||||
|
@ -96,7 +92,6 @@ func (s *DockerSuite) TestRestartPolicyAlways(c *check.C) {
|
|||
}
|
||||
|
||||
func (s *DockerSuite) TestRestartPolicyOnFailure(c *check.C) {
|
||||
testRequires(c, DaemonIsLinux)
|
||||
out, _ := dockerCmd(c, "run", "-d", "--restart=on-failure:1", "busybox", "false")
|
||||
|
||||
id := strings.TrimSpace(string(out))
|
||||
|
@ -107,12 +102,11 @@ func (s *DockerSuite) TestRestartPolicyOnFailure(c *check.C) {
|
|||
|
||||
// a good container with --restart=on-failure:3
|
||||
// MaximumRetryCount!=0; RestartCount=0
|
||||
func (s *DockerSuite) TestContainerRestartwithGoodContainer(c *check.C) {
|
||||
testRequires(c, DaemonIsLinux)
|
||||
func (s *DockerSuite) TestRestartContainerwithGoodContainer(c *check.C) {
|
||||
out, _ := dockerCmd(c, "run", "-d", "--restart=on-failure:3", "busybox", "true")
|
||||
|
||||
id := strings.TrimSpace(string(out))
|
||||
err := waitInspect(id, "{{ .State.Restarting }} {{ .State.Running }}", "false false", 5*time.Second)
|
||||
err := waitInspect(id, "{{ .State.Restarting }} {{ .State.Running }}", "false false", 30*time.Second)
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
count := inspectField(c, id, "RestartCount")
|
||||
|
@ -123,10 +117,10 @@ func (s *DockerSuite) TestContainerRestartwithGoodContainer(c *check.C) {
|
|||
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestContainerRestartSuccess(c *check.C) {
|
||||
testRequires(c, DaemonIsLinux, SameHostDaemon)
|
||||
func (s *DockerSuite) TestRestartContainerSuccess(c *check.C) {
|
||||
testRequires(c, SameHostDaemon)
|
||||
|
||||
out, _ := dockerCmd(c, "run", "-d", "--restart=always", "busybox", "top")
|
||||
out, _ := runSleepingContainer(c, "-d", "--restart=always")
|
||||
id := strings.TrimSpace(out)
|
||||
c.Assert(waitRun(id), check.IsNil)
|
||||
|
||||
|
@ -142,14 +136,15 @@ func (s *DockerSuite) TestContainerRestartSuccess(c *check.C) {
|
|||
err = p.Kill()
|
||||
c.Assert(err, check.IsNil)
|
||||
|
||||
err = waitInspect(id, "{{.RestartCount}}", "1", 5*time.Second)
|
||||
err = waitInspect(id, "{{.RestartCount}}", "1", 30*time.Second)
|
||||
c.Assert(err, check.IsNil)
|
||||
|
||||
err = waitInspect(id, "{{.State.Status}}", "running", 5*time.Second)
|
||||
err = waitInspect(id, "{{.State.Status}}", "running", 30*time.Second)
|
||||
c.Assert(err, check.IsNil)
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestUserDefinedNetworkWithRestartPolicy(c *check.C) {
|
||||
func (s *DockerSuite) TestRestartWithPolicyUserDefinedNetwork(c *check.C) {
|
||||
// TODO Windows. This may be portable following HNS integration post TP5.
|
||||
testRequires(c, DaemonIsLinux, SameHostDaemon, NotUserNamespace, NotArm)
|
||||
dockerCmd(c, "network", "create", "-d", "bridge", "udNet")
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue