mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Cleanup errorOut resp log tests
Docker-DCO-1.1-Signed-off-by: Jessica Frazelle <jess@docker.com> (github: jfrazelle)
This commit is contained in:
parent
9f52d8e6e7
commit
842d4b6b0a
1 changed files with 51 additions and 17 deletions
|
@ -16,14 +16,18 @@ func TestLogsContainerSmallerThanPage(t *testing.T) {
|
||||||
testLen := 32767
|
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))
|
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)
|
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)
|
cleanedContainerID := stripTrailingCharacters(out)
|
||||||
exec.Command(dockerBinary, "wait", cleanedContainerID).Run()
|
exec.Command(dockerBinary, "wait", cleanedContainerID).Run()
|
||||||
|
|
||||||
logsCmd := exec.Command(dockerBinary, "logs", cleanedContainerID)
|
logsCmd := exec.Command(dockerBinary, "logs", cleanedContainerID)
|
||||||
out, _, _, err = runCommandWithStdoutStderr(logsCmd)
|
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 {
|
if len(out) != testLen+1 {
|
||||||
t.Fatalf("Expected log length of %d, received %d\n", testLen+1, len(out))
|
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
|
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))
|
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)
|
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)
|
cleanedContainerID := stripTrailingCharacters(out)
|
||||||
exec.Command(dockerBinary, "wait", cleanedContainerID).Run()
|
exec.Command(dockerBinary, "wait", cleanedContainerID).Run()
|
||||||
|
|
||||||
logsCmd := exec.Command(dockerBinary, "logs", cleanedContainerID)
|
logsCmd := exec.Command(dockerBinary, "logs", cleanedContainerID)
|
||||||
out, _, _, err = runCommandWithStdoutStderr(logsCmd)
|
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 {
|
if len(out) != testLen+1 {
|
||||||
t.Fatalf("Expected log length of %d, received %d\n", testLen+1, len(out))
|
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
|
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))
|
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)
|
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)
|
cleanedContainerID := stripTrailingCharacters(out)
|
||||||
exec.Command(dockerBinary, "wait", cleanedContainerID).Run()
|
exec.Command(dockerBinary, "wait", cleanedContainerID).Run()
|
||||||
|
|
||||||
logsCmd := exec.Command(dockerBinary, "logs", cleanedContainerID)
|
logsCmd := exec.Command(dockerBinary, "logs", cleanedContainerID)
|
||||||
out, _, _, err = runCommandWithStdoutStderr(logsCmd)
|
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 {
|
if len(out) != testLen+1 {
|
||||||
t.Fatalf("Expected log length of %d, received %d\n", testLen+1, len(out))
|
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))
|
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)
|
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)
|
cleanedContainerID := stripTrailingCharacters(out)
|
||||||
exec.Command(dockerBinary, "wait", cleanedContainerID).Run()
|
exec.Command(dockerBinary, "wait", cleanedContainerID).Run()
|
||||||
|
|
||||||
logsCmd := exec.Command(dockerBinary, "logs", "-t", cleanedContainerID)
|
logsCmd := exec.Command(dockerBinary, "logs", "-t", cleanedContainerID)
|
||||||
out, _, _, err = runCommandWithStdoutStderr(logsCmd)
|
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")
|
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))
|
runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "sh", "-c", fmt.Sprintf("echo %s 1>&2", msg))
|
||||||
|
|
||||||
out, _, _, err := runCommandWithStdoutStderr(runCmd)
|
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)
|
cleanedContainerID := stripTrailingCharacters(out)
|
||||||
exec.Command(dockerBinary, "wait", cleanedContainerID).Run()
|
exec.Command(dockerBinary, "wait", cleanedContainerID).Run()
|
||||||
|
|
||||||
logsCmd := exec.Command(dockerBinary, "logs", cleanedContainerID)
|
logsCmd := exec.Command(dockerBinary, "logs", cleanedContainerID)
|
||||||
stdout, stderr, _, err := runCommandWithStdoutStderr(logsCmd)
|
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 != "" {
|
if stdout != "" {
|
||||||
t.Fatalf("Expected empty stdout stream, got %v", 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))
|
runCmd := exec.Command(dockerBinary, "run", "-d", "-t", "busybox", "sh", "-c", fmt.Sprintf("echo %s 1>&2", msg))
|
||||||
|
|
||||||
out, _, _, err := runCommandWithStdoutStderr(runCmd)
|
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)
|
cleanedContainerID := stripTrailingCharacters(out)
|
||||||
exec.Command(dockerBinary, "wait", cleanedContainerID).Run()
|
exec.Command(dockerBinary, "wait", cleanedContainerID).Run()
|
||||||
|
|
||||||
logsCmd := exec.Command(dockerBinary, "logs", cleanedContainerID)
|
logsCmd := exec.Command(dockerBinary, "logs", cleanedContainerID)
|
||||||
stdout, stderr, _, err := runCommandWithStdoutStderr(logsCmd)
|
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 != "" {
|
if stderr != "" {
|
||||||
t.Fatalf("Expected empty stderr stream, got %v", stdout)
|
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))
|
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)
|
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)
|
cleanedContainerID := stripTrailingCharacters(out)
|
||||||
exec.Command(dockerBinary, "wait", cleanedContainerID).Run()
|
exec.Command(dockerBinary, "wait", cleanedContainerID).Run()
|
||||||
|
|
||||||
logsCmd := exec.Command(dockerBinary, "logs", "--tail", "5", cleanedContainerID)
|
logsCmd := exec.Command(dockerBinary, "logs", "--tail", "5", cleanedContainerID)
|
||||||
out, _, _, err = runCommandWithStdoutStderr(logsCmd)
|
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")
|
lines := strings.Split(out, "\n")
|
||||||
|
|
||||||
|
@ -197,7 +225,9 @@ func TestLogsTail(t *testing.T) {
|
||||||
|
|
||||||
logsCmd = exec.Command(dockerBinary, "logs", "--tail", "all", cleanedContainerID)
|
logsCmd = exec.Command(dockerBinary, "logs", "--tail", "all", cleanedContainerID)
|
||||||
out, _, _, err = runCommandWithStdoutStderr(logsCmd)
|
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")
|
lines = strings.Split(out, "\n")
|
||||||
|
|
||||||
|
@ -207,7 +237,9 @@ func TestLogsTail(t *testing.T) {
|
||||||
|
|
||||||
logsCmd = exec.Command(dockerBinary, "logs", "--tail", "random", cleanedContainerID)
|
logsCmd = exec.Command(dockerBinary, "logs", "--tail", "random", cleanedContainerID)
|
||||||
out, _, _, err = runCommandWithStdoutStderr(logsCmd)
|
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")
|
lines = strings.Split(out, "\n")
|
||||||
|
|
||||||
|
@ -223,7 +255,9 @@ func TestLogsFollowStopped(t *testing.T) {
|
||||||
runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "echo", "hello")
|
runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "echo", "hello")
|
||||||
|
|
||||||
out, _, _, err := runCommandWithStdoutStderr(runCmd)
|
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)
|
cleanedContainerID := stripTrailingCharacters(out)
|
||||||
exec.Command(dockerBinary, "wait", cleanedContainerID).Run()
|
exec.Command(dockerBinary, "wait", cleanedContainerID).Run()
|
||||||
|
|
Loading…
Reference in a new issue