Merge pull request #19942 from LK4D4/fix_vet_errors

Fix minor vet warnings
This commit is contained in:
Jess Frazelle 2016-02-03 13:31:11 -08:00
commit fdcce4ac03
3 changed files with 11 additions and 35 deletions

View file

@ -136,7 +136,7 @@ func TestModifiedDiscoverySettings(t *testing.T) {
for _, c := range cases {
got := modifiedDiscoverySettings(c.current, c.modified.ClusterStore, c.modified.ClusterAdvertise, c.modified.ClusterOpts)
if c.expected != got {
t.Fatalf("expected %v, got %v: current config %q, new config %q", c.expected, got, c.current, c.modified)
t.Fatalf("expected %v, got %v: current config %v, new config %v", c.expected, got, c.current, c.modified)
}
}
}

View file

@ -23,18 +23,12 @@ func (s *DockerSuite) TestApiUpdateContainer(c *check.C) {
_, _, err := sockRequest("POST", "/containers/"+name+"/update", hostConfig)
c.Assert(err, check.IsNil)
memory := inspectField(c, name, "HostConfig.Memory")
if memory != "314572800" {
c.Fatalf("Got the wrong memory value, we got %d, expected 314572800(300M).", memory)
}
c.Assert(inspectField(c, name, "HostConfig.Memory"), checker.Equals, "314572800")
file := "/sys/fs/cgroup/memory/memory.limit_in_bytes"
out, _ := dockerCmd(c, "exec", name, "cat", file)
c.Assert(strings.TrimSpace(out), checker.Equals, "314572800")
memorySwap := inspectField(c, name, "HostConfig.MemorySwap")
if memorySwap != "524288000" {
c.Fatalf("Got the wrong memorySwap value, we got %d, expected 524288000(500M).", memorySwap)
}
c.Assert(inspectField(c, name, "HostConfig.MemorySwap"), checker.Equals, "524288000")
file = "/sys/fs/cgroup/memory/memory.memsw.limit_in_bytes"
out, _ = dockerCmd(c, "exec", name, "cat", file)
c.Assert(strings.TrimSpace(out), checker.Equals, "524288000")

View file

@ -20,10 +20,7 @@ func (s *DockerSuite) TestUpdateRunningContainer(c *check.C) {
dockerCmd(c, "run", "-d", "--name", name, "-m", "300M", "busybox", "top")
dockerCmd(c, "update", "-m", "500M", name)
memory := inspectField(c, name, "HostConfig.Memory")
if memory != "524288000" {
c.Fatalf("Got the wrong memory value, we got %d, expected 524288000(500M).", memory)
}
c.Assert(inspectField(c, name, "HostConfig.Memory"), checker.Equals, "524288000")
file := "/sys/fs/cgroup/memory/memory.limit_in_bytes"
out, _ := dockerCmd(c, "exec", name, "cat", file)
@ -39,10 +36,7 @@ func (s *DockerSuite) TestUpdateRunningContainerWithRestart(c *check.C) {
dockerCmd(c, "update", "-m", "500M", name)
dockerCmd(c, "restart", name)
memory := inspectField(c, name, "HostConfig.Memory")
if memory != "524288000" {
c.Fatalf("Got the wrong memory value, we got %d, expected 524288000(500M).", memory)
}
c.Assert(inspectField(c, name, "HostConfig.Memory"), checker.Equals, "524288000")
file := "/sys/fs/cgroup/memory/memory.limit_in_bytes"
out, _ := dockerCmd(c, "exec", name, "cat", file)
@ -58,10 +52,7 @@ func (s *DockerSuite) TestUpdateStoppedContainer(c *check.C) {
dockerCmd(c, "run", "--name", name, "-m", "300M", "busybox", "cat", file)
dockerCmd(c, "update", "-m", "500M", name)
memory := inspectField(c, name, "HostConfig.Memory")
if memory != "524288000" {
c.Fatalf("Got the wrong memory value, we got %d, expected 524288000(500M).", memory)
}
c.Assert(inspectField(c, name, "HostConfig.Memory"), checker.Equals, "524288000")
out, _ := dockerCmd(c, "start", "-a", name)
c.Assert(strings.TrimSpace(out), checker.Equals, "524288000")
@ -76,14 +67,11 @@ func (s *DockerSuite) TestUpdatePausedContainer(c *check.C) {
dockerCmd(c, "pause", name)
dockerCmd(c, "update", "--cpu-shares", "500", name)
out := inspectField(c, name, "HostConfig.CPUShares")
if out != "500" {
c.Fatalf("Got the wrong cpu shares value, we got %d, expected 500.", out)
}
c.Assert(inspectField(c, name, "HostConfig.CPUShares"), checker.Equals, "500")
dockerCmd(c, "unpause", name)
file := "/sys/fs/cgroup/cpu/cpu.shares"
out, _ = dockerCmd(c, "exec", name, "cat", file)
out, _ := dockerCmd(c, "exec", name, "cat", file)
c.Assert(strings.TrimSpace(out), checker.Equals, "500")
}
@ -137,23 +125,17 @@ func (s *DockerSuite) TestUpdateKernelMemory(c *check.C) {
// Update kernel memory to a running container is not allowed.
c.Assert(err, check.NotNil)
out := inspectField(c, name, "HostConfig.KernelMemory")
// Update kernel memory to a running container with failure should not change HostConfig
if out != "52428800" {
c.Fatalf("Got the wrong memory value, we got %d, expected 52428800(50M).", out)
}
c.Assert(inspectField(c, name, "HostConfig.KernelMemory"), checker.Equals, "52428800")
dockerCmd(c, "stop", name)
dockerCmd(c, "update", "--kernel-memory", "100M", name)
dockerCmd(c, "start", name)
out = inspectField(c, name, "HostConfig.KernelMemory")
if out != "104857600" {
c.Fatalf("Got the wrong memory value, we got %d, expected 104857600(100M).", out)
}
c.Assert(inspectField(c, name, "HostConfig.KernelMemory"), checker.Equals, "104857600")
file := "/sys/fs/cgroup/memory/memory.kmem.limit_in_bytes"
out, _ = dockerCmd(c, "exec", name, "cat", file)
out, _ := dockerCmd(c, "exec", name, "cat", file)
c.Assert(strings.TrimSpace(out), checker.Equals, "104857600")
}