2016-01-04 10:58:20 -05:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/docker/docker/pkg/integration/checker"
|
|
|
|
"github.com/go-check/check"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (s *DockerSuite) TestUpdateRestartPolicy(c *check.C) {
|
|
|
|
out, _ := dockerCmd(c, "run", "-d", "--restart=on-failure:3", "busybox", "sh", "-c", "sleep 1 && false")
|
|
|
|
timeout := 60 * time.Second
|
|
|
|
if daemonPlatform == "windows" {
|
2016-03-14 07:49:24 -04:00
|
|
|
timeout = 180 * time.Second
|
2016-01-04 10:58:20 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
id := strings.TrimSpace(string(out))
|
|
|
|
|
|
|
|
// update restart policy to on-failure:5
|
|
|
|
dockerCmd(c, "update", "--restart=on-failure:5", id)
|
|
|
|
|
|
|
|
err := waitExited(id, timeout)
|
|
|
|
c.Assert(err, checker.IsNil)
|
|
|
|
|
|
|
|
count := inspectField(c, id, "RestartCount")
|
|
|
|
c.Assert(count, checker.Equals, "5")
|
|
|
|
|
|
|
|
maximumRetryCount := inspectField(c, id, "HostConfig.RestartPolicy.MaximumRetryCount")
|
|
|
|
c.Assert(maximumRetryCount, checker.Equals, "5")
|
|
|
|
}
|
2016-08-15 04:38:47 -04:00
|
|
|
|
|
|
|
func (s *DockerSuite) TestUpdateRestartWithAutoRemoveFlag(c *check.C) {
|
|
|
|
out, _ := runSleepingContainer(c, "--rm")
|
|
|
|
id := strings.TrimSpace(out)
|
|
|
|
|
|
|
|
// update restart policy for an AutoRemove container
|
|
|
|
out, _, err := dockerCmdWithError("update", "--restart=always", id)
|
|
|
|
c.Assert(err, checker.NotNil)
|
|
|
|
c.Assert(out, checker.Contains, "Restart policy cannot be updated because AutoRemove is enabled for the container")
|
|
|
|
}
|