|
@@ -1409,3 +1409,23 @@ func (s *DockerDaemonSuite) TestRunWithDaemonDefaultSeccompProfile(c *check.C) {
|
|
|
c.Assert(err, check.NotNil)
|
|
|
c.Assert(out, checker.Contains, "Operation not permitted")
|
|
|
}
|
|
|
+
|
|
|
+func (s *DockerSuite) TestRunWithNanoCPUs(c *check.C) {
|
|
|
+ testRequires(c, cpuCfsQuota, cpuCfsPeriod)
|
|
|
+
|
|
|
+ file1 := "/sys/fs/cgroup/cpu/cpu.cfs_quota_us"
|
|
|
+ file2 := "/sys/fs/cgroup/cpu/cpu.cfs_period_us"
|
|
|
+ out, _ := dockerCmd(c, "run", "--cpus", "0.5", "--name", "test", "busybox", "sh", "-c", fmt.Sprintf("cat %s && cat %s", file1, file2))
|
|
|
+ c.Assert(strings.TrimSpace(out), checker.Equals, "50000\n100000")
|
|
|
+
|
|
|
+ out = inspectField(c, "test", "HostConfig.NanoCpus")
|
|
|
+ c.Assert(out, checker.Equals, "5e+08", check.Commentf("setting the Nano CPUs failed"))
|
|
|
+ out = inspectField(c, "test", "HostConfig.CpuQuota")
|
|
|
+ c.Assert(out, checker.Equals, "0", check.Commentf("CPU CFS quota should be 0"))
|
|
|
+ out = inspectField(c, "test", "HostConfig.CpuPeriod")
|
|
|
+ c.Assert(out, checker.Equals, "0", check.Commentf("CPU CFS period should be 0"))
|
|
|
+
|
|
|
+ out, _, err := dockerCmdWithError("run", "--cpus", "0.5", "--cpu-quota", "50000", "--cpu-period", "100000", "busybox", "sh")
|
|
|
+ c.Assert(err, check.NotNil)
|
|
|
+ c.Assert(out, checker.Contains, "Conflicting options: Nano CPUs and CPU Period cannot both be set")
|
|
|
+}
|