mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Cleanup errorOut resp in commit test
Docker-DCO-1.1-Signed-off-by: Jessica Frazelle <jess@docker.com> (github: jfrazelle) Cleanup errorOut resp in commit test Docker-DCO-1.1-Signed-off-by: Jessica Frazelle <jess@docker.com> (github: jfrazelle)
This commit is contained in:
parent
2f9ffe5b6a
commit
3182ee5c9b
1 changed files with 26 additions and 16 deletions
|
@ -1,7 +1,6 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -10,23 +9,29 @@ import (
|
||||||
func TestCommitAfterContainerIsDone(t *testing.T) {
|
func TestCommitAfterContainerIsDone(t *testing.T) {
|
||||||
runCmd := exec.Command(dockerBinary, "run", "-i", "-a", "stdin", "busybox", "echo", "foo")
|
runCmd := exec.Command(dockerBinary, "run", "-i", "-a", "stdin", "busybox", "echo", "foo")
|
||||||
out, _, _, err := runCommandWithStdoutStderr(runCmd)
|
out, _, _, err := runCommandWithStdoutStderr(runCmd)
|
||||||
errorOut(err, t, fmt.Sprintf("failed to run container: %v %v", out, err))
|
if err != nil {
|
||||||
|
t.Fatalf("failed to run container: %s, %v", out, err)
|
||||||
|
}
|
||||||
|
|
||||||
cleanedContainerID := stripTrailingCharacters(out)
|
cleanedContainerID := stripTrailingCharacters(out)
|
||||||
|
|
||||||
waitCmd := exec.Command(dockerBinary, "wait", cleanedContainerID)
|
waitCmd := exec.Command(dockerBinary, "wait", cleanedContainerID)
|
||||||
_, _, err = runCommandWithOutput(waitCmd)
|
if _, _, err = runCommandWithOutput(waitCmd); err != nil {
|
||||||
errorOut(err, t, fmt.Sprintf("error thrown while waiting for container: %s", out))
|
t.Fatalf("error thrown while waiting for container: %s, %v", out, err)
|
||||||
|
}
|
||||||
|
|
||||||
commitCmd := exec.Command(dockerBinary, "commit", cleanedContainerID)
|
commitCmd := exec.Command(dockerBinary, "commit", cleanedContainerID)
|
||||||
out, _, err = runCommandWithOutput(commitCmd)
|
out, _, err = runCommandWithOutput(commitCmd)
|
||||||
errorOut(err, t, fmt.Sprintf("failed to commit container to image: %v %v", out, err))
|
if err != nil {
|
||||||
|
t.Fatalf("failed to commit container to image: %s, %v", out, err)
|
||||||
|
}
|
||||||
|
|
||||||
cleanedImageID := stripTrailingCharacters(out)
|
cleanedImageID := stripTrailingCharacters(out)
|
||||||
|
|
||||||
inspectCmd := exec.Command(dockerBinary, "inspect", cleanedImageID)
|
inspectCmd := exec.Command(dockerBinary, "inspect", cleanedImageID)
|
||||||
out, _, err = runCommandWithOutput(inspectCmd)
|
if out, _, err = runCommandWithOutput(inspectCmd); err != nil {
|
||||||
errorOut(err, t, fmt.Sprintf("failed to inspect image: %v %v", out, err))
|
t.Fatalf("failed to inspect image: %s, %v", out, err)
|
||||||
|
}
|
||||||
|
|
||||||
deleteContainer(cleanedContainerID)
|
deleteContainer(cleanedContainerID)
|
||||||
deleteImages(cleanedImageID)
|
deleteImages(cleanedImageID)
|
||||||
|
@ -37,23 +42,29 @@ func TestCommitAfterContainerIsDone(t *testing.T) {
|
||||||
func TestCommitWithoutPause(t *testing.T) {
|
func TestCommitWithoutPause(t *testing.T) {
|
||||||
runCmd := exec.Command(dockerBinary, "run", "-i", "-a", "stdin", "busybox", "echo", "foo")
|
runCmd := exec.Command(dockerBinary, "run", "-i", "-a", "stdin", "busybox", "echo", "foo")
|
||||||
out, _, _, err := runCommandWithStdoutStderr(runCmd)
|
out, _, _, err := runCommandWithStdoutStderr(runCmd)
|
||||||
errorOut(err, t, fmt.Sprintf("failed to run container: %v %v", out, err))
|
if err != nil {
|
||||||
|
t.Fatalf("failed to run container: %s, %v", out, err)
|
||||||
|
}
|
||||||
|
|
||||||
cleanedContainerID := stripTrailingCharacters(out)
|
cleanedContainerID := stripTrailingCharacters(out)
|
||||||
|
|
||||||
waitCmd := exec.Command(dockerBinary, "wait", cleanedContainerID)
|
waitCmd := exec.Command(dockerBinary, "wait", cleanedContainerID)
|
||||||
_, _, err = runCommandWithOutput(waitCmd)
|
if _, _, err = runCommandWithOutput(waitCmd); err != nil {
|
||||||
errorOut(err, t, fmt.Sprintf("error thrown while waiting for container: %s", out))
|
t.Fatalf("error thrown while waiting for container: %s, %v", out, err)
|
||||||
|
}
|
||||||
|
|
||||||
commitCmd := exec.Command(dockerBinary, "commit", "-p=false", cleanedContainerID)
|
commitCmd := exec.Command(dockerBinary, "commit", "-p=false", cleanedContainerID)
|
||||||
out, _, err = runCommandWithOutput(commitCmd)
|
out, _, err = runCommandWithOutput(commitCmd)
|
||||||
errorOut(err, t, fmt.Sprintf("failed to commit container to image: %v %v", out, err))
|
if err != nil {
|
||||||
|
t.Fatalf("failed to commit container to image: %s, %v", out, err)
|
||||||
|
}
|
||||||
|
|
||||||
cleanedImageID := stripTrailingCharacters(out)
|
cleanedImageID := stripTrailingCharacters(out)
|
||||||
|
|
||||||
inspectCmd := exec.Command(dockerBinary, "inspect", cleanedImageID)
|
inspectCmd := exec.Command(dockerBinary, "inspect", cleanedImageID)
|
||||||
out, _, err = runCommandWithOutput(inspectCmd)
|
if out, _, err = runCommandWithOutput(inspectCmd); err != nil {
|
||||||
errorOut(err, t, fmt.Sprintf("failed to inspect image: %v %v", out, err))
|
t.Fatalf("failed to inspect image: %s, %v", out, err)
|
||||||
|
}
|
||||||
|
|
||||||
deleteContainer(cleanedContainerID)
|
deleteContainer(cleanedContainerID)
|
||||||
deleteImages(cleanedImageID)
|
deleteImages(cleanedImageID)
|
||||||
|
@ -81,7 +92,7 @@ func TestCommitNewFile(t *testing.T) {
|
||||||
t.Fatal(err, out)
|
t.Fatal(err, out)
|
||||||
}
|
}
|
||||||
if actual := strings.Trim(out, "\r\n"); actual != "koye" {
|
if actual := strings.Trim(out, "\r\n"); actual != "koye" {
|
||||||
t.Fatalf("expected output koye received %s", actual)
|
t.Fatalf("expected output koye received %q", actual)
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteAllContainers()
|
deleteAllContainers()
|
||||||
|
@ -92,7 +103,6 @@ func TestCommitNewFile(t *testing.T) {
|
||||||
|
|
||||||
func TestCommitTTY(t *testing.T) {
|
func TestCommitTTY(t *testing.T) {
|
||||||
cmd := exec.Command(dockerBinary, "run", "-t", "--name", "tty", "busybox", "/bin/ls")
|
cmd := exec.Command(dockerBinary, "run", "-t", "--name", "tty", "busybox", "/bin/ls")
|
||||||
|
|
||||||
if _, err := runCommand(cmd); err != nil {
|
if _, err := runCommand(cmd); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -105,7 +115,6 @@ func TestCommitTTY(t *testing.T) {
|
||||||
imageID = strings.Trim(imageID, "\r\n")
|
imageID = strings.Trim(imageID, "\r\n")
|
||||||
|
|
||||||
cmd = exec.Command(dockerBinary, "run", "ttytest", "/bin/ls")
|
cmd = exec.Command(dockerBinary, "run", "ttytest", "/bin/ls")
|
||||||
|
|
||||||
if _, err := runCommand(cmd); err != nil {
|
if _, err := runCommand(cmd); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -124,6 +133,7 @@ func TestCommitWithHostBindMount(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(imageID, err)
|
t.Fatal(imageID, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
imageID = strings.Trim(imageID, "\r\n")
|
imageID = strings.Trim(imageID, "\r\n")
|
||||||
|
|
||||||
cmd = exec.Command(dockerBinary, "run", "bindtest", "true")
|
cmd = exec.Command(dockerBinary, "run", "bindtest", "true")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue