Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com>
| ... | ... |
@@ -213,3 +213,35 @@ func TestLogsTail(t *testing.T) {
|
| 213 | 213 |
deleteContainer(cleanedContainerID) |
| 214 | 214 |
logDone("logs - logs tail")
|
| 215 | 215 |
} |
| 216 |
+ |
|
| 217 |
+func TestLogsFollowStopped(t *testing.T) {
|
|
| 218 |
+ runCmd := exec.Command(dockerBinary, "run", "-d", "busybox", "echo", "hello") |
|
| 219 |
+ |
|
| 220 |
+ out, _, _, err := runCommandWithStdoutStderr(runCmd) |
|
| 221 |
+ errorOut(err, t, fmt.Sprintf("run failed with errors: %v", err))
|
|
| 222 |
+ |
|
| 223 |
+ cleanedContainerID := stripTrailingCharacters(out) |
|
| 224 |
+ exec.Command(dockerBinary, "wait", cleanedContainerID).Run() |
|
| 225 |
+ |
|
| 226 |
+ logsCmd := exec.Command(dockerBinary, "logs", "-f", cleanedContainerID) |
|
| 227 |
+ if err := logsCmd.Start(); err != nil {
|
|
| 228 |
+ t.Fatal(err) |
|
| 229 |
+ } |
|
| 230 |
+ |
|
| 231 |
+ c := make(chan struct{})
|
|
| 232 |
+ go func() {
|
|
| 233 |
+ if err := logsCmd.Wait(); err != nil {
|
|
| 234 |
+ t.Fatal(err) |
|
| 235 |
+ } |
|
| 236 |
+ close(c) |
|
| 237 |
+ }() |
|
| 238 |
+ |
|
| 239 |
+ select {
|
|
| 240 |
+ case <-c: |
|
| 241 |
+ case <-time.After(1 * time.Second): |
|
| 242 |
+ t.Fatal("Following logs is hanged")
|
|
| 243 |
+ } |
|
| 244 |
+ |
|
| 245 |
+ deleteContainer(cleanedContainerID) |
|
| 246 |
+ logDone("logs - logs follow stopped container")
|
|
| 247 |
+} |