mirror of
https://github.com/docker/cli.git
synced 2026-09-24 23:41:10 -05:00
Windows: Add cpu count option
Signed-off-by: Darren Stahl <darst@microsoft.com> Upstream-commit: 4e15420b9be50ddd7fa65e5c7f9b732777f9cc35 Component: engine
This commit is contained in:
@@ -4766,3 +4766,67 @@ func (s *DockerSuite) TestRunMount(c *check.C) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestRunWindowsWithCPUCount(c *check.C) {
|
||||
testRequires(c, DaemonIsWindows)
|
||||
|
||||
out, _ := dockerCmd(c, "run", "--cpu-count=1", "--name", "test", "busybox", "echo", "testing")
|
||||
c.Assert(strings.TrimSpace(out), checker.Equals, "testing")
|
||||
|
||||
out = inspectField(c, "test", "HostConfig.CPUCount")
|
||||
c.Assert(out, check.Equals, "1")
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestRunWindowsWithCPUShares(c *check.C) {
|
||||
testRequires(c, DaemonIsWindows)
|
||||
|
||||
out, _ := dockerCmd(c, "run", "--cpu-shares=1000", "--name", "test", "busybox", "echo", "testing")
|
||||
c.Assert(strings.TrimSpace(out), checker.Equals, "testing")
|
||||
|
||||
out = inspectField(c, "test", "HostConfig.CPUShares")
|
||||
c.Assert(out, check.Equals, "1000")
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestRunWindowsWithCPUPercent(c *check.C) {
|
||||
testRequires(c, DaemonIsWindows)
|
||||
|
||||
out, _ := dockerCmd(c, "run", "--cpu-percent=80", "--name", "test", "busybox", "echo", "testing")
|
||||
c.Assert(strings.TrimSpace(out), checker.Equals, "testing")
|
||||
|
||||
out = inspectField(c, "test", "HostConfig.CPUPercent")
|
||||
c.Assert(out, check.Equals, "80")
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestRunProcessIsolationWithCPUCountCPUSharesAndCPUPercent(c *check.C) {
|
||||
testRequires(c, DaemonIsWindows, IsolationIsProcess)
|
||||
|
||||
out, _ := dockerCmd(c, "run", "--cpu-count=1", "--cpu-shares=1000", "--cpu-percent=80", "--name", "test", "busybox", "echo", "testing")
|
||||
c.Assert(strings.TrimSpace(out), checker.Contains, "WARNING: Conflicting options: CPU count takes priority over CPU shares on Windows Server Containers. CPU shares discarded")
|
||||
c.Assert(strings.TrimSpace(out), checker.Contains, "WARNING: Conflicting options: CPU count takes priority over CPU percent on Windows Server Containers. CPU percent discarded")
|
||||
c.Assert(strings.TrimSpace(out), checker.Contains, "testing")
|
||||
|
||||
out = inspectField(c, "test", "HostConfig.CPUCount")
|
||||
c.Assert(out, check.Equals, "1")
|
||||
|
||||
out = inspectField(c, "test", "HostConfig.CPUShares")
|
||||
c.Assert(out, check.Equals, "0")
|
||||
|
||||
out = inspectField(c, "test", "HostConfig.CPUPercent")
|
||||
c.Assert(out, check.Equals, "0")
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestRunHypervIsolationWithCPUCountCPUSharesAndCPUPercent(c *check.C) {
|
||||
testRequires(c, DaemonIsWindows, IsolationIsHyperv)
|
||||
|
||||
out, _ := dockerCmd(c, "run", "--cpu-count=1", "--cpu-shares=1000", "--cpu-percent=80", "--name", "test", "busybox", "echo", "testing")
|
||||
c.Assert(strings.TrimSpace(out), checker.Contains, "testing")
|
||||
|
||||
out = inspectField(c, "test", "HostConfig.CPUCount")
|
||||
c.Assert(out, check.Equals, "1")
|
||||
|
||||
out = inspectField(c, "test", "HostConfig.CPUShares")
|
||||
c.Assert(out, check.Equals, "1000")
|
||||
|
||||
out = inspectField(c, "test", "HostConfig.CPUPercent")
|
||||
c.Assert(out, check.Equals, "80")
|
||||
}
|
||||
|
||||
@@ -218,6 +218,18 @@ var (
|
||||
},
|
||||
"Test requires containers are not pausable.",
|
||||
}
|
||||
IsolationIsHyperv = testRequirement{
|
||||
func() bool {
|
||||
return daemonPlatform == "windows" && isolation == "hyperv"
|
||||
},
|
||||
"Test requires a Windows daemon running default isolation mode of hyperv.",
|
||||
}
|
||||
IsolationIsProcess = testRequirement{
|
||||
func() bool {
|
||||
return daemonPlatform == "windows" && isolation == "process"
|
||||
},
|
||||
"Test requires a Windows daemon running default isolation mode of process.",
|
||||
}
|
||||
)
|
||||
|
||||
// testRequires checks if the environment satisfies the requirements
|
||||
|
||||
Reference in New Issue
Block a user