From 168d6b41a8b738389dd7e866f4a7a50dc4967923 Mon Sep 17 00:00:00 2001 From: Jessica Frazelle Date: Tue, 14 Oct 2014 14:22:49 -0700 Subject: [PATCH] Cleanup errorOut resp log tests Docker-DCO-1.1-Signed-off-by: Jessica Frazelle (github: jfrazelle) Upstream-commit: 842d4b6b0afb0380afeea6d1638edb8913ae70bd Component: engine --- .../integration-cli/docker_cli_logs_test.go | 68 ++++++++++++++----- 1 file changed, 51 insertions(+), 17 deletions(-) diff --git a/components/engine/integration-cli/docker_cli_logs_test.go b/components/engine/integration-cli/docker_cli_logs_test.go index 2407291cdb..d6d3f9320f 100644 --- a/components/engine/integration-cli/docker_cli_logs_test.go +++ b/components/engine/integration-cli/docker_cli_logs_test.go @@ -16,14 +16,18 @@ func TestLogsContainerSmallerThanPage(t *testing.T) { testLen := 32767 runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "sh", "-c", fmt.Sprintf("for i in $(seq 1 %d); do echo -n =; done; echo", testLen)) out, _, _, err := runCommandWithStdoutStderr(runCmd) - errorOut(err, t, fmt.Sprintf("run failed with errors: %v", err)) + if err != nil { + t.Fatalf("run failed with errors: %s, %v", out, err) + } cleanedContainerID := stripTrailingCharacters(out) exec.Command(dockerBinary, "wait", cleanedContainerID).Run() logsCmd := exec.Command(dockerBinary, "logs", cleanedContainerID) out, _, _, err = runCommandWithStdoutStderr(logsCmd) - errorOut(err, t, fmt.Sprintf("failed to log container: %v %v", out, err)) + if err != nil { + t.Fatalf("failed to log container: %s, %v", out, err) + } if len(out) != testLen+1 { t.Fatalf("Expected log length of %d, received %d\n", testLen+1, len(out)) @@ -39,14 +43,18 @@ func TestLogsContainerBiggerThanPage(t *testing.T) { testLen := 32768 runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "sh", "-c", fmt.Sprintf("for i in $(seq 1 %d); do echo -n =; done; echo", testLen)) out, _, _, err := runCommandWithStdoutStderr(runCmd) - errorOut(err, t, fmt.Sprintf("run failed with errors: %v", err)) + if err != nil { + t.Fatalf("run failed with errors: %s, %v", out, err) + } cleanedContainerID := stripTrailingCharacters(out) exec.Command(dockerBinary, "wait", cleanedContainerID).Run() logsCmd := exec.Command(dockerBinary, "logs", cleanedContainerID) out, _, _, err = runCommandWithStdoutStderr(logsCmd) - errorOut(err, t, fmt.Sprintf("failed to log container: %v %v", out, err)) + if err != nil { + t.Fatalf("failed to log container: %s, %v", out, err) + } if len(out) != testLen+1 { t.Fatalf("Expected log length of %d, received %d\n", testLen+1, len(out)) @@ -62,14 +70,18 @@ func TestLogsContainerMuchBiggerThanPage(t *testing.T) { testLen := 33000 runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "sh", "-c", fmt.Sprintf("for i in $(seq 1 %d); do echo -n =; done; echo", testLen)) out, _, _, err := runCommandWithStdoutStderr(runCmd) - errorOut(err, t, fmt.Sprintf("run failed with errors: %v", err)) + if err != nil { + t.Fatalf("run failed with errors: %s, %v", out, err) + } cleanedContainerID := stripTrailingCharacters(out) exec.Command(dockerBinary, "wait", cleanedContainerID).Run() logsCmd := exec.Command(dockerBinary, "logs", cleanedContainerID) out, _, _, err = runCommandWithStdoutStderr(logsCmd) - errorOut(err, t, fmt.Sprintf("failed to log container: %v %v", out, err)) + if err != nil { + t.Fatalf("failed to log container: %s, %v", out, err) + } if len(out) != testLen+1 { t.Fatalf("Expected log length of %d, received %d\n", testLen+1, len(out)) @@ -85,14 +97,18 @@ func TestLogsTimestamps(t *testing.T) { runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "sh", "-c", fmt.Sprintf("for i in $(seq 1 %d); do echo =; done;", testLen)) out, _, _, err := runCommandWithStdoutStderr(runCmd) - errorOut(err, t, fmt.Sprintf("run failed with errors: %v", err)) + if err != nil { + t.Fatalf("run failed with errors: %s, %v", out, err) + } cleanedContainerID := stripTrailingCharacters(out) exec.Command(dockerBinary, "wait", cleanedContainerID).Run() logsCmd := exec.Command(dockerBinary, "logs", "-t", cleanedContainerID) out, _, _, err = runCommandWithStdoutStderr(logsCmd) - errorOut(err, t, fmt.Sprintf("failed to log container: %v %v", out, err)) + if err != nil { + t.Fatalf("failed to log container: %s, %v", out, err) + } lines := strings.Split(out, "\n") @@ -124,14 +140,18 @@ func TestLogsSeparateStderr(t *testing.T) { runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "sh", "-c", fmt.Sprintf("echo %s 1>&2", msg)) out, _, _, err := runCommandWithStdoutStderr(runCmd) - errorOut(err, t, fmt.Sprintf("run failed with errors: %v", err)) + if err != nil { + t.Fatalf("run failed with errors: %s, %v", out, err) + } cleanedContainerID := stripTrailingCharacters(out) exec.Command(dockerBinary, "wait", cleanedContainerID).Run() logsCmd := exec.Command(dockerBinary, "logs", cleanedContainerID) stdout, stderr, _, err := runCommandWithStdoutStderr(logsCmd) - errorOut(err, t, fmt.Sprintf("failed to log container: %v %v", out, err)) + if err != nil { + t.Fatalf("failed to log container: %s, %v", out, err) + } if stdout != "" { t.Fatalf("Expected empty stdout stream, got %v", stdout) @@ -152,14 +172,18 @@ func TestLogsStderrInStdout(t *testing.T) { runCmd := exec.Command(dockerBinary, "run", "-d", "-t", "busybox", "sh", "-c", fmt.Sprintf("echo %s 1>&2", msg)) out, _, _, err := runCommandWithStdoutStderr(runCmd) - errorOut(err, t, fmt.Sprintf("run failed with errors: %v", err)) + if err != nil { + t.Fatalf("run failed with errors: %s, %v", out, err) + } cleanedContainerID := stripTrailingCharacters(out) exec.Command(dockerBinary, "wait", cleanedContainerID).Run() logsCmd := exec.Command(dockerBinary, "logs", cleanedContainerID) stdout, stderr, _, err := runCommandWithStdoutStderr(logsCmd) - errorOut(err, t, fmt.Sprintf("failed to log container: %v %v", out, err)) + if err != nil { + t.Fatalf("failed to log container: %s, %v", out, err) + } if stderr != "" { t.Fatalf("Expected empty stderr stream, got %v", stdout) @@ -180,14 +204,18 @@ func TestLogsTail(t *testing.T) { runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "sh", "-c", fmt.Sprintf("for i in $(seq 1 %d); do echo =; done;", testLen)) out, _, _, err := runCommandWithStdoutStderr(runCmd) - errorOut(err, t, fmt.Sprintf("run failed with errors: %v", err)) + if err != nil { + t.Fatalf("run failed with errors: %s, %v", out, err) + } cleanedContainerID := stripTrailingCharacters(out) exec.Command(dockerBinary, "wait", cleanedContainerID).Run() logsCmd := exec.Command(dockerBinary, "logs", "--tail", "5", cleanedContainerID) out, _, _, err = runCommandWithStdoutStderr(logsCmd) - errorOut(err, t, fmt.Sprintf("failed to log container: %v %v", out, err)) + if err != nil { + t.Fatalf("failed to log container: %s, %v", out, err) + } lines := strings.Split(out, "\n") @@ -197,7 +225,9 @@ func TestLogsTail(t *testing.T) { logsCmd = exec.Command(dockerBinary, "logs", "--tail", "all", cleanedContainerID) out, _, _, err = runCommandWithStdoutStderr(logsCmd) - errorOut(err, t, fmt.Sprintf("failed to log container: %v %v", out, err)) + if err != nil { + t.Fatalf("failed to log container: %s, %v", out, err) + } lines = strings.Split(out, "\n") @@ -207,7 +237,9 @@ func TestLogsTail(t *testing.T) { logsCmd = exec.Command(dockerBinary, "logs", "--tail", "random", cleanedContainerID) out, _, _, err = runCommandWithStdoutStderr(logsCmd) - errorOut(err, t, fmt.Sprintf("failed to log container: %v %v", out, err)) + if err != nil { + t.Fatalf("failed to log container: %s, %v", out, err) + } lines = strings.Split(out, "\n") @@ -223,7 +255,9 @@ func TestLogsFollowStopped(t *testing.T) { runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "echo", "hello") out, _, _, err := runCommandWithStdoutStderr(runCmd) - errorOut(err, t, fmt.Sprintf("run failed with errors: %v", err)) + if err != nil { + t.Fatalf("run failed with errors: %s, %v", out, err) + } cleanedContainerID := stripTrailingCharacters(out) exec.Command(dockerBinary, "wait", cleanedContainerID).Run()