mirror of
https://github.com/clearlinux/docker.git
synced 2026-09-06 21:51:33 +00:00
Add cpu cfs quota to build
Signed-off-by: Lei Jitang <leijitang@huawei.com>
This commit is contained in:
@@ -5371,7 +5371,7 @@ func (s *DockerSuite) TestBuildResourceConstraintsAreUsed(c *check.C) {
|
||||
c.Fatal(err)
|
||||
}
|
||||
|
||||
cmd := exec.Command(dockerBinary, "build", "--no-cache", "--rm=false", "--memory=64m", "--memory-swap=-1", "--cpuset-cpus=0", "--cpuset-mems=0", "--cpu-shares=100", "-t", name, ".")
|
||||
cmd := exec.Command(dockerBinary, "build", "--no-cache", "--rm=false", "--memory=64m", "--memory-swap=-1", "--cpuset-cpus=0", "--cpuset-mems=0", "--cpu-shares=100", "--cpu-quota=8000", "-t", name, ".")
|
||||
cmd.Dir = ctx.Dir
|
||||
|
||||
out, _, err := runCommandWithOutput(cmd)
|
||||
@@ -5388,6 +5388,7 @@ func (s *DockerSuite) TestBuildResourceConstraintsAreUsed(c *check.C) {
|
||||
CpusetCpus string
|
||||
CpusetMems string
|
||||
CpuShares int64
|
||||
CpuQuota int64
|
||||
}
|
||||
|
||||
cfg, err := inspectFieldJSON(cID, "HostConfig")
|
||||
@@ -5399,9 +5400,9 @@ func (s *DockerSuite) TestBuildResourceConstraintsAreUsed(c *check.C) {
|
||||
if err := json.Unmarshal([]byte(cfg), &c1); err != nil {
|
||||
c.Fatal(err, cfg)
|
||||
}
|
||||
if c1.Memory != 67108864 || c1.MemorySwap != -1 || c1.CpusetCpus != "0" || c1.CpusetMems != "0" || c1.CpuShares != 100 {
|
||||
c.Fatalf("resource constraints not set properly:\nMemory: %d, MemSwap: %d, CpusetCpus: %s, CpusetMems: %s, CpuShares: %d",
|
||||
c1.Memory, c1.MemorySwap, c1.CpusetCpus, c1.CpusetMems, c1.CpuShares)
|
||||
if c1.Memory != 67108864 || c1.MemorySwap != -1 || c1.CpusetCpus != "0" || c1.CpusetMems != "0" || c1.CpuShares != 100 || c1.CpuQuota != 8000 {
|
||||
c.Fatalf("resource constraints not set properly:\nMemory: %d, MemSwap: %d, CpusetCpus: %s, CpusetMems: %s, CpuShares: %d, CpuQuota: %d",
|
||||
c1.Memory, c1.MemorySwap, c1.CpusetCpus, c1.CpusetMems, c1.CpuShares, c1.CpuQuota)
|
||||
}
|
||||
|
||||
// Make sure constraints aren't saved to image
|
||||
@@ -5415,9 +5416,9 @@ func (s *DockerSuite) TestBuildResourceConstraintsAreUsed(c *check.C) {
|
||||
if err := json.Unmarshal([]byte(cfg), &c2); err != nil {
|
||||
c.Fatal(err, cfg)
|
||||
}
|
||||
if c2.Memory == 67108864 || c2.MemorySwap == -1 || c2.CpusetCpus == "0" || c2.CpusetMems == "0" || c2.CpuShares == 100 {
|
||||
c.Fatalf("resource constraints leaked from build:\nMemory: %d, MemSwap: %d, CpusetCpus: %s, CpusetMems: %s, CpuShares: %d",
|
||||
c2.Memory, c2.MemorySwap, c2.CpusetCpus, c2.CpusetMems, c2.CpuShares)
|
||||
if c2.Memory == 67108864 || c2.MemorySwap == -1 || c2.CpusetCpus == "0" || c2.CpusetMems == "0" || c2.CpuShares == 100 || c2.CpuQuota == 8000 {
|
||||
c.Fatalf("resource constraints leaked from build:\nMemory: %d, MemSwap: %d, CpusetCpus: %s, CpusetMems: %s, CpuShares: %d, CpuQuota: %d",
|
||||
c2.Memory, c2.MemorySwap, c2.CpusetCpus, c2.CpusetMems, c2.CpuShares, c2.CpuQuota)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user