1
0
mirror of https://github.com/moby/moby.git synced 2025-08-01 05:47:11 +03:00

Fix ineffassign linting

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2018-07-09 19:40:34 +02:00
parent f0585d04d0
commit ddd8a6572d
20 changed files with 74 additions and 64 deletions

View File

@ -1265,6 +1265,7 @@ func (s *DockerSuite) TestContainerAPIDeleteRemoveVolume(c *check.C) {
c.Assert(waitRun(id), checker.IsNil) c.Assert(waitRun(id), checker.IsNil)
source, err := inspectMountSourceField(id, vol) source, err := inspectMountSourceField(id, vol)
c.Assert(err, checker.IsNil)
_, err = os.Stat(source) _, err = os.Stat(source)
c.Assert(err, checker.IsNil) c.Assert(err, checker.IsNil)
@ -2201,6 +2202,7 @@ func (s *DockerSuite) TestContainerKillCustomStopSignal(c *check.C) {
defer res.Body.Close() defer res.Body.Close()
b, err := ioutil.ReadAll(res.Body) b, err := ioutil.ReadAll(res.Body)
c.Assert(err, checker.IsNil)
c.Assert(res.StatusCode, checker.Equals, http.StatusNoContent, check.Commentf(string(b))) c.Assert(res.StatusCode, checker.Equals, http.StatusNoContent, check.Commentf(string(b)))
err = waitInspect(id, "{{.State.Running}} {{.State.Restarting}}", "false false", 30*time.Second) err = waitInspect(id, "{{.State.Running}} {{.State.Restarting}}", "false false", 30*time.Second)
c.Assert(err, checker.IsNil) c.Assert(err, checker.IsNil)

View File

@ -1012,10 +1012,6 @@ func (s *DockerSuite) TestBuildAddBadLinksVolume(c *check.C) {
ADD foo.txt /x/` ADD foo.txt /x/`
targetFile = "foo.txt" targetFile = "foo.txt"
) )
var (
name = "test-link-absolute-volume"
dockerfile = ""
)
tempDir, err := ioutil.TempDir("", "test-link-absolute-volume-temp-") tempDir, err := ioutil.TempDir("", "test-link-absolute-volume-temp-")
if err != nil { if err != nil {
@ -1023,7 +1019,7 @@ func (s *DockerSuite) TestBuildAddBadLinksVolume(c *check.C) {
} }
defer os.RemoveAll(tempDir) defer os.RemoveAll(tempDir)
dockerfile = fmt.Sprintf(dockerfileTemplate, tempDir) dockerfile := fmt.Sprintf(dockerfileTemplate, tempDir)
nonExistingFile := filepath.Join(tempDir, targetFile) nonExistingFile := filepath.Join(tempDir, targetFile)
ctx := fakecontext.New(c, "", fakecontext.WithDockerfile(dockerfile)) ctx := fakecontext.New(c, "", fakecontext.WithDockerfile(dockerfile))
@ -1040,7 +1036,7 @@ func (s *DockerSuite) TestBuildAddBadLinksVolume(c *check.C) {
c.Fatal(err) c.Fatal(err)
} }
buildImageSuccessfully(c, name, build.WithExternalBuildContext(ctx)) buildImageSuccessfully(c, "test-link-absolute-volume", build.WithExternalBuildContext(ctx))
if _, err := os.Stat(nonExistingFile); err == nil || err != nil && !os.IsNotExist(err) { if _, err := os.Stat(nonExistingFile); err == nil || err != nil && !os.IsNotExist(err) {
c.Fatalf("%s shouldn't have been written and it shouldn't exist", nonExistingFile) c.Fatalf("%s shouldn't have been written and it shouldn't exist", nonExistingFile)
} }

View File

@ -46,8 +46,7 @@ func (s *DockerSuite) TestCommitPausedContainer(c *check.C) {
cleanedContainerID := strings.TrimSpace(out) cleanedContainerID := strings.TrimSpace(out)
dockerCmd(c, "pause", cleanedContainerID) dockerCmd(c, "pause", cleanedContainerID)
dockerCmd(c, "commit", cleanedContainerID)
out, _ = dockerCmd(c, "commit", cleanedContainerID)
out = inspectField(c, cleanedContainerID, "State.Paused") out = inspectField(c, cleanedContainerID, "State.Paused")
// commit should not unpause a paused container // commit should not unpause a paused container

View File

@ -78,6 +78,7 @@ func (s *DockerSwarmSuite) TestConfigCreateResolve(c *check.C) {
c.Assert(out, checker.Contains, fake) c.Assert(out, checker.Contains, fake)
out, err = d.Cmd("config", "rm", id) out, err = d.Cmd("config", "rm", id)
c.Assert(err, checker.IsNil)
c.Assert(out, checker.Contains, id) c.Assert(out, checker.Contains, id)
// Fake one will remain // Fake one will remain
@ -93,6 +94,7 @@ func (s *DockerSwarmSuite) TestConfigCreateResolve(c *check.C) {
// - Full Name // - Full Name
// - Partial ID (prefix) // - Partial ID (prefix)
out, err = d.Cmd("config", "rm", id[:5]) out, err = d.Cmd("config", "rm", id[:5])
c.Assert(err, checker.Not(checker.IsNil))
c.Assert(out, checker.Not(checker.Contains), id) c.Assert(out, checker.Not(checker.Contains), id)
out, err = d.Cmd("config", "ls") out, err = d.Cmd("config", "ls")
c.Assert(err, checker.IsNil) c.Assert(err, checker.IsNil)
@ -101,6 +103,7 @@ func (s *DockerSwarmSuite) TestConfigCreateResolve(c *check.C) {
// Remove based on ID prefix of the fake one should succeed // Remove based on ID prefix of the fake one should succeed
out, err = d.Cmd("config", "rm", fake[:5]) out, err = d.Cmd("config", "rm", fake[:5])
c.Assert(err, checker.IsNil)
c.Assert(out, checker.Contains, fake[:5]) c.Assert(out, checker.Contains, fake[:5])
out, err = d.Cmd("config", "ls") out, err = d.Cmd("config", "ls")
c.Assert(err, checker.IsNil) c.Assert(err, checker.IsNil)

View File

@ -423,6 +423,7 @@ func (s *DockerSuite) TestCpSpecialFiles(c *check.C) {
expected := readContainerFile(c, containerID, "resolv.conf") expected := readContainerFile(c, containerID, "resolv.conf")
actual, err := ioutil.ReadFile(outDir + "/resolv.conf") actual, err := ioutil.ReadFile(outDir + "/resolv.conf")
c.Assert(err, checker.IsNil)
// Expected copied file to be duplicate of the container resolvconf // Expected copied file to be duplicate of the container resolvconf
c.Assert(bytes.Equal(actual, expected), checker.True) c.Assert(bytes.Equal(actual, expected), checker.True)
@ -432,6 +433,7 @@ func (s *DockerSuite) TestCpSpecialFiles(c *check.C) {
expected = readContainerFile(c, containerID, "hosts") expected = readContainerFile(c, containerID, "hosts")
actual, err = ioutil.ReadFile(outDir + "/hosts") actual, err = ioutil.ReadFile(outDir + "/hosts")
c.Assert(err, checker.IsNil)
// Expected copied file to be duplicate of the container hosts // Expected copied file to be duplicate of the container hosts
c.Assert(bytes.Equal(actual, expected), checker.True) c.Assert(bytes.Equal(actual, expected), checker.True)
@ -639,6 +641,7 @@ func (s *DockerSuite) TestCpSymlinkFromConToHostFollowSymlink(c *check.C) {
expected := []byte(cpContainerContents) expected := []byte(cpContainerContents)
actual, err := ioutil.ReadFile(expectedPath) actual, err := ioutil.ReadFile(expectedPath)
c.Assert(err, checker.IsNil)
if !bytes.Equal(actual, expected) { if !bytes.Equal(actual, expected) {
c.Fatalf("Expected copied file to be duplicate of the container symbol link target") c.Fatalf("Expected copied file to be duplicate of the container symbol link target")

View File

@ -448,10 +448,10 @@ func (s *DockerDaemonSuite) TestDaemonIPv6FixedCIDRAndMac(c *check.C) {
s.d.StartWithBusybox(c, "--ipv6", "--fixed-cidr-v6=2001:db8:1::/64") s.d.StartWithBusybox(c, "--ipv6", "--fixed-cidr-v6=2001:db8:1::/64")
out, err := s.d.Cmd("run", "-itd", "--name=ipv6test", "--mac-address", "AA:BB:CC:DD:EE:FF", "busybox") _, err := s.d.Cmd("run", "-itd", "--name=ipv6test", "--mac-address", "AA:BB:CC:DD:EE:FF", "busybox")
c.Assert(err, checker.IsNil) c.Assert(err, checker.IsNil)
out, err = s.d.Cmd("inspect", "--format", "{{.NetworkSettings.Networks.bridge.GlobalIPv6Address}}", "ipv6test") out, err := s.d.Cmd("inspect", "--format", "{{.NetworkSettings.Networks.bridge.GlobalIPv6Address}}", "ipv6test")
c.Assert(err, checker.IsNil) c.Assert(err, checker.IsNil)
c.Assert(strings.Trim(out, " \r\n'"), checker.Equals, "2001:db8:1::aabb:ccdd:eeff") c.Assert(strings.Trim(out, " \r\n'"), checker.Equals, "2001:db8:1::aabb:ccdd:eeff")
} }
@ -742,6 +742,7 @@ func (s *DockerDaemonSuite) TestDaemonBridgeFixedCidr2(c *check.C) {
defer d.Cmd("stop", "bb") defer d.Cmd("stop", "bb")
out, err = d.Cmd("exec", "bb", "/bin/sh", "-c", "ifconfig eth0 | awk '/inet addr/{print substr($2,6)}'") out, err = d.Cmd("exec", "bb", "/bin/sh", "-c", "ifconfig eth0 | awk '/inet addr/{print substr($2,6)}'")
c.Assert(err, check.IsNil)
c.Assert(out, checker.Equals, "10.2.2.0\n") c.Assert(out, checker.Equals, "10.2.2.0\n")
out, err = d.Cmd("run", "--rm", "busybox", "/bin/sh", "-c", "ifconfig eth0 | awk '/inet addr/{print substr($2,6)}'") out, err = d.Cmd("run", "--rm", "busybox", "/bin/sh", "-c", "ifconfig eth0 | awk '/inet addr/{print substr($2,6)}'")
@ -1944,11 +1945,12 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithNames(c *check.C) {
test2ID := strings.TrimSpace(out) test2ID := strings.TrimSpace(out)
out, err = s.d.Cmd("run", "-d", "--name=test3", "--link", "test2:abc", "busybox", "top") out, err = s.d.Cmd("run", "-d", "--name=test3", "--link", "test2:abc", "busybox", "top")
c.Assert(err, check.IsNil)
test3ID := strings.TrimSpace(out) test3ID := strings.TrimSpace(out)
s.d.Restart(c) s.d.Restart(c)
out, err = s.d.Cmd("create", "--name=test", "busybox") _, err = s.d.Cmd("create", "--name=test", "busybox")
c.Assert(err, check.NotNil, check.Commentf("expected error trying to create container with duplicate name")) c.Assert(err, check.NotNil, check.Commentf("expected error trying to create container with duplicate name"))
// this one is no longer needed, removing simplifies the remainder of the test // this one is no longer needed, removing simplifies the remainder of the test
out, err = s.d.Cmd("rm", "-f", "test") out, err = s.d.Cmd("rm", "-f", "test")
@ -2615,6 +2617,7 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithAutoRemoveContainer(c *check.C)
c.Assert(err, checker.IsNil, check.Commentf("run top2: %v", out)) c.Assert(err, checker.IsNil, check.Commentf("run top2: %v", out))
out, err = s.d.Cmd("ps") out, err = s.d.Cmd("ps")
c.Assert(err, checker.IsNil)
c.Assert(out, checker.Contains, "top1", check.Commentf("top1 should be running")) c.Assert(out, checker.Contains, "top1", check.Commentf("top1 should be running"))
c.Assert(out, checker.Contains, "top2", check.Commentf("top2 should be running")) c.Assert(out, checker.Contains, "top2", check.Commentf("top2 should be running"))
@ -2639,11 +2642,11 @@ func (s *DockerDaemonSuite) TestDaemonRestartSaveContainerExitCode(c *check.C) {
// captured, so `.State.Error` is empty. // captured, so `.State.Error` is empty.
// See the discussion on https://github.com/docker/docker/pull/30227#issuecomment-274161426, // See the discussion on https://github.com/docker/docker/pull/30227#issuecomment-274161426,
// and https://github.com/docker/docker/pull/26061#r78054578 for more information. // and https://github.com/docker/docker/pull/26061#r78054578 for more information.
out, err := s.d.Cmd("run", "--name", containerName, "--init=false", "busybox", "toto") _, err := s.d.Cmd("run", "--name", containerName, "--init=false", "busybox", "toto")
c.Assert(err, checker.NotNil) c.Assert(err, checker.NotNil)
// Check that those values were saved on disk // Check that those values were saved on disk
out, err = s.d.Cmd("inspect", "-f", "{{.State.ExitCode}}", containerName) out, err := s.d.Cmd("inspect", "-f", "{{.State.ExitCode}}", containerName)
out = strings.TrimSpace(out) out = strings.TrimSpace(out)
c.Assert(err, checker.IsNil) c.Assert(err, checker.IsNil)
c.Assert(out, checker.Equals, "127") c.Assert(out, checker.Equals, "127")

View File

@ -81,7 +81,7 @@ func (s *DockerSuite) TestHealth(c *check.C) {
dockerCmd(c, "rm", "-f", name) dockerCmd(c, "rm", "-f", name)
// Disable the check from the CLI // Disable the check from the CLI
out, _ = dockerCmd(c, "create", "--name=noh", "--no-healthcheck", imageName) dockerCmd(c, "create", "--name=noh", "--no-healthcheck", imageName)
out, _ = dockerCmd(c, "inspect", "--format={{.Config.Healthcheck.Test}}", "noh") out, _ = dockerCmd(c, "inspect", "--format={{.Config.Healthcheck.Test}}", "noh")
c.Check(out, checker.Equals, "[NONE]\n") c.Check(out, checker.Equals, "[NONE]\n")
dockerCmd(c, "rm", "noh") dockerCmd(c, "rm", "noh")

View File

@ -181,14 +181,14 @@ func (s *DockerSuite) TestLogsSinceFutureFollow(c *check.C) {
// TODO Windows TP5 - Figure out why this test is so flakey. Disabled for now. // TODO Windows TP5 - Figure out why this test is so flakey. Disabled for now.
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
name := "testlogssincefuturefollow" name := "testlogssincefuturefollow"
out, _ := dockerCmd(c, "run", "-d", "--name", name, "busybox", "/bin/sh", "-c", `for i in $(seq 1 5); do echo log$i; sleep 1; done`) dockerCmd(c, "run", "-d", "--name", name, "busybox", "/bin/sh", "-c", `for i in $(seq 1 5); do echo log$i; sleep 1; done`)
// Extract one timestamp from the log file to give us a starting point for // Extract one timestamp from the log file to give us a starting point for
// our `--since` argument. Because the log producer runs in the background, // our `--since` argument. Because the log producer runs in the background,
// we need to check repeatedly for some output to be produced. // we need to check repeatedly for some output to be produced.
var timestamp string var timestamp string
for i := 0; i != 100 && timestamp == ""; i++ { for i := 0; i != 100 && timestamp == ""; i++ {
if out, _ = dockerCmd(c, "logs", "-t", name); out == "" { if out, _ := dockerCmd(c, "logs", "-t", name); out == "" {
time.Sleep(time.Millisecond * 100) // Retry time.Sleep(time.Millisecond * 100) // Retry
} else { } else {
timestamp = strings.Split(strings.Split(out, "\n")[0], " ")[0] timestamp = strings.Split(strings.Split(out, "\n")[0], " ")[0]
@ -200,7 +200,7 @@ func (s *DockerSuite) TestLogsSinceFutureFollow(c *check.C) {
c.Assert(err, check.IsNil) c.Assert(err, check.IsNil)
since := t.Unix() + 2 since := t.Unix() + 2
out, _ = dockerCmd(c, "logs", "-t", "-f", fmt.Sprintf("--since=%v", since), name) out, _ := dockerCmd(c, "logs", "-t", "-f", fmt.Sprintf("--since=%v", since), name)
c.Assert(out, checker.Not(checker.HasLen), 0, check.Commentf("cannot read from empty log")) c.Assert(out, checker.Not(checker.HasLen), 0, check.Commentf("cannot read from empty log"))
lines := strings.Split(strings.TrimSpace(out), "\n") lines := strings.Split(strings.TrimSpace(out), "\n")
for _, v := range lines { for _, v := range lines {

View File

@ -348,7 +348,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkLsFilter(c *check.C) {
out, _ = dockerCmd(c, "network", "ls", "-f", "type=custom", "-f", "type=builtin") out, _ = dockerCmd(c, "network", "ls", "-f", "type=custom", "-f", "type=builtin")
assertNwList(c, out, []string{"bridge", "dev", "host", "none"}) assertNwList(c, out, []string{"bridge", "dev", "host", "none"})
out, _ = dockerCmd(c, "network", "create", "--label", testLabel+"="+testValue, testNet) dockerCmd(c, "network", "create", "--label", testLabel+"="+testValue, testNet)
assertNwIsAvailable(c, testNet) assertNwIsAvailable(c, testNet)
out, _ = dockerCmd(c, "network", "ls", "-f", "label="+testLabel) out, _ = dockerCmd(c, "network", "ls", "-f", "label="+testLabel)
@ -880,8 +880,6 @@ func (s *DockerNetworkSuite) TestDockerNetworkAnonymousEndpoint(c *check.C) {
out, _ = dockerCmd(c, "run", "-d", "--net", cstmBridgeNw, "busybox", "top") out, _ = dockerCmd(c, "run", "-d", "--net", cstmBridgeNw, "busybox", "top")
cid2 := strings.TrimSpace(out) cid2 := strings.TrimSpace(out)
hosts2 := readContainerFileWithExec(c, cid2, hostsFile)
// verify first container etc/hosts file has not changed // verify first container etc/hosts file has not changed
hosts1post := readContainerFileWithExec(c, cid1, hostsFile) hosts1post := readContainerFileWithExec(c, cid1, hostsFile)
c.Assert(string(hosts1), checker.Equals, string(hosts1post), c.Assert(string(hosts1), checker.Equals, string(hosts1post),
@ -894,7 +892,7 @@ func (s *DockerNetworkSuite) TestDockerNetworkAnonymousEndpoint(c *check.C) {
dockerCmd(c, "network", "connect", cstmBridgeNw1, cid2) dockerCmd(c, "network", "connect", cstmBridgeNw1, cid2)
hosts2 = readContainerFileWithExec(c, cid2, hostsFile) hosts2 := readContainerFileWithExec(c, cid2, hostsFile)
hosts1post = readContainerFileWithExec(c, cid1, hostsFile) hosts1post = readContainerFileWithExec(c, cid1, hostsFile)
c.Assert(string(hosts1), checker.Equals, string(hosts1post), c.Assert(string(hosts1), checker.Equals, string(hosts1post),
check.Commentf("Unexpected %s change on container connect", hostsFile)) check.Commentf("Unexpected %s change on container connect", hostsFile))

View File

@ -62,10 +62,10 @@ func (ps *DockerPluginSuite) TestPluginBasicOps(c *check.C) {
func (ps *DockerPluginSuite) TestPluginForceRemove(c *check.C) { func (ps *DockerPluginSuite) TestPluginForceRemove(c *check.C) {
pNameWithTag := ps.getPluginRepoWithTag() pNameWithTag := ps.getPluginRepoWithTag()
out, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", pNameWithTag) _, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", pNameWithTag)
c.Assert(err, checker.IsNil) c.Assert(err, checker.IsNil)
out, _, err = dockerCmdWithError("plugin", "remove", pNameWithTag) out, _, _ := dockerCmdWithError("plugin", "remove", pNameWithTag)
c.Assert(out, checker.Contains, "is enabled") c.Assert(out, checker.Contains, "is enabled")
out, _, err = dockerCmdWithError("plugin", "remove", "--force", pNameWithTag) out, _, err = dockerCmdWithError("plugin", "remove", "--force", pNameWithTag)
@ -82,7 +82,7 @@ func (s *DockerSuite) TestPluginActive(c *check.C) {
_, _, err = dockerCmdWithError("volume", "create", "-d", pNameWithTag, "--name", "testvol1") _, _, err = dockerCmdWithError("volume", "create", "-d", pNameWithTag, "--name", "testvol1")
c.Assert(err, checker.IsNil) c.Assert(err, checker.IsNil)
out, _, err := dockerCmdWithError("plugin", "disable", pNameWithTag) out, _, _ := dockerCmdWithError("plugin", "disable", pNameWithTag)
c.Assert(out, checker.Contains, "in use") c.Assert(out, checker.Contains, "in use")
_, _, err = dockerCmdWithError("volume", "rm", "testvol1") _, _, err = dockerCmdWithError("volume", "rm", "testvol1")
@ -98,21 +98,21 @@ func (s *DockerSuite) TestPluginActive(c *check.C) {
func (s *DockerSuite) TestPluginActiveNetwork(c *check.C) { func (s *DockerSuite) TestPluginActiveNetwork(c *check.C) {
testRequires(c, DaemonIsLinux, IsAmd64, Network) testRequires(c, DaemonIsLinux, IsAmd64, Network)
out, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", npNameWithTag) _, _, err := dockerCmdWithError("plugin", "install", "--grant-all-permissions", npNameWithTag)
c.Assert(err, checker.IsNil) c.Assert(err, checker.IsNil)
out, _, err = dockerCmdWithError("network", "create", "-d", npNameWithTag, "test") out, _, err := dockerCmdWithError("network", "create", "-d", npNameWithTag, "test")
c.Assert(err, checker.IsNil) c.Assert(err, checker.IsNil)
nID := strings.TrimSpace(out) nID := strings.TrimSpace(out)
out, _, err = dockerCmdWithError("plugin", "remove", npNameWithTag) out, _, _ = dockerCmdWithError("plugin", "remove", npNameWithTag)
c.Assert(out, checker.Contains, "is in use") c.Assert(out, checker.Contains, "is in use")
_, _, err = dockerCmdWithError("network", "rm", nID) _, _, err = dockerCmdWithError("network", "rm", nID)
c.Assert(err, checker.IsNil) c.Assert(err, checker.IsNil)
out, _, err = dockerCmdWithError("plugin", "remove", npNameWithTag) out, _, _ = dockerCmdWithError("plugin", "remove", npNameWithTag)
c.Assert(out, checker.Contains, "is enabled") c.Assert(out, checker.Contains, "is enabled")
_, _, err = dockerCmdWithError("plugin", "disable", npNameWithTag) _, _, err = dockerCmdWithError("plugin", "disable", npNameWithTag)
@ -400,7 +400,7 @@ func (ps *DockerPluginSuite) TestPluginIDPrefix(c *check.C) {
c.Assert(out, checker.Contains, "false") c.Assert(out, checker.Contains, "false")
// Remove // Remove
out, _, err = dockerCmdWithError("plugin", "remove", id[:5]) _, _, err = dockerCmdWithError("plugin", "remove", id[:5])
c.Assert(err, checker.IsNil) c.Assert(err, checker.IsNil)
// List returns none // List returns none
out, _, err = dockerCmdWithError("plugin", "ls") out, _, err = dockerCmdWithError("plugin", "ls")

View File

@ -792,19 +792,14 @@ func (s *DockerSuite) TestPsListContainersFilterNetwork(c *check.C) {
} }
func (s *DockerSuite) TestPsByOrder(c *check.C) { func (s *DockerSuite) TestPsByOrder(c *check.C) {
name1 := "xyz-abc" out := runSleepingContainer(c, "--name", "xyz-abc")
out := runSleepingContainer(c, "--name", name1)
container1 := strings.TrimSpace(out) container1 := strings.TrimSpace(out)
name2 := "xyz-123" out = runSleepingContainer(c, "--name", "xyz-123")
out = runSleepingContainer(c, "--name", name2)
container2 := strings.TrimSpace(out) container2 := strings.TrimSpace(out)
name3 := "789-abc" runSleepingContainer(c, "--name", "789-abc")
out = runSleepingContainer(c, "--name", name3) runSleepingContainer(c, "--name", "789-123")
name4 := "789-123"
out = runSleepingContainer(c, "--name", name4)
// Run multiple time should have the same result // Run multiple time should have the same result
out = cli.DockerCmd(c, "ps", "--no-trunc", "-q", "-f", "name=xyz").Combined() out = cli.DockerCmd(c, "ps", "--no-trunc", "-q", "-f", "name=xyz").Combined()

View File

@ -224,6 +224,7 @@ func (s *DockerSuite) TestRestartWithPolicyUserDefinedNetwork(c *check.C) {
c.Assert(err, check.IsNil) c.Assert(err, check.IsNil)
err = waitInspect("second", "{{.State.Status}}", "running", 5*time.Second) err = waitInspect("second", "{{.State.Status}}", "running", 5*time.Second)
c.Assert(err, check.IsNil)
// ping to first and its alias foo must still succeed // ping to first and its alias foo must still succeed
_, _, err = dockerCmdWithError("exec", "second", "ping", "-c", "1", "first") _, _, err = dockerCmdWithError("exec", "second", "ping", "-c", "1", "first")

View File

@ -623,6 +623,7 @@ func (s *DockerSuite) TestRunCreateVolumeWithSymlink(c *check.C) {
// Cannot run on Windows as relies on Linux-specific functionality (sh -c mount...) // Cannot run on Windows as relies on Linux-specific functionality (sh -c mount...)
testRequires(c, DaemonIsLinux) testRequires(c, DaemonIsLinux)
workingDirectory, err := ioutil.TempDir("", "TestRunCreateVolumeWithSymlink") workingDirectory, err := ioutil.TempDir("", "TestRunCreateVolumeWithSymlink")
c.Assert(err, checker.IsNil)
image := "docker-test-createvolumewithsymlink" image := "docker-test-createvolumewithsymlink"
buildCmd := exec.Command(dockerBinary, "build", "-t", image, "-") buildCmd := exec.Command(dockerBinary, "build", "-t", image, "-")

View File

@ -39,6 +39,7 @@ func (s *DockerSwarmSuite) TestSecretCreateResolve(c *check.C) {
c.Assert(out, checker.Contains, fake) c.Assert(out, checker.Contains, fake)
out, err = d.Cmd("secret", "rm", id) out, err = d.Cmd("secret", "rm", id)
c.Assert(err, checker.IsNil)
c.Assert(out, checker.Contains, id) c.Assert(out, checker.Contains, id)
// Fake one will remain // Fake one will remain
@ -54,6 +55,7 @@ func (s *DockerSwarmSuite) TestSecretCreateResolve(c *check.C) {
// - Full Name // - Full Name
// - Partial ID (prefix) // - Partial ID (prefix)
out, err = d.Cmd("secret", "rm", id[:5]) out, err = d.Cmd("secret", "rm", id[:5])
c.Assert(err, checker.Not(checker.IsNil))
c.Assert(out, checker.Not(checker.Contains), id) c.Assert(out, checker.Not(checker.Contains), id)
out, err = d.Cmd("secret", "ls") out, err = d.Cmd("secret", "ls")
c.Assert(err, checker.IsNil) c.Assert(err, checker.IsNil)
@ -62,6 +64,7 @@ func (s *DockerSwarmSuite) TestSecretCreateResolve(c *check.C) {
// Remove based on ID prefix of the fake one should succeed // Remove based on ID prefix of the fake one should succeed
out, err = d.Cmd("secret", "rm", fake[:5]) out, err = d.Cmd("secret", "rm", fake[:5])
c.Assert(err, checker.IsNil)
c.Assert(out, checker.Contains, fake[:5]) c.Assert(out, checker.Contains, fake[:5])
out, err = d.Cmd("secret", "ls") out, err = d.Cmd("secret", "ls")
c.Assert(err, checker.IsNil) c.Assert(err, checker.IsNil)

View File

@ -21,16 +21,16 @@ func (s *DockerSwarmSuite) TestServiceScale(c *check.C) {
service2Args := append([]string{"service", "create", "--detach", "--no-resolve-image", "--name", service2Name, "--mode=global", defaultSleepImage}, sleepCommandForDaemonPlatform()...) service2Args := append([]string{"service", "create", "--detach", "--no-resolve-image", "--name", service2Name, "--mode=global", defaultSleepImage}, sleepCommandForDaemonPlatform()...)
// Create services // Create services
out, err := d.Cmd(service1Args...) _, err := d.Cmd(service1Args...)
c.Assert(err, checker.IsNil) c.Assert(err, checker.IsNil)
out, err = d.Cmd(service2Args...) _, err = d.Cmd(service2Args...)
c.Assert(err, checker.IsNil) c.Assert(err, checker.IsNil)
out, err = d.Cmd("service", "scale", "TestService1=2") _, err = d.Cmd("service", "scale", "TestService1=2")
c.Assert(err, checker.IsNil) c.Assert(err, checker.IsNil)
out, err = d.Cmd("service", "scale", "TestService1=foobar") out, err := d.Cmd("service", "scale", "TestService1=foobar")
c.Assert(err, checker.NotNil) c.Assert(err, checker.NotNil)
str := fmt.Sprintf("%s: invalid replicas value %s", service1Name, "foobar") str := fmt.Sprintf("%s: invalid replicas value %s", service1Name, "foobar")

View File

@ -279,13 +279,13 @@ func (s *DockerSwarmSuite) TestSwarmPublishAdd(c *check.C) {
c.Assert(err, checker.IsNil) c.Assert(err, checker.IsNil)
c.Assert(strings.TrimSpace(out), checker.Not(checker.Equals), "") c.Assert(strings.TrimSpace(out), checker.Not(checker.Equals), "")
out, err = d.Cmd("service", "update", "--detach", "--publish-add", "80:80", name) _, err = d.Cmd("service", "update", "--detach", "--publish-add", "80:80", name)
c.Assert(err, checker.IsNil) c.Assert(err, checker.IsNil)
out, err = d.Cmd("service", "update", "--detach", "--publish-add", "80:80", name) _, err = d.Cmd("service", "update", "--detach", "--publish-add", "80:80", name)
c.Assert(err, checker.IsNil) c.Assert(err, checker.IsNil)
out, err = d.Cmd("service", "update", "--detach", "--publish-add", "80:80", "--publish-add", "80:20", name) _, err = d.Cmd("service", "update", "--detach", "--publish-add", "80:80", "--publish-add", "80:20", name)
c.Assert(err, checker.NotNil) c.Assert(err, checker.NotNil)
out, err = d.Cmd("service", "inspect", "--format", "{{ .Spec.EndpointSpec.Ports }}", name) out, err = d.Cmd("service", "inspect", "--format", "{{ .Spec.EndpointSpec.Ports }}", name)
@ -841,14 +841,14 @@ func (s *DockerSwarmSuite) TestSwarmServiceTTY(c *check.C) {
// Without --tty // Without --tty
expectedOutput := "none" expectedOutput := "none"
out, err := d.Cmd("service", "create", "--detach", "--no-resolve-image", "--name", name, "busybox", "sh", "-c", ttyCheck) _, err := d.Cmd("service", "create", "--detach", "--no-resolve-image", "--name", name, "busybox", "sh", "-c", ttyCheck)
c.Assert(err, checker.IsNil) c.Assert(err, checker.IsNil)
// Make sure task has been deployed. // Make sure task has been deployed.
waitAndAssert(c, defaultReconciliationTimeout, d.CheckActiveContainerCount, checker.Equals, 1) waitAndAssert(c, defaultReconciliationTimeout, d.CheckActiveContainerCount, checker.Equals, 1)
// We need to get the container id. // We need to get the container id.
out, err = d.Cmd("ps", "-q", "--no-trunc") out, err := d.Cmd("ps", "-q", "--no-trunc")
c.Assert(err, checker.IsNil) c.Assert(err, checker.IsNil)
id := strings.TrimSpace(out) id := strings.TrimSpace(out)
@ -857,14 +857,14 @@ func (s *DockerSwarmSuite) TestSwarmServiceTTY(c *check.C) {
c.Assert(out, checker.Contains, expectedOutput, check.Commentf("Expected '%s', but got %q", expectedOutput, out)) c.Assert(out, checker.Contains, expectedOutput, check.Commentf("Expected '%s', but got %q", expectedOutput, out))
// Remove service // Remove service
out, err = d.Cmd("service", "rm", name) _, err = d.Cmd("service", "rm", name)
c.Assert(err, checker.IsNil) c.Assert(err, checker.IsNil)
// Make sure container has been destroyed. // Make sure container has been destroyed.
waitAndAssert(c, defaultReconciliationTimeout, d.CheckActiveContainerCount, checker.Equals, 0) waitAndAssert(c, defaultReconciliationTimeout, d.CheckActiveContainerCount, checker.Equals, 0)
// With --tty // With --tty
expectedOutput = "TTY" expectedOutput = "TTY"
out, err = d.Cmd("service", "create", "--detach", "--no-resolve-image", "--name", name, "--tty", "busybox", "sh", "-c", ttyCheck) _, err = d.Cmd("service", "create", "--detach", "--no-resolve-image", "--name", name, "--tty", "busybox", "sh", "-c", ttyCheck)
c.Assert(err, checker.IsNil) c.Assert(err, checker.IsNil)
// Make sure task has been deployed. // Make sure task has been deployed.
@ -1069,6 +1069,7 @@ func (s *DockerSwarmSuite) TestSwarmInitLocked(c *check.C) {
c.Assert(unlockKey, checker.Not(checker.Equals), "") c.Assert(unlockKey, checker.Not(checker.Equals), "")
outs, err = d.Cmd("swarm", "unlock-key", "-q") outs, err = d.Cmd("swarm", "unlock-key", "-q")
c.Assert(err, checker.IsNil)
c.Assert(outs, checker.Equals, unlockKey+"\n") c.Assert(outs, checker.Equals, unlockKey+"\n")
c.Assert(getNodeStatus(c, d), checker.Equals, swarm.LocalNodeStateActive) c.Assert(getNodeStatus(c, d), checker.Equals, swarm.LocalNodeStateActive)
@ -1168,6 +1169,7 @@ func (s *DockerSwarmSuite) TestSwarmLockUnlockCluster(c *check.C) {
c.Assert(unlockKey, checker.Not(checker.Equals), "") c.Assert(unlockKey, checker.Not(checker.Equals), "")
outs, err = d1.Cmd("swarm", "unlock-key", "-q") outs, err = d1.Cmd("swarm", "unlock-key", "-q")
c.Assert(err, checker.IsNil)
c.Assert(outs, checker.Equals, unlockKey+"\n") c.Assert(outs, checker.Equals, unlockKey+"\n")
// The ones that got the cluster update should be set to locked // The ones that got the cluster update should be set to locked
@ -1234,6 +1236,7 @@ func (s *DockerSwarmSuite) TestSwarmJoinPromoteLocked(c *check.C) {
c.Assert(unlockKey, checker.Not(checker.Equals), "") c.Assert(unlockKey, checker.Not(checker.Equals), "")
outs, err = d1.Cmd("swarm", "unlock-key", "-q") outs, err = d1.Cmd("swarm", "unlock-key", "-q")
c.Assert(err, checker.IsNil)
c.Assert(outs, checker.Equals, unlockKey+"\n") c.Assert(outs, checker.Equals, unlockKey+"\n")
// joined workers start off unlocked // joined workers start off unlocked
@ -1306,6 +1309,7 @@ func (s *DockerSwarmSuite) TestSwarmRotateUnlockKey(c *check.C) {
c.Assert(unlockKey, checker.Not(checker.Equals), "") c.Assert(unlockKey, checker.Not(checker.Equals), "")
outs, err = d.Cmd("swarm", "unlock-key", "-q") outs, err = d.Cmd("swarm", "unlock-key", "-q")
c.Assert(err, checker.IsNil)
c.Assert(outs, checker.Equals, unlockKey+"\n") c.Assert(outs, checker.Equals, unlockKey+"\n")
// Rotate multiple times // Rotate multiple times
@ -1390,6 +1394,7 @@ func (s *DockerSwarmSuite) TestSwarmClusterRotateUnlockKey(c *check.C) {
c.Assert(unlockKey, checker.Not(checker.Equals), "") c.Assert(unlockKey, checker.Not(checker.Equals), "")
outs, err = d1.Cmd("swarm", "unlock-key", "-q") outs, err = d1.Cmd("swarm", "unlock-key", "-q")
c.Assert(err, checker.IsNil)
c.Assert(outs, checker.Equals, unlockKey+"\n") c.Assert(outs, checker.Equals, unlockKey+"\n")
// Rotate multiple times // Rotate multiple times

View File

@ -26,6 +26,7 @@ func (s *DockerSwarmSuite) TestSwarmVolumePlugin(c *check.C) {
// create a dummy volume to trigger lazy loading of the plugin // create a dummy volume to trigger lazy loading of the plugin
out, err = d.Cmd("volume", "create", "-d", "customvolumedriver", "hello") out, err = d.Cmd("volume", "create", "-d", "customvolumedriver", "hello")
c.Assert(err, checker.IsNil, check.Commentf(out))
// TODO(aaronl): It will take about 15 seconds for swarm to realize the // TODO(aaronl): It will take about 15 seconds for swarm to realize the
// plugin was loaded. Switching the test over to plugin v2 would avoid // plugin was loaded. Switching the test over to plugin v2 would avoid

View File

@ -324,7 +324,7 @@ func (s *DockerSuite) TestUpdateWithNanoCPUs(c *check.C) {
c.Assert(err, checker.NotNil) c.Assert(err, checker.NotNil)
c.Assert(out, checker.Contains, "Conflicting options: CPU Quota cannot be updated as NanoCPUs has already been set") c.Assert(out, checker.Contains, "Conflicting options: CPU Quota cannot be updated as NanoCPUs has already been set")
out, _ = dockerCmd(c, "update", "--cpus", "0.8", "top") dockerCmd(c, "update", "--cpus", "0.8", "top")
inspect, err = clt.ContainerInspect(context.Background(), "top") inspect, err = clt.ContainerInspect(context.Background(), "top")
c.Assert(err, checker.IsNil) c.Assert(err, checker.IsNil)
c.Assert(inspect.HostConfig.NanoCPUs, checker.Equals, int64(800000000)) c.Assert(inspect.HostConfig.NanoCPUs, checker.Equals, int64(800000000))

View File

@ -61,12 +61,12 @@ func (s *DockerDaemonSuite) TestDaemonUserNamespaceRootSetting(c *check.C) {
c.Assert(err, checker.IsNil, check.Commentf("Could not inspect running container: out: %q", pid)) c.Assert(err, checker.IsNil, check.Commentf("Could not inspect running container: out: %q", pid))
// check the uid and gid maps for the PID to ensure root is remapped // check the uid and gid maps for the PID to ensure root is remapped
// (cmd = cat /proc/<pid>/uid_map | grep -E '0\s+9999\s+1') // (cmd = cat /proc/<pid>/uid_map | grep -E '0\s+9999\s+1')
out, err = RunCommandPipelineWithOutput( _, err = RunCommandPipelineWithOutput(
exec.Command("cat", "/proc/"+strings.TrimSpace(pid)+"/uid_map"), exec.Command("cat", "/proc/"+strings.TrimSpace(pid)+"/uid_map"),
exec.Command("grep", "-E", fmt.Sprintf("0[[:space:]]+%d[[:space:]]+", uid))) exec.Command("grep", "-E", fmt.Sprintf("0[[:space:]]+%d[[:space:]]+", uid)))
c.Assert(err, check.IsNil) c.Assert(err, check.IsNil)
out, err = RunCommandPipelineWithOutput( _, err = RunCommandPipelineWithOutput(
exec.Command("cat", "/proc/"+strings.TrimSpace(pid)+"/gid_map"), exec.Command("cat", "/proc/"+strings.TrimSpace(pid)+"/gid_map"),
exec.Command("grep", "-E", fmt.Sprintf("0[[:space:]]+%d[[:space:]]+", gid))) exec.Command("grep", "-E", fmt.Sprintf("0[[:space:]]+%d[[:space:]]+", gid)))
c.Assert(err, check.IsNil) c.Assert(err, check.IsNil)

View File

@ -300,10 +300,10 @@ func (s *DockerSuite) TestVolumeCLICreateLabel(c *check.C) {
testLabel := "foo" testLabel := "foo"
testValue := "bar" testValue := "bar"
out, _, err := dockerCmdWithError("volume", "create", "--label", testLabel+"="+testValue, testVol) _, _, err := dockerCmdWithError("volume", "create", "--label", testLabel+"="+testValue, testVol)
c.Assert(err, check.IsNil) c.Assert(err, check.IsNil)
out, _ = dockerCmd(c, "volume", "inspect", "--format={{ .Labels."+testLabel+" }}", testVol) out, _ := dockerCmd(c, "volume", "inspect", "--format={{ .Labels."+testLabel+" }}", testVol)
c.Assert(strings.TrimSpace(out), check.Equals, testValue) c.Assert(strings.TrimSpace(out), check.Equals, testValue)
} }
@ -325,25 +325,25 @@ func (s *DockerSuite) TestVolumeCLICreateLabelMultiple(c *check.C) {
args = append(args, "--label", k+"="+v) args = append(args, "--label", k+"="+v)
} }
out, _, err := dockerCmdWithError(args...) _, _, err := dockerCmdWithError(args...)
c.Assert(err, check.IsNil) c.Assert(err, check.IsNil)
for k, v := range testLabels { for k, v := range testLabels {
out, _ = dockerCmd(c, "volume", "inspect", "--format={{ .Labels."+k+" }}", testVol) out, _ := dockerCmd(c, "volume", "inspect", "--format={{ .Labels."+k+" }}", testVol)
c.Assert(strings.TrimSpace(out), check.Equals, v) c.Assert(strings.TrimSpace(out), check.Equals, v)
} }
} }
func (s *DockerSuite) TestVolumeCLILsFilterLabels(c *check.C) { func (s *DockerSuite) TestVolumeCLILsFilterLabels(c *check.C) {
testVol1 := "testvolcreatelabel-1" testVol1 := "testvolcreatelabel-1"
out, _, err := dockerCmdWithError("volume", "create", "--label", "foo=bar1", testVol1) _, _, err := dockerCmdWithError("volume", "create", "--label", "foo=bar1", testVol1)
c.Assert(err, check.IsNil) c.Assert(err, check.IsNil)
testVol2 := "testvolcreatelabel-2" testVol2 := "testvolcreatelabel-2"
out, _, err = dockerCmdWithError("volume", "create", "--label", "foo=bar2", testVol2) _, _, err = dockerCmdWithError("volume", "create", "--label", "foo=bar2", testVol2)
c.Assert(err, check.IsNil) c.Assert(err, check.IsNil)
out, _ = dockerCmd(c, "volume", "ls", "--filter", "label=foo") out, _ := dockerCmd(c, "volume", "ls", "--filter", "label=foo")
// filter with label=key // filter with label=key
c.Assert(out, checker.Contains, "testvolcreatelabel-1\n", check.Commentf("expected volume 'testvolcreatelabel-1' in output")) c.Assert(out, checker.Contains, "testvolcreatelabel-1\n", check.Commentf("expected volume 'testvolcreatelabel-1' in output"))
@ -367,15 +367,15 @@ func (s *DockerSuite) TestVolumeCLILsFilterLabels(c *check.C) {
func (s *DockerSuite) TestVolumeCLILsFilterDrivers(c *check.C) { func (s *DockerSuite) TestVolumeCLILsFilterDrivers(c *check.C) {
// using default volume driver local to create volumes // using default volume driver local to create volumes
testVol1 := "testvol-1" testVol1 := "testvol-1"
out, _, err := dockerCmdWithError("volume", "create", testVol1) _, _, err := dockerCmdWithError("volume", "create", testVol1)
c.Assert(err, check.IsNil) c.Assert(err, check.IsNil)
testVol2 := "testvol-2" testVol2 := "testvol-2"
out, _, err = dockerCmdWithError("volume", "create", testVol2) _, _, err = dockerCmdWithError("volume", "create", testVol2)
c.Assert(err, check.IsNil) c.Assert(err, check.IsNil)
// filter with driver=local // filter with driver=local
out, _ = dockerCmd(c, "volume", "ls", "--filter", "driver=local") out, _ := dockerCmd(c, "volume", "ls", "--filter", "driver=local")
c.Assert(out, checker.Contains, "testvol-1\n", check.Commentf("expected volume 'testvol-1' in output")) c.Assert(out, checker.Contains, "testvol-1\n", check.Commentf("expected volume 'testvol-1' in output"))
c.Assert(out, checker.Contains, "testvol-2\n", check.Commentf("expected volume 'testvol-2' in output")) c.Assert(out, checker.Contains, "testvol-2\n", check.Commentf("expected volume 'testvol-2' in output"))
@ -434,7 +434,7 @@ func (s *DockerSuite) TestVolumeCLIRmForceInUse(c *check.C) {
c.Assert(id, checker.Equals, name) c.Assert(id, checker.Equals, name)
prefix, slash := getPrefixAndSlashFromDaemonPlatform() prefix, slash := getPrefixAndSlashFromDaemonPlatform()
out, e := dockerCmd(c, "create", "-v", "testvolume:"+prefix+slash+"foo", "busybox") out, _ = dockerCmd(c, "create", "-v", "testvolume:"+prefix+slash+"foo", "busybox")
cid := strings.TrimSpace(out) cid := strings.TrimSpace(out)
_, _, err := dockerCmdWithError("volume", "rm", "-f", name) _, _, err := dockerCmdWithError("volume", "rm", "-f", name)
@ -454,7 +454,7 @@ func (s *DockerSuite) TestVolumeCLIRmForceInUse(c *check.C) {
c.Assert(out, checker.Contains, name) c.Assert(out, checker.Contains, name)
// Verify removing the volume after the container is removed works // Verify removing the volume after the container is removed works
_, e = dockerCmd(c, "rm", cid) _, e := dockerCmd(c, "rm", cid)
c.Assert(e, check.Equals, 0) c.Assert(e, check.Equals, 0)
_, e = dockerCmd(c, "volume", "rm", "-f", name) _, e = dockerCmd(c, "volume", "rm", "-f", name)