Docker-DCO-1.1-Signed-off-by: Jessica Frazelle <jess@docker.com> (github: jfrazelle)
| ... | ... |
@@ -16,14 +16,18 @@ func TestLogsContainerSmallerThanPage(t *testing.T) {
|
| 16 | 16 |
testLen := 32767 |
| 17 | 17 |
runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "sh", "-c", fmt.Sprintf("for i in $(seq 1 %d); do echo -n =; done; echo", testLen))
|
| 18 | 18 |
out, _, _, err := runCommandWithStdoutStderr(runCmd) |
| 19 |
- errorOut(err, t, fmt.Sprintf("run failed with errors: %v", err))
|
|
| 19 |
+ if err != nil {
|
|
| 20 |
+ t.Fatalf("run failed with errors: %s, %v", out, err)
|
|
| 21 |
+ } |
|
| 20 | 22 |
|
| 21 | 23 |
cleanedContainerID := stripTrailingCharacters(out) |
| 22 | 24 |
exec.Command(dockerBinary, "wait", cleanedContainerID).Run() |
| 23 | 25 |
|
| 24 | 26 |
logsCmd := exec.Command(dockerBinary, "logs", cleanedContainerID) |
| 25 | 27 |
out, _, _, err = runCommandWithStdoutStderr(logsCmd) |
| 26 |
- errorOut(err, t, fmt.Sprintf("failed to log container: %v %v", out, err))
|
|
| 28 |
+ if err != nil {
|
|
| 29 |
+ t.Fatalf("failed to log container: %s, %v", out, err)
|
|
| 30 |
+ } |
|
| 27 | 31 |
|
| 28 | 32 |
if len(out) != testLen+1 {
|
| 29 | 33 |
t.Fatalf("Expected log length of %d, received %d\n", testLen+1, len(out))
|
| ... | ... |
@@ -39,14 +43,18 @@ func TestLogsContainerBiggerThanPage(t *testing.T) {
|
| 39 | 39 |
testLen := 32768 |
| 40 | 40 |
runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "sh", "-c", fmt.Sprintf("for i in $(seq 1 %d); do echo -n =; done; echo", testLen))
|
| 41 | 41 |
out, _, _, err := runCommandWithStdoutStderr(runCmd) |
| 42 |
- errorOut(err, t, fmt.Sprintf("run failed with errors: %v", err))
|
|
| 42 |
+ if err != nil {
|
|
| 43 |
+ t.Fatalf("run failed with errors: %s, %v", out, err)
|
|
| 44 |
+ } |
|
| 43 | 45 |
|
| 44 | 46 |
cleanedContainerID := stripTrailingCharacters(out) |
| 45 | 47 |
exec.Command(dockerBinary, "wait", cleanedContainerID).Run() |
| 46 | 48 |
|
| 47 | 49 |
logsCmd := exec.Command(dockerBinary, "logs", cleanedContainerID) |
| 48 | 50 |
out, _, _, err = runCommandWithStdoutStderr(logsCmd) |
| 49 |
- errorOut(err, t, fmt.Sprintf("failed to log container: %v %v", out, err))
|
|
| 51 |
+ if err != nil {
|
|
| 52 |
+ t.Fatalf("failed to log container: %s, %v", out, err)
|
|
| 53 |
+ } |
|
| 50 | 54 |
|
| 51 | 55 |
if len(out) != testLen+1 {
|
| 52 | 56 |
t.Fatalf("Expected log length of %d, received %d\n", testLen+1, len(out))
|
| ... | ... |
@@ -62,14 +70,18 @@ func TestLogsContainerMuchBiggerThanPage(t *testing.T) {
|
| 62 | 62 |
testLen := 33000 |
| 63 | 63 |
runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "sh", "-c", fmt.Sprintf("for i in $(seq 1 %d); do echo -n =; done; echo", testLen))
|
| 64 | 64 |
out, _, _, err := runCommandWithStdoutStderr(runCmd) |
| 65 |
- errorOut(err, t, fmt.Sprintf("run failed with errors: %v", err))
|
|
| 65 |
+ if err != nil {
|
|
| 66 |
+ t.Fatalf("run failed with errors: %s, %v", out, err)
|
|
| 67 |
+ } |
|
| 66 | 68 |
|
| 67 | 69 |
cleanedContainerID := stripTrailingCharacters(out) |
| 68 | 70 |
exec.Command(dockerBinary, "wait", cleanedContainerID).Run() |
| 69 | 71 |
|
| 70 | 72 |
logsCmd := exec.Command(dockerBinary, "logs", cleanedContainerID) |
| 71 | 73 |
out, _, _, err = runCommandWithStdoutStderr(logsCmd) |
| 72 |
- errorOut(err, t, fmt.Sprintf("failed to log container: %v %v", out, err))
|
|
| 74 |
+ if err != nil {
|
|
| 75 |
+ t.Fatalf("failed to log container: %s, %v", out, err)
|
|
| 76 |
+ } |
|
| 73 | 77 |
|
| 74 | 78 |
if len(out) != testLen+1 {
|
| 75 | 79 |
t.Fatalf("Expected log length of %d, received %d\n", testLen+1, len(out))
|
| ... | ... |
@@ -85,14 +97,18 @@ func TestLogsTimestamps(t *testing.T) {
|
| 85 | 85 |
runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "sh", "-c", fmt.Sprintf("for i in $(seq 1 %d); do echo =; done;", testLen))
|
| 86 | 86 |
|
| 87 | 87 |
out, _, _, err := runCommandWithStdoutStderr(runCmd) |
| 88 |
- errorOut(err, t, fmt.Sprintf("run failed with errors: %v", err))
|
|
| 88 |
+ if err != nil {
|
|
| 89 |
+ t.Fatalf("run failed with errors: %s, %v", out, err)
|
|
| 90 |
+ } |
|
| 89 | 91 |
|
| 90 | 92 |
cleanedContainerID := stripTrailingCharacters(out) |
| 91 | 93 |
exec.Command(dockerBinary, "wait", cleanedContainerID).Run() |
| 92 | 94 |
|
| 93 | 95 |
logsCmd := exec.Command(dockerBinary, "logs", "-t", cleanedContainerID) |
| 94 | 96 |
out, _, _, err = runCommandWithStdoutStderr(logsCmd) |
| 95 |
- errorOut(err, t, fmt.Sprintf("failed to log container: %v %v", out, err))
|
|
| 97 |
+ if err != nil {
|
|
| 98 |
+ t.Fatalf("failed to log container: %s, %v", out, err)
|
|
| 99 |
+ } |
|
| 96 | 100 |
|
| 97 | 101 |
lines := strings.Split(out, "\n") |
| 98 | 102 |
|
| ... | ... |
@@ -124,14 +140,18 @@ func TestLogsSeparateStderr(t *testing.T) {
|
| 124 | 124 |
runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "sh", "-c", fmt.Sprintf("echo %s 1>&2", msg))
|
| 125 | 125 |
|
| 126 | 126 |
out, _, _, err := runCommandWithStdoutStderr(runCmd) |
| 127 |
- errorOut(err, t, fmt.Sprintf("run failed with errors: %v", err))
|
|
| 127 |
+ if err != nil {
|
|
| 128 |
+ t.Fatalf("run failed with errors: %s, %v", out, err)
|
|
| 129 |
+ } |
|
| 128 | 130 |
|
| 129 | 131 |
cleanedContainerID := stripTrailingCharacters(out) |
| 130 | 132 |
exec.Command(dockerBinary, "wait", cleanedContainerID).Run() |
| 131 | 133 |
|
| 132 | 134 |
logsCmd := exec.Command(dockerBinary, "logs", cleanedContainerID) |
| 133 | 135 |
stdout, stderr, _, err := runCommandWithStdoutStderr(logsCmd) |
| 134 |
- errorOut(err, t, fmt.Sprintf("failed to log container: %v %v", out, err))
|
|
| 136 |
+ if err != nil {
|
|
| 137 |
+ t.Fatalf("failed to log container: %s, %v", out, err)
|
|
| 138 |
+ } |
|
| 135 | 139 |
|
| 136 | 140 |
if stdout != "" {
|
| 137 | 141 |
t.Fatalf("Expected empty stdout stream, got %v", stdout)
|
| ... | ... |
@@ -152,14 +172,18 @@ func TestLogsStderrInStdout(t *testing.T) {
|
| 152 | 152 |
runCmd := exec.Command(dockerBinary, "run", "-d", "-t", "busybox", "sh", "-c", fmt.Sprintf("echo %s 1>&2", msg))
|
| 153 | 153 |
|
| 154 | 154 |
out, _, _, err := runCommandWithStdoutStderr(runCmd) |
| 155 |
- errorOut(err, t, fmt.Sprintf("run failed with errors: %v", err))
|
|
| 155 |
+ if err != nil {
|
|
| 156 |
+ t.Fatalf("run failed with errors: %s, %v", out, err)
|
|
| 157 |
+ } |
|
| 156 | 158 |
|
| 157 | 159 |
cleanedContainerID := stripTrailingCharacters(out) |
| 158 | 160 |
exec.Command(dockerBinary, "wait", cleanedContainerID).Run() |
| 159 | 161 |
|
| 160 | 162 |
logsCmd := exec.Command(dockerBinary, "logs", cleanedContainerID) |
| 161 | 163 |
stdout, stderr, _, err := runCommandWithStdoutStderr(logsCmd) |
| 162 |
- errorOut(err, t, fmt.Sprintf("failed to log container: %v %v", out, err))
|
|
| 164 |
+ if err != nil {
|
|
| 165 |
+ t.Fatalf("failed to log container: %s, %v", out, err)
|
|
| 166 |
+ } |
|
| 163 | 167 |
|
| 164 | 168 |
if stderr != "" {
|
| 165 | 169 |
t.Fatalf("Expected empty stderr stream, got %v", stdout)
|
| ... | ... |
@@ -180,14 +204,18 @@ func TestLogsTail(t *testing.T) {
|
| 180 | 180 |
runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "sh", "-c", fmt.Sprintf("for i in $(seq 1 %d); do echo =; done;", testLen))
|
| 181 | 181 |
|
| 182 | 182 |
out, _, _, err := runCommandWithStdoutStderr(runCmd) |
| 183 |
- errorOut(err, t, fmt.Sprintf("run failed with errors: %v", err))
|
|
| 183 |
+ if err != nil {
|
|
| 184 |
+ t.Fatalf("run failed with errors: %s, %v", out, err)
|
|
| 185 |
+ } |
|
| 184 | 186 |
|
| 185 | 187 |
cleanedContainerID := stripTrailingCharacters(out) |
| 186 | 188 |
exec.Command(dockerBinary, "wait", cleanedContainerID).Run() |
| 187 | 189 |
|
| 188 | 190 |
logsCmd := exec.Command(dockerBinary, "logs", "--tail", "5", cleanedContainerID) |
| 189 | 191 |
out, _, _, err = runCommandWithStdoutStderr(logsCmd) |
| 190 |
- errorOut(err, t, fmt.Sprintf("failed to log container: %v %v", out, err))
|
|
| 192 |
+ if err != nil {
|
|
| 193 |
+ t.Fatalf("failed to log container: %s, %v", out, err)
|
|
| 194 |
+ } |
|
| 191 | 195 |
|
| 192 | 196 |
lines := strings.Split(out, "\n") |
| 193 | 197 |
|
| ... | ... |
@@ -197,7 +225,9 @@ func TestLogsTail(t *testing.T) {
|
| 197 | 197 |
|
| 198 | 198 |
logsCmd = exec.Command(dockerBinary, "logs", "--tail", "all", cleanedContainerID) |
| 199 | 199 |
out, _, _, err = runCommandWithStdoutStderr(logsCmd) |
| 200 |
- errorOut(err, t, fmt.Sprintf("failed to log container: %v %v", out, err))
|
|
| 200 |
+ if err != nil {
|
|
| 201 |
+ t.Fatalf("failed to log container: %s, %v", out, err)
|
|
| 202 |
+ } |
|
| 201 | 203 |
|
| 202 | 204 |
lines = strings.Split(out, "\n") |
| 203 | 205 |
|
| ... | ... |
@@ -207,7 +237,9 @@ func TestLogsTail(t *testing.T) {
|
| 207 | 207 |
|
| 208 | 208 |
logsCmd = exec.Command(dockerBinary, "logs", "--tail", "random", cleanedContainerID) |
| 209 | 209 |
out, _, _, err = runCommandWithStdoutStderr(logsCmd) |
| 210 |
- errorOut(err, t, fmt.Sprintf("failed to log container: %v %v", out, err))
|
|
| 210 |
+ if err != nil {
|
|
| 211 |
+ t.Fatalf("failed to log container: %s, %v", out, err)
|
|
| 212 |
+ } |
|
| 211 | 213 |
|
| 212 | 214 |
lines = strings.Split(out, "\n") |
| 213 | 215 |
|
| ... | ... |
@@ -223,7 +255,9 @@ func TestLogsFollowStopped(t *testing.T) {
|
| 223 | 223 |
runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "echo", "hello") |
| 224 | 224 |
|
| 225 | 225 |
out, _, _, err := runCommandWithStdoutStderr(runCmd) |
| 226 |
- errorOut(err, t, fmt.Sprintf("run failed with errors: %v", err))
|
|
| 226 |
+ if err != nil {
|
|
| 227 |
+ t.Fatalf("run failed with errors: %s, %v", out, err)
|
|
| 228 |
+ } |
|
| 227 | 229 |
|
| 228 | 230 |
cleanedContainerID := stripTrailingCharacters(out) |
| 229 | 231 |
exec.Command(dockerBinary, "wait", cleanedContainerID).Run() |