Merge pull request #26795 from darrenstahlmsft/PauseResume
Implement Pause Resume support for Windows Upstream-commit: dd383898cdcbcef7bd48bc0115cc9a739cf610f3 Component: engine
This commit is contained in:
@ -154,9 +154,9 @@ func (s *DockerSuite) TestAttachDisconnect(c *check.C) {
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestAttachPausedContainer(c *check.C) {
|
||||
testRequires(c, DaemonIsLinux) // Containers cannot be paused on Windows
|
||||
testRequires(c, IsPausable)
|
||||
defer unpauseAllContainers()
|
||||
dockerCmd(c, "run", "-d", "--name=test", "busybox", "top")
|
||||
runSleepingContainer(c, "-d", "--name=test")
|
||||
dockerCmd(c, "pause", "test")
|
||||
|
||||
result := dockerCmdWithResult("attach", "test")
|
||||
|
||||
@ -127,11 +127,10 @@ func (s *DockerSuite) TestExecExitStatus(c *check.C) {
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestExecPausedContainer(c *check.C) {
|
||||
// Windows does not support pause
|
||||
testRequires(c, DaemonIsLinux)
|
||||
testRequires(c, IsPausable)
|
||||
defer unpauseAllContainers()
|
||||
|
||||
out, _ := dockerCmd(c, "run", "-d", "--name", "testing", "busybox", "top")
|
||||
out, _ := runSleepingContainer(c, "-d", "--name", "testing")
|
||||
ContainerID := strings.TrimSpace(out)
|
||||
|
||||
dockerCmd(c, "pause", "testing")
|
||||
|
||||
@ -138,9 +138,9 @@ func (s *DockerSuite) TestInfoDisplaysRunningContainers(c *check.C) {
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestInfoDisplaysPausedContainers(c *check.C) {
|
||||
testRequires(c, DaemonIsLinux)
|
||||
testRequires(c, IsPausable)
|
||||
|
||||
out, _ := dockerCmd(c, "run", "-d", "busybox", "top")
|
||||
out, _ := runSleepingContainer(c, "-d")
|
||||
cleanedContainerID := strings.TrimSpace(out)
|
||||
|
||||
dockerCmd(c, "pause", cleanedContainerID)
|
||||
|
||||
@ -8,11 +8,11 @@ import (
|
||||
)
|
||||
|
||||
func (s *DockerSuite) TestPause(c *check.C) {
|
||||
testRequires(c, DaemonIsLinux)
|
||||
testRequires(c, IsPausable)
|
||||
defer unpauseAllContainers()
|
||||
|
||||
name := "testeventpause"
|
||||
dockerCmd(c, "run", "-d", "--name", name, "busybox", "top")
|
||||
runSleepingContainer(c, "-d", "--name", name)
|
||||
|
||||
dockerCmd(c, "pause", name)
|
||||
pausedContainers, err := getSliceOfPausedContainers()
|
||||
@ -30,7 +30,7 @@ func (s *DockerSuite) TestPause(c *check.C) {
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestPauseMultipleContainers(c *check.C) {
|
||||
testRequires(c, DaemonIsLinux)
|
||||
testRequires(c, IsPausable)
|
||||
defer unpauseAllContainers()
|
||||
|
||||
containers := []string{
|
||||
@ -38,7 +38,7 @@ func (s *DockerSuite) TestPauseMultipleContainers(c *check.C) {
|
||||
"testpausewithmorecontainers2",
|
||||
}
|
||||
for _, name := range containers {
|
||||
dockerCmd(c, "run", "-d", "--name", name, "busybox", "top")
|
||||
runSleepingContainer(c, "-d", "--name", name)
|
||||
}
|
||||
dockerCmd(c, append([]string{"pause"}, containers...)...)
|
||||
pausedContainers, err := getSliceOfPausedContainers()
|
||||
@ -58,9 +58,9 @@ func (s *DockerSuite) TestPauseMultipleContainers(c *check.C) {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestPauseFailsOnWindows(c *check.C) {
|
||||
testRequires(c, DaemonIsWindows)
|
||||
dockerCmd(c, "run", "-d", "--name=test", "busybox", "sleep 3")
|
||||
func (s *DockerSuite) TestPauseFailsOnWindowsServerContainers(c *check.C) {
|
||||
testRequires(c, DaemonIsWindows, NotPausable)
|
||||
runSleepingContainer(c, "-d", "--name=test")
|
||||
out, _, _ := dockerCmdWithError("pause", "test")
|
||||
c.Assert(out, checker.Contains, "Windows: Containers cannot be paused")
|
||||
c.Assert(out, checker.Contains, "cannot pause Windows Server Containers")
|
||||
}
|
||||
|
||||
@ -95,10 +95,10 @@ func (s *DockerSuite) TestStartRecordError(c *check.C) {
|
||||
|
||||
func (s *DockerSuite) TestStartPausedContainer(c *check.C) {
|
||||
// Windows does not support pausing containers
|
||||
testRequires(c, DaemonIsLinux)
|
||||
testRequires(c, IsPausable)
|
||||
defer unpauseAllContainers()
|
||||
|
||||
dockerCmd(c, "run", "-d", "--name", "testing", "busybox", "top")
|
||||
runSleepingContainer(c, "-d", "--name", "testing")
|
||||
|
||||
dockerCmd(c, "pause", "testing")
|
||||
|
||||
|
||||
@ -201,6 +201,24 @@ var (
|
||||
},
|
||||
"Test cannot be run when remapping root",
|
||||
}
|
||||
IsPausable = testRequirement{
|
||||
func() bool {
|
||||
if daemonPlatform == "windows" {
|
||||
return isolation == "hyperv"
|
||||
}
|
||||
return true
|
||||
},
|
||||
"Test requires containers are pausable.",
|
||||
}
|
||||
NotPausable = testRequirement{
|
||||
func() bool {
|
||||
if daemonPlatform == "windows" {
|
||||
return isolation == "process"
|
||||
}
|
||||
return false
|
||||
},
|
||||
"Test requires containers are not pausable.",
|
||||
}
|
||||
)
|
||||
|
||||
// testRequires checks if the environment satisfies the requirements
|
||||
|
||||
Reference in New Issue
Block a user