diff --git a/integration-cli/docker_api_containers_test.go b/integration-cli/docker_api_containers_test.go index cabbfc2045..b76eb6ba2a 100644 --- a/integration-cli/docker_api_containers_test.go +++ b/integration-cli/docker_api_containers_test.go @@ -627,7 +627,7 @@ func TestContainerApiPause(t *testing.T) { func TestContainerApiTop(t *testing.T) { defer deleteAllContainers() - out, _, _ := dockerCmd(t, "run", "-d", "-i", "busybox", "/bin/sh", "-c", "cat") + out, _ := dockerCmd(t, "run", "-d", "-i", "busybox", "/bin/sh", "-c", "cat") id := strings.TrimSpace(out) if err := waitRun(id); err != nil { t.Fatal(err) @@ -667,7 +667,7 @@ func TestContainerApiTop(t *testing.T) { } func TestContainerApiCommit(t *testing.T) { - out, _, _ := dockerCmd(t, "run", "-d", "busybox", "/bin/sh", "-c", "touch /test") + out, _ := dockerCmd(t, "run", "-d", "busybox", "/bin/sh", "-c", "touch /test") id := strings.TrimSpace(out) name := "testcommit" @@ -714,7 +714,7 @@ func TestContainerApiCreate(t *testing.T) { t.Fatal(err) } - out, _, _ := dockerCmd(t, "start", "-a", container.Id) + out, _ := dockerCmd(t, "start", "-a", container.Id) if strings.TrimSpace(out) != "/test" { t.Fatalf("expected output `/test`, got %q", out) } diff --git a/integration-cli/docker_api_images_test.go b/integration-cli/docker_api_images_test.go index 083d63204f..276ee7f3c7 100644 --- a/integration-cli/docker_api_images_test.go +++ b/integration-cli/docker_api_images_test.go @@ -91,7 +91,7 @@ func TestApiImagesSaveAndLoad(t *testing.T) { } defer loadBody.Close() - out, _, _ = dockerCmd(t, "inspect", "--format='{{ .Id }}'", id) + out, _ = dockerCmd(t, "inspect", "--format='{{ .Id }}'", id) if strings.TrimSpace(out) != id { t.Fatal("load did not work properly") } diff --git a/integration-cli/docker_cli_attach_test.go b/integration-cli/docker_cli_attach_test.go index 04cb593989..08b109f883 100644 --- a/integration-cli/docker_cli_attach_test.go +++ b/integration-cli/docker_cli_attach_test.go @@ -138,7 +138,7 @@ func TestAttachTtyWithoutStdin(t *testing.T) { func TestAttachDisconnect(t *testing.T) { defer deleteAllContainers() - out, _, _ := dockerCmd(t, "run", "-di", "busybox", "/bin/cat") + out, _ := dockerCmd(t, "run", "-di", "busybox", "/bin/cat") id := strings.TrimSpace(out) cmd := exec.Command(dockerBinary, "attach", id) diff --git a/integration-cli/docker_cli_attach_unix_test.go b/integration-cli/docker_cli_attach_unix_test.go index ebc3804e3e..e17256cf74 100644 --- a/integration-cli/docker_cli_attach_unix_test.go +++ b/integration-cli/docker_cli_attach_unix_test.go @@ -142,7 +142,7 @@ func TestAttachAfterDetach(t *testing.T) { // TestAttachDetach checks that attach in tty mode can be detached using the long container ID func TestAttachDetach(t *testing.T) { - out, _, _ := dockerCmd(t, "run", "-itd", "busybox", "cat") + out, _ := dockerCmd(t, "run", "-itd", "busybox", "cat") id := strings.TrimSpace(out) if err := waitRun(id); err != nil { t.Fatal(err) @@ -217,7 +217,7 @@ func TestAttachDetach(t *testing.T) { // TestAttachDetachTruncatedID checks that attach in tty mode can be detached func TestAttachDetachTruncatedID(t *testing.T) { - out, _, _ := dockerCmd(t, "run", "-itd", "busybox", "cat") + out, _ := dockerCmd(t, "run", "-itd", "busybox", "cat") id := stringid.TruncateID(strings.TrimSpace(out)) if err := waitRun(id); err != nil { t.Fatal(err) diff --git a/integration-cli/docker_cli_build_test.go b/integration-cli/docker_cli_build_test.go index 1ef5088e24..44370d4b9f 100644 --- a/integration-cli/docker_cli_build_test.go +++ b/integration-cli/docker_cli_build_test.go @@ -3294,7 +3294,7 @@ func TestBuildNoContext(t *testing.T) { t.Fatalf("build failed to complete: %v %v", out, err) } - if out, _, err := dockerCmd(t, "run", "--rm", "nocontext"); out != "ok\n" || err != nil { + if out, _ := dockerCmd(t, "run", "--rm", "nocontext"); out != "ok\n" { t.Fatalf("run produced invalid output: %q, expected %q", out, "ok") } @@ -5562,10 +5562,7 @@ func TestBuildResourceConstraintsAreUsed(t *testing.T) { if err != nil { t.Fatal(err, out) } - out, _, err = dockerCmd(t, "ps", "-lq") - if err != nil { - t.Fatal(err, out) - } + out, _ = dockerCmd(t, "ps", "-lq") cID := strings.TrimSpace(out) @@ -5593,10 +5590,8 @@ func TestBuildResourceConstraintsAreUsed(t *testing.T) { } // Make sure constraints aren't saved to image - _, _, err = dockerCmd(t, "run", "--name=test", name) - if err != nil { - t.Fatal(err) - } + _, _ = dockerCmd(t, "run", "--name=test", name) + cfg, err = inspectFieldJSON("test", "HostConfig") if err != nil { t.Fatal(err) diff --git a/integration-cli/docker_cli_commit_test.go b/integration-cli/docker_cli_commit_test.go index a51360a9b6..5d42881923 100644 --- a/integration-cli/docker_cli_commit_test.go +++ b/integration-cli/docker_cli_commit_test.go @@ -284,13 +284,13 @@ func TestCommitChange(t *testing.T) { func TestCommitMergeConfigRun(t *testing.T) { defer deleteAllContainers() name := "commit-test" - out, _, _ := dockerCmd(t, "run", "-d", "-e=FOO=bar", "busybox", "/bin/sh", "-c", "echo testing > /tmp/foo") + out, _ := dockerCmd(t, "run", "-d", "-e=FOO=bar", "busybox", "/bin/sh", "-c", "echo testing > /tmp/foo") id := strings.TrimSpace(out) dockerCmd(t, "commit", `--run={"Cmd": ["cat", "/tmp/foo"]}`, id, "commit-test") defer deleteImages("commit-test") - out, _, _ = dockerCmd(t, "run", "--name", name, "commit-test") + out, _ = dockerCmd(t, "run", "--name", name, "commit-test") if strings.TrimSpace(out) != "testing" { t.Fatal("run config in commited container was not merged") } diff --git a/integration-cli/docker_cli_cp_test.go b/integration-cli/docker_cli_cp_test.go index 12da76abca..b577e82982 100644 --- a/integration-cli/docker_cli_cp_test.go +++ b/integration-cli/docker_cli_cp_test.go @@ -25,17 +25,17 @@ const ( // Test for #5656 // Check that garbage paths don't escape the container's rootfs func TestCpGarbagePath(t *testing.T) { - out, exitCode, err := dockerCmd(t, "run", "-d", "busybox", "/bin/sh", "-c", "mkdir -p '"+cpTestPath+"' && echo -n '"+cpContainerContents+"' > "+cpFullPath) - if err != nil || exitCode != 0 { - t.Fatal("failed to create a container", out, err) + out, exitCode := dockerCmd(t, "run", "-d", "busybox", "/bin/sh", "-c", "mkdir -p '"+cpTestPath+"' && echo -n '"+cpContainerContents+"' > "+cpFullPath) + if exitCode != 0 { + t.Fatal("failed to create a container", out) } cleanedContainerID := strings.TrimSpace(out) defer deleteContainer(cleanedContainerID) - out, _, err = dockerCmd(t, "wait", cleanedContainerID) - if err != nil || strings.TrimSpace(out) != "0" { - t.Fatal("failed to set up container", out, err) + out, _ = dockerCmd(t, "wait", cleanedContainerID) + if strings.TrimSpace(out) != "0" { + t.Fatal("failed to set up container", out) } if err := os.MkdirAll(cpTestPath, os.ModeDir); err != nil { @@ -61,10 +61,7 @@ func TestCpGarbagePath(t *testing.T) { path := path.Join("../../../../../../../../../../../../", cpFullPath) - _, _, err = dockerCmd(t, "cp", cleanedContainerID+":"+path, tmpdir) - if err != nil { - t.Fatalf("couldn't copy from garbage path: %s:%s %s", cleanedContainerID, path, err) - } + _, _ = dockerCmd(t, "cp", cleanedContainerID+":"+path, tmpdir) file, _ := os.Open(tmpname) defer file.Close() @@ -87,17 +84,17 @@ func TestCpGarbagePath(t *testing.T) { // Check that relative paths are relative to the container's rootfs func TestCpRelativePath(t *testing.T) { - out, exitCode, err := dockerCmd(t, "run", "-d", "busybox", "/bin/sh", "-c", "mkdir -p '"+cpTestPath+"' && echo -n '"+cpContainerContents+"' > "+cpFullPath) - if err != nil || exitCode != 0 { - t.Fatal("failed to create a container", out, err) + out, exitCode := dockerCmd(t, "run", "-d", "busybox", "/bin/sh", "-c", "mkdir -p '"+cpTestPath+"' && echo -n '"+cpContainerContents+"' > "+cpFullPath) + if exitCode != 0 { + t.Fatal("failed to create a container", out) } cleanedContainerID := strings.TrimSpace(out) defer deleteContainer(cleanedContainerID) - out, _, err = dockerCmd(t, "wait", cleanedContainerID) - if err != nil || strings.TrimSpace(out) != "0" { - t.Fatal("failed to set up container", out, err) + out, _ = dockerCmd(t, "wait", cleanedContainerID) + if strings.TrimSpace(out) != "0" { + t.Fatal("failed to set up container", out) } if err := os.MkdirAll(cpTestPath, os.ModeDir); err != nil { @@ -131,10 +128,7 @@ func TestCpRelativePath(t *testing.T) { t.Fatalf("path %s was assumed to be an absolute path", cpFullPath) } - _, _, err = dockerCmd(t, "cp", cleanedContainerID+":"+relPath, tmpdir) - if err != nil { - t.Fatalf("couldn't copy from relative path: %s:%s %s", cleanedContainerID, relPath, err) - } + _, _ = dockerCmd(t, "cp", cleanedContainerID+":"+relPath, tmpdir) file, _ := os.Open(tmpname) defer file.Close() @@ -157,17 +151,17 @@ func TestCpRelativePath(t *testing.T) { // Check that absolute paths are relative to the container's rootfs func TestCpAbsolutePath(t *testing.T) { - out, exitCode, err := dockerCmd(t, "run", "-d", "busybox", "/bin/sh", "-c", "mkdir -p '"+cpTestPath+"' && echo -n '"+cpContainerContents+"' > "+cpFullPath) - if err != nil || exitCode != 0 { - t.Fatal("failed to create a container", out, err) + out, exitCode := dockerCmd(t, "run", "-d", "busybox", "/bin/sh", "-c", "mkdir -p '"+cpTestPath+"' && echo -n '"+cpContainerContents+"' > "+cpFullPath) + if exitCode != 0 { + t.Fatal("failed to create a container", out) } cleanedContainerID := strings.TrimSpace(out) defer deleteContainer(cleanedContainerID) - out, _, err = dockerCmd(t, "wait", cleanedContainerID) - if err != nil || strings.TrimSpace(out) != "0" { - t.Fatal("failed to set up container", out, err) + out, _ = dockerCmd(t, "wait", cleanedContainerID) + if strings.TrimSpace(out) != "0" { + t.Fatal("failed to set up container", out) } if err := os.MkdirAll(cpTestPath, os.ModeDir); err != nil { @@ -194,10 +188,7 @@ func TestCpAbsolutePath(t *testing.T) { path := cpFullPath - _, _, err = dockerCmd(t, "cp", cleanedContainerID+":"+path, tmpdir) - if err != nil { - t.Fatalf("couldn't copy from absolute path: %s:%s %s", cleanedContainerID, path, err) - } + _, _ = dockerCmd(t, "cp", cleanedContainerID+":"+path, tmpdir) file, _ := os.Open(tmpname) defer file.Close() @@ -221,17 +212,17 @@ func TestCpAbsolutePath(t *testing.T) { // Test for #5619 // Check that absolute symlinks are still relative to the container's rootfs func TestCpAbsoluteSymlink(t *testing.T) { - out, exitCode, err := dockerCmd(t, "run", "-d", "busybox", "/bin/sh", "-c", "mkdir -p '"+cpTestPath+"' && echo -n '"+cpContainerContents+"' > "+cpFullPath+" && ln -s "+cpFullPath+" container_path") - if err != nil || exitCode != 0 { - t.Fatal("failed to create a container", out, err) + out, exitCode := dockerCmd(t, "run", "-d", "busybox", "/bin/sh", "-c", "mkdir -p '"+cpTestPath+"' && echo -n '"+cpContainerContents+"' > "+cpFullPath+" && ln -s "+cpFullPath+" container_path") + if exitCode != 0 { + t.Fatal("failed to create a container", out) } cleanedContainerID := strings.TrimSpace(out) defer deleteContainer(cleanedContainerID) - out, _, err = dockerCmd(t, "wait", cleanedContainerID) - if err != nil || strings.TrimSpace(out) != "0" { - t.Fatal("failed to set up container", out, err) + out, _ = dockerCmd(t, "wait", cleanedContainerID) + if strings.TrimSpace(out) != "0" { + t.Fatal("failed to set up container", out) } if err := os.MkdirAll(cpTestPath, os.ModeDir); err != nil { @@ -258,10 +249,7 @@ func TestCpAbsoluteSymlink(t *testing.T) { path := path.Join("/", "container_path") - _, _, err = dockerCmd(t, "cp", cleanedContainerID+":"+path, tmpdir) - if err != nil { - t.Fatalf("couldn't copy from absolute path: %s:%s %s", cleanedContainerID, path, err) - } + _, _ = dockerCmd(t, "cp", cleanedContainerID+":"+path, tmpdir) file, _ := os.Open(tmpname) defer file.Close() @@ -285,17 +273,17 @@ func TestCpAbsoluteSymlink(t *testing.T) { // Test for #5619 // Check that symlinks which are part of the resource path are still relative to the container's rootfs func TestCpSymlinkComponent(t *testing.T) { - out, exitCode, err := dockerCmd(t, "run", "-d", "busybox", "/bin/sh", "-c", "mkdir -p '"+cpTestPath+"' && echo -n '"+cpContainerContents+"' > "+cpFullPath+" && ln -s "+cpTestPath+" container_path") - if err != nil || exitCode != 0 { - t.Fatal("failed to create a container", out, err) + out, exitCode := dockerCmd(t, "run", "-d", "busybox", "/bin/sh", "-c", "mkdir -p '"+cpTestPath+"' && echo -n '"+cpContainerContents+"' > "+cpFullPath+" && ln -s "+cpTestPath+" container_path") + if exitCode != 0 { + t.Fatal("failed to create a container", out) } cleanedContainerID := strings.TrimSpace(out) defer deleteContainer(cleanedContainerID) - out, _, err = dockerCmd(t, "wait", cleanedContainerID) - if err != nil || strings.TrimSpace(out) != "0" { - t.Fatal("failed to set up container", out, err) + out, _ = dockerCmd(t, "wait", cleanedContainerID) + if strings.TrimSpace(out) != "0" { + t.Fatal("failed to set up container", out) } if err := os.MkdirAll(cpTestPath, os.ModeDir); err != nil { @@ -322,10 +310,7 @@ func TestCpSymlinkComponent(t *testing.T) { path := path.Join("/", "container_path", cpTestName) - _, _, err = dockerCmd(t, "cp", cleanedContainerID+":"+path, tmpdir) - if err != nil { - t.Fatalf("couldn't copy from symlink path component: %s:%s %s", cleanedContainerID, path, err) - } + _, _ = dockerCmd(t, "cp", cleanedContainerID+":"+path, tmpdir) file, _ := os.Open(tmpname) defer file.Close() @@ -350,17 +335,17 @@ func TestCpSymlinkComponent(t *testing.T) { func TestCpUnprivilegedUser(t *testing.T) { testRequires(t, UnixCli) // uses chmod/su: not available on windows - out, exitCode, err := dockerCmd(t, "run", "-d", "busybox", "/bin/sh", "-c", "touch "+cpTestName) - if err != nil || exitCode != 0 { - t.Fatal("failed to create a container", out, err) + out, exitCode := dockerCmd(t, "run", "-d", "busybox", "/bin/sh", "-c", "touch "+cpTestName) + if exitCode != 0 { + t.Fatal("failed to create a container", out) } cleanedContainerID := strings.TrimSpace(out) defer deleteContainer(cleanedContainerID) - out, _, err = dockerCmd(t, "wait", cleanedContainerID) - if err != nil || strings.TrimSpace(out) != "0" { - t.Fatal("failed to set up container", out, err) + out, _ = dockerCmd(t, "wait", cleanedContainerID) + if strings.TrimSpace(out) != "0" { + t.Fatal("failed to set up container", out) } tmpdir, err := ioutil.TempDir("", "docker-integration") @@ -393,24 +378,21 @@ func TestCpSpecialFiles(t *testing.T) { } defer os.RemoveAll(outDir) - out, exitCode, err := dockerCmd(t, "run", "-d", "busybox", "/bin/sh", "-c", "touch /foo") - if err != nil || exitCode != 0 { - t.Fatal("failed to create a container", out, err) + out, exitCode := dockerCmd(t, "run", "-d", "busybox", "/bin/sh", "-c", "touch /foo") + if exitCode != 0 { + t.Fatal("failed to create a container", out) } cleanedContainerID := strings.TrimSpace(out) defer deleteContainer(cleanedContainerID) - out, _, err = dockerCmd(t, "wait", cleanedContainerID) - if err != nil || strings.TrimSpace(out) != "0" { - t.Fatal("failed to set up container", out, err) + out, _ = dockerCmd(t, "wait", cleanedContainerID) + if strings.TrimSpace(out) != "0" { + t.Fatal("failed to set up container", out) } // Copy actual /etc/resolv.conf - _, _, err = dockerCmd(t, "cp", cleanedContainerID+":/etc/resolv.conf", outDir) - if err != nil { - t.Fatalf("couldn't copy from container: %s:%s %v", cleanedContainerID, "/etc/resolv.conf", err) - } + _, _ = dockerCmd(t, "cp", cleanedContainerID+":/etc/resolv.conf", outDir) expected, err := ioutil.ReadFile("/var/lib/docker/containers/" + cleanedContainerID + "/resolv.conf") actual, err := ioutil.ReadFile(outDir + "/resolv.conf") @@ -420,10 +402,7 @@ func TestCpSpecialFiles(t *testing.T) { } // Copy actual /etc/hosts - _, _, err = dockerCmd(t, "cp", cleanedContainerID+":/etc/hosts", outDir) - if err != nil { - t.Fatalf("couldn't copy from container: %s:%s %v", cleanedContainerID, "/etc/hosts", err) - } + _, _ = dockerCmd(t, "cp", cleanedContainerID+":/etc/hosts", outDir) expected, err = ioutil.ReadFile("/var/lib/docker/containers/" + cleanedContainerID + "/hosts") actual, err = ioutil.ReadFile(outDir + "/hosts") @@ -433,10 +412,7 @@ func TestCpSpecialFiles(t *testing.T) { } // Copy actual /etc/resolv.conf - _, _, err = dockerCmd(t, "cp", cleanedContainerID+":/etc/hostname", outDir) - if err != nil { - t.Fatalf("couldn't copy from container: %s:%s %v", cleanedContainerID, "/etc/hostname", err) - } + _, _ = dockerCmd(t, "cp", cleanedContainerID+":/etc/hostname", outDir) expected, err = ioutil.ReadFile("/var/lib/docker/containers/" + cleanedContainerID + "/hostname") actual, err = ioutil.ReadFile(outDir + "/hostname") @@ -466,24 +442,22 @@ func TestCpVolumePath(t *testing.T) { t.Fatal(err) } - out, exitCode, err := dockerCmd(t, "run", "-d", "-v", "/foo", "-v", tmpDir+"/test:/test", "-v", tmpDir+":/baz", "busybox", "/bin/sh", "-c", "touch /foo/bar") - if err != nil || exitCode != 0 { - t.Fatal("failed to create a container", out, err) + out, exitCode := dockerCmd(t, "run", "-d", "-v", "/foo", "-v", tmpDir+"/test:/test", "-v", tmpDir+":/baz", "busybox", "/bin/sh", "-c", "touch /foo/bar") + if exitCode != 0 { + t.Fatal("failed to create a container", out) } cleanedContainerID := strings.TrimSpace(out) defer dockerCmd(t, "rm", "-fv", cleanedContainerID) - out, _, err = dockerCmd(t, "wait", cleanedContainerID) - if err != nil || strings.TrimSpace(out) != "0" { - t.Fatal("failed to set up container", out, err) + out, _ = dockerCmd(t, "wait", cleanedContainerID) + if strings.TrimSpace(out) != "0" { + t.Fatal("failed to set up container", out) } // Copy actual volume path - _, _, err = dockerCmd(t, "cp", cleanedContainerID+":/foo", outDir) - if err != nil { - t.Fatalf("couldn't copy from volume path: %s:%s %v", cleanedContainerID, "/foo", err) - } + _, _ = dockerCmd(t, "cp", cleanedContainerID+":/foo", outDir) + stat, err := os.Stat(outDir + "/foo") if err != nil { t.Fatal(err) @@ -500,10 +474,8 @@ func TestCpVolumePath(t *testing.T) { } // Copy file nested in volume - _, _, err = dockerCmd(t, "cp", cleanedContainerID+":/foo/bar", outDir) - if err != nil { - t.Fatalf("couldn't copy from volume path: %s:%s %v", cleanedContainerID, "/foo", err) - } + _, _ = dockerCmd(t, "cp", cleanedContainerID+":/foo/bar", outDir) + stat, err = os.Stat(outDir + "/bar") if err != nil { t.Fatal(err) @@ -513,10 +485,7 @@ func TestCpVolumePath(t *testing.T) { } // Copy Bind-mounted dir - _, _, err = dockerCmd(t, "cp", cleanedContainerID+":/baz", outDir) - if err != nil { - t.Fatalf("couldn't copy from bind-mounted volume path: %s:%s %v", cleanedContainerID, "/baz", err) - } + _, _ = dockerCmd(t, "cp", cleanedContainerID+":/baz", outDir) stat, err = os.Stat(outDir + "/baz") if err != nil { t.Fatal(err) @@ -526,7 +495,7 @@ func TestCpVolumePath(t *testing.T) { } // Copy file nested in bind-mounted dir - _, _, err = dockerCmd(t, "cp", cleanedContainerID+":/baz/test", outDir) + _, _ = dockerCmd(t, "cp", cleanedContainerID+":/baz/test", outDir) fb, err := ioutil.ReadFile(outDir + "/baz/test") if err != nil { t.Fatal(err) @@ -540,7 +509,7 @@ func TestCpVolumePath(t *testing.T) { } // Copy bind-mounted file - _, _, err = dockerCmd(t, "cp", cleanedContainerID+":/test", outDir) + _, _ = dockerCmd(t, "cp", cleanedContainerID+":/test", outDir) fb, err = ioutil.ReadFile(outDir + "/test") if err != nil { t.Fatal(err) @@ -557,17 +526,17 @@ func TestCpVolumePath(t *testing.T) { } func TestCpToDot(t *testing.T) { - out, exitCode, err := dockerCmd(t, "run", "-d", "busybox", "/bin/sh", "-c", "echo lololol > /test") - if err != nil || exitCode != 0 { - t.Fatal("failed to create a container", out, err) + out, exitCode := dockerCmd(t, "run", "-d", "busybox", "/bin/sh", "-c", "echo lololol > /test") + if exitCode != 0 { + t.Fatal("failed to create a container", out) } cleanedContainerID := strings.TrimSpace(out) defer deleteContainer(cleanedContainerID) - out, _, err = dockerCmd(t, "wait", cleanedContainerID) - if err != nil || strings.TrimSpace(out) != "0" { - t.Fatal("failed to set up container", out, err) + out, _ = dockerCmd(t, "wait", cleanedContainerID) + if strings.TrimSpace(out) != "0" { + t.Fatal("failed to set up container", out) } tmpdir, err := ioutil.TempDir("", "docker-integration") @@ -583,10 +552,7 @@ func TestCpToDot(t *testing.T) { if err := os.Chdir(tmpdir); err != nil { t.Fatal(err) } - _, _, err = dockerCmd(t, "cp", cleanedContainerID+":/test", ".") - if err != nil { - t.Fatalf("couldn't docker cp to \".\" path: %s", err) - } + _, _ = dockerCmd(t, "cp", cleanedContainerID+":/test", ".") content, err := ioutil.ReadFile("./test") if string(content) != "lololol\n" { t.Fatalf("Wrong content in copied file %q, should be %q", content, "lololol\n") @@ -595,22 +561,23 @@ func TestCpToDot(t *testing.T) { } func TestCpToStdout(t *testing.T) { - out, exitCode, err := dockerCmd(t, "run", "-d", "busybox", "/bin/sh", "-c", "echo lololol > /test") - if err != nil || exitCode != 0 { - t.Fatalf("failed to create a container:%s\n%s", out, err) + out, exitCode := dockerCmd(t, "run", "-d", "busybox", "/bin/sh", "-c", "echo lololol > /test") + if exitCode != 0 { + t.Fatalf("failed to create a container:%s\n", out) } cID := strings.TrimSpace(out) defer deleteContainer(cID) - out, _, err = dockerCmd(t, "wait", cID) - if err != nil || strings.TrimSpace(out) != "0" { - t.Fatalf("failed to set up container:%s\n%s", out, err) + out, _ = dockerCmd(t, "wait", cID) + if strings.TrimSpace(out) != "0" { + t.Fatalf("failed to set up container:%s\n", out) } - out, _, err = runCommandPipelineWithOutput( + out, _, err := runCommandPipelineWithOutput( exec.Command(dockerBinary, "cp", cID+":/test", "-"), exec.Command("tar", "-vtf", "-")) + if err != nil { t.Fatalf("Failed to run commands: %s", err) } @@ -624,17 +591,17 @@ func TestCpToStdout(t *testing.T) { func TestCpNameHasColon(t *testing.T) { testRequires(t, SameHostDaemon) - out, exitCode, err := dockerCmd(t, "run", "-d", "busybox", "/bin/sh", "-c", "echo lololol > /te:s:t") - if err != nil || exitCode != 0 { - t.Fatal("failed to create a container", out, err) + out, exitCode := dockerCmd(t, "run", "-d", "busybox", "/bin/sh", "-c", "echo lololol > /te:s:t") + if exitCode != 0 { + t.Fatal("failed to create a container", out) } cleanedContainerID := strings.TrimSpace(out) defer deleteContainer(cleanedContainerID) - out, _, err = dockerCmd(t, "wait", cleanedContainerID) - if err != nil || strings.TrimSpace(out) != "0" { - t.Fatal("failed to set up container", out, err) + out, _ = dockerCmd(t, "wait", cleanedContainerID) + if strings.TrimSpace(out) != "0" { + t.Fatal("failed to set up container", out) } tmpdir, err := ioutil.TempDir("", "docker-integration") @@ -642,10 +609,7 @@ func TestCpNameHasColon(t *testing.T) { t.Fatal(err) } defer os.RemoveAll(tmpdir) - _, _, err = dockerCmd(t, "cp", cleanedContainerID+":/te:s:t", tmpdir) - if err != nil { - t.Fatalf("couldn't docker cp to %s: %s", tmpdir, err) - } + _, _ = dockerCmd(t, "cp", cleanedContainerID+":/te:s:t", tmpdir) content, err := ioutil.ReadFile(tmpdir + "/te:s:t") if string(content) != "lololol\n" { t.Fatalf("Wrong content in copied file %q, should be %q", content, "lololol\n") diff --git a/integration-cli/docker_cli_create_test.go b/integration-cli/docker_cli_create_test.go index ac10b264eb..a8cc09106e 100644 --- a/integration-cli/docker_cli_create_test.go +++ b/integration-cli/docker_cli_create_test.go @@ -307,7 +307,7 @@ func TestCreateLabelFromImage(t *testing.T) { } func TestCreateHostnameWithNumber(t *testing.T) { - out, _, _ := dockerCmd(t, "run", "-h", "web.0", "busybox", "hostname") + out, _ := dockerCmd(t, "run", "-h", "web.0", "busybox", "hostname") if strings.TrimSpace(out) != "web.0" { t.Fatalf("hostname not set, expected `web.0`, got: %s", out) } diff --git a/integration-cli/docker_cli_events_test.go b/integration-cli/docker_cli_events_test.go index 767af55018..3e4c005b2c 100644 --- a/integration-cli/docker_cli_events_test.go +++ b/integration-cli/docker_cli_events_test.go @@ -38,7 +38,7 @@ func TestEventsUntag(t *testing.T) { func TestEventsContainerFailStartDie(t *testing.T) { defer deleteAllContainers() - out, _, _ := dockerCmd(t, "images", "-q") + out, _ := dockerCmd(t, "images", "-q") image := strings.Split(out, "\n")[0] eventsCmd := exec.Command(dockerBinary, "run", "--name", "testeventdie", image, "blerg") _, _, err := runCommandWithOutput(eventsCmd) diff --git a/integration-cli/docker_cli_exec_test.go b/integration-cli/docker_cli_exec_test.go index d4e4839717..6a0999eefb 100644 --- a/integration-cli/docker_cli_exec_test.go +++ b/integration-cli/docker_cli_exec_test.go @@ -500,12 +500,12 @@ func TestLinksPingLinkedContainersOnRename(t *testing.T) { defer deleteAllContainers() var out string - out, _, _ = dockerCmd(t, "run", "-d", "--name", "container1", "busybox", "top") + out, _ = dockerCmd(t, "run", "-d", "--name", "container1", "busybox", "top") idA := strings.TrimSpace(out) if idA == "" { t.Fatal(out, "id should not be nil") } - out, _, _ = dockerCmd(t, "run", "-d", "--link", "container1:alias1", "--name", "container2", "busybox", "top") + out, _ = dockerCmd(t, "run", "-d", "--link", "container1:alias1", "--name", "container2", "busybox", "top") idB := strings.TrimSpace(out) if idB == "" { t.Fatal(out, "id should not be nil") diff --git a/integration-cli/docker_cli_links_test.go b/integration-cli/docker_cli_links_test.go index 04718c23f0..0f48cbb1e2 100644 --- a/integration-cli/docker_cli_links_test.go +++ b/integration-cli/docker_cli_links_test.go @@ -110,9 +110,9 @@ func TestLinksPingLinkedContainers(t *testing.T) { func TestLinksPingLinkedContainersAfterRename(t *testing.T) { defer deleteAllContainers() - out, _, _ := dockerCmd(t, "run", "-d", "--name", "container1", "busybox", "top") + out, _ := dockerCmd(t, "run", "-d", "--name", "container1", "busybox", "top") idA := strings.TrimSpace(out) - out, _, _ = dockerCmd(t, "run", "-d", "--name", "container2", "busybox", "top") + out, _ = dockerCmd(t, "run", "-d", "--name", "container2", "busybox", "top") idB := strings.TrimSpace(out) dockerCmd(t, "rename", "container1", "container_new") dockerCmd(t, "run", "--rm", "--link", "container_new:alias1", "--link", "container2:alias2", "busybox", "sh", "-c", "ping -c 1 alias1 -W 1 && ping -c 1 alias2 -W 1") diff --git a/integration-cli/docker_cli_pause_test.go b/integration-cli/docker_cli_pause_test.go index 41147b2062..6c620e7cde 100644 --- a/integration-cli/docker_cli_pause_test.go +++ b/integration-cli/docker_cli_pause_test.go @@ -12,7 +12,7 @@ func TestPause(t *testing.T) { defer unpauseAllContainers() name := "testeventpause" - out, _, _ := dockerCmd(t, "images", "-q") + out, _ := dockerCmd(t, "images", "-q") image := strings.Split(out, "\n")[0] dockerCmd(t, "run", "-d", "--name", name, image, "top") @@ -55,7 +55,7 @@ func TestPauseMultipleContainers(t *testing.T) { "testpausewithmorecontainers1", "testpausewithmorecontainers2", } - out, _, _ := dockerCmd(t, "images", "-q") + out, _ := dockerCmd(t, "images", "-q") image := strings.Split(out, "\n")[0] for _, name := range containers { dockerCmd(t, "run", "-d", "--name", name, image, "top") diff --git a/integration-cli/docker_cli_rmi_test.go b/integration-cli/docker_cli_rmi_test.go index 7161a09228..f6b12aa6c7 100644 --- a/integration-cli/docker_cli_rmi_test.go +++ b/integration-cli/docker_cli_rmi_test.go @@ -29,7 +29,7 @@ func TestRmiWithContainerFails(t *testing.T) { } // make sure it didn't delete the busybox name - images, _, _ := dockerCmd(t, "images") + images, _ := dockerCmd(t, "images") if !strings.Contains(images, "busybox") { t.Fatalf("The name 'busybox' should not have been removed from images: %q", images) } @@ -40,19 +40,19 @@ func TestRmiWithContainerFails(t *testing.T) { } func TestRmiTag(t *testing.T) { - imagesBefore, _, _ := dockerCmd(t, "images", "-a") + imagesBefore, _ := dockerCmd(t, "images", "-a") dockerCmd(t, "tag", "busybox", "utest:tag1") dockerCmd(t, "tag", "busybox", "utest/docker:tag2") dockerCmd(t, "tag", "busybox", "utest:5000/docker:tag3") { - imagesAfter, _, _ := dockerCmd(t, "images", "-a") + imagesAfter, _ := dockerCmd(t, "images", "-a") if strings.Count(imagesAfter, "\n") != strings.Count(imagesBefore, "\n")+3 { t.Fatalf("before: %q\n\nafter: %q\n", imagesBefore, imagesAfter) } } dockerCmd(t, "rmi", "utest/docker:tag2") { - imagesAfter, _, _ := dockerCmd(t, "images", "-a") + imagesAfter, _ := dockerCmd(t, "images", "-a") if strings.Count(imagesAfter, "\n") != strings.Count(imagesBefore, "\n")+2 { t.Fatalf("before: %q\n\nafter: %q\n", imagesBefore, imagesAfter) } @@ -60,7 +60,7 @@ func TestRmiTag(t *testing.T) { } dockerCmd(t, "rmi", "utest:5000/docker:tag3") { - imagesAfter, _, _ := dockerCmd(t, "images", "-a") + imagesAfter, _ := dockerCmd(t, "images", "-a") if strings.Count(imagesAfter, "\n") != strings.Count(imagesBefore, "\n")+1 { t.Fatalf("before: %q\n\nafter: %q\n", imagesBefore, imagesAfter) } @@ -68,7 +68,7 @@ func TestRmiTag(t *testing.T) { } dockerCmd(t, "rmi", "utest:tag1") { - imagesAfter, _, _ := dockerCmd(t, "images", "-a") + imagesAfter, _ := dockerCmd(t, "images", "-a") if strings.Count(imagesAfter, "\n") != strings.Count(imagesBefore, "\n")+0 { t.Fatalf("before: %q\n\nafter: %q\n", imagesBefore, imagesAfter) } @@ -90,22 +90,22 @@ func TestRmiImgIDForce(t *testing.T) { t.Fatalf("failed to commit a new busybox-test:%s, %v", out, err) } - imagesBefore, _, _ := dockerCmd(t, "images", "-a") + imagesBefore, _ := dockerCmd(t, "images", "-a") dockerCmd(t, "tag", "busybox-test", "utest:tag1") dockerCmd(t, "tag", "busybox-test", "utest:tag2") dockerCmd(t, "tag", "busybox-test", "utest/docker:tag3") dockerCmd(t, "tag", "busybox-test", "utest:5000/docker:tag4") { - imagesAfter, _, _ := dockerCmd(t, "images", "-a") + imagesAfter, _ := dockerCmd(t, "images", "-a") if strings.Count(imagesAfter, "\n") != strings.Count(imagesBefore, "\n")+4 { t.Fatalf("tag busybox to create 4 more images with same imageID; docker images shows: %q\n", imagesAfter) } } - out, _, _ = dockerCmd(t, "inspect", "-f", "{{.Id}}", "busybox-test") + out, _ = dockerCmd(t, "inspect", "-f", "{{.Id}}", "busybox-test") imgID := strings.TrimSpace(out) dockerCmd(t, "rmi", "-f", imgID) { - imagesAfter, _, _ := dockerCmd(t, "images", "-a") + imagesAfter, _ := dockerCmd(t, "images", "-a") if strings.Contains(imagesAfter, imgID[:12]) { t.Fatalf("rmi -f %s failed, image still exists: %q\n\n", imgID, imagesAfter) } diff --git a/integration-cli/docker_cli_run_test.go b/integration-cli/docker_cli_run_test.go index b3cd1c73a2..de53fd4941 100644 --- a/integration-cli/docker_cli_run_test.go +++ b/integration-cli/docker_cli_run_test.go @@ -501,9 +501,7 @@ func TestRunCreateVolumesInSymlinkDir(t *testing.T) { } defer deleteImages(name) - if out, _, err := dockerCmd(t, "run", "-v", "/test/test", name); err != nil { - t.Fatal(err, out) - } + dockerCmd(t, "run", "-v", "/test/test", name) logDone("run - create volume in symlink directory") } @@ -1058,9 +1056,9 @@ func TestRunLoopbackWhenNetworkDisabled(t *testing.T) { func TestRunNetHostNotAllowedWithLinks(t *testing.T) { defer deleteAllContainers() - _, _, err := dockerCmd(t, "run", "--name", "linked", "busybox", "true") + _, _ = dockerCmd(t, "run", "--name", "linked", "busybox", "true") cmd := exec.Command(dockerBinary, "run", "--net=host", "--link", "linked:linked", "busybox", "true") - _, _, err = runCommandWithOutput(cmd) + _, _, err := runCommandWithOutput(cmd) if err == nil { t.Fatal("Expected error") } @@ -1493,10 +1491,7 @@ func TestRunModeHostname(t *testing.T) { func TestRunRootWorkdir(t *testing.T) { defer deleteAllContainers() - s, _, err := dockerCmd(t, "run", "--workdir", "/", "busybox", "pwd") - if err != nil { - t.Fatal(s, err) - } + s, _ := dockerCmd(t, "run", "--workdir", "/", "busybox", "pwd") if s != "/\n" { t.Fatalf("pwd returned %q (expected /\\n)", s) } @@ -1507,10 +1502,7 @@ func TestRunRootWorkdir(t *testing.T) { func TestRunAllowBindMountingRoot(t *testing.T) { defer deleteAllContainers() - s, _, err := dockerCmd(t, "run", "-v", "/:/host", "busybox", "ls", "/host") - if err != nil { - t.Fatal(s, err) - } + _, _ = dockerCmd(t, "run", "-v", "/:/host", "busybox", "ls", "/host") logDone("run - bind mount / as volume") } diff --git a/integration-cli/docker_cli_start_test.go b/integration-cli/docker_cli_start_test.go index c703e434c1..342209dc4b 100644 --- a/integration-cli/docker_cli_start_test.go +++ b/integration-cli/docker_cli_start_test.go @@ -157,7 +157,7 @@ func TestStartVolumesFromFailsCleanly(t *testing.T) { dockerCmd(t, "start", "consumer") // Check that we have the volumes we want - out, _, _ := dockerCmd(t, "inspect", "--format='{{ len .Volumes }}'", "consumer") + out, _ := dockerCmd(t, "inspect", "--format='{{ len .Volumes }}'", "consumer") nVolumes := strings.Trim(out, " \r\n'") if nVolumes != "2" { t.Fatalf("Missing volumes: expected 2, got %s", nVolumes) diff --git a/integration-cli/docker_utils.go b/integration-cli/docker_utils.go index 367e518094..4e622b84c7 100644 --- a/integration-cli/docker_utils.go +++ b/integration-cli/docker_utils.go @@ -478,12 +478,12 @@ func pullImageIfNotExist(image string) (err error) { return } -func dockerCmd(t *testing.T, args ...string) (string, int, error) { +func dockerCmd(t *testing.T, args ...string) (string, int) { out, status, err := runCommandWithOutput(exec.Command(dockerBinary, args...)) if err != nil { t.Fatalf("%q failed with errors: %s, %v", strings.Join(args, " "), out, err) } - return out, status, err + return out, status } // execute a docker command with a timeout @@ -784,9 +784,9 @@ func getContainerState(t *testing.T, id string) (int, bool, error) { exitStatus int running bool ) - out, exitCode, err := dockerCmd(t, "inspect", "--format={{.State.Running}} {{.State.ExitCode}}", id) - if err != nil || exitCode != 0 { - return 0, false, fmt.Errorf("%q doesn't exist: %s", id, err) + out, exitCode := dockerCmd(t, "inspect", "--format={{.State.Running}} {{.State.ExitCode}}", id) + if exitCode != 0 { + return 0, false, fmt.Errorf("%q doesn't exist: %s", id, out) } out = strings.Trim(out, "\n")